using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using UnityEngine;
using UnityEngine.Rendering;
using Zorro.Core;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.1", FrameworkDisplayName = ".NET Framework 4.7.1")]
[assembly: AssemblyCompany("RandomAirstrikes")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.11.0")]
[assembly: AssemblyInformationalVersion("1.0.11+ba429e5a1e80b65c2c3fc3e9502b85d0e4725f70")]
[assembly: AssemblyProduct("RandomAirstrikes")]
[assembly: AssemblyTitle("RandomAirstrikes")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.11.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte P_0)
{
NullableFlags = new byte[1] { P_0 };
}
public NullableAttribute(byte[] P_0)
{
NullableFlags = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
internal sealed class NullableContextAttribute : Attribute
{
public readonly byte Flag;
public NullableContextAttribute(byte P_0)
{
Flag = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace BepInEx
{
[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
[Conditional("CodeGeneration")]
internal sealed class BepInAutoPluginAttribute : Attribute
{
public BepInAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
{
}
}
}
namespace BepInEx.Preloader.Core.Patching
{
[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
[Conditional("CodeGeneration")]
internal sealed class PatcherAutoPluginAttribute : Attribute
{
public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
{
}
}
}
namespace RandomAirstrikes
{
[BepInPlugin("RandomAirstrikes", "RandomAirstrikes", "1.0.11")]
internal class Plugin : BaseUnityPlugin
{
[HarmonyPatch(typeof(ExplosionEffect), "GetPoints")]
private static class ReduceDynamiteCloudInstanceCount
{
public static void Postfix(ExplosionEffect __instance)
{
if (ReduceExplosionCloudDensity)
{
__instance.explosionPoints = new List<ExplosionOrb>(1) { __instance.explosionPoints[0] };
}
}
}
internal static ManualLogSource Logger;
internal static ConfigEntry<float> meanSecondsBetweenStrikesCfg;
internal static ConfigEntry<float> rangeSecondsBetweenStrikesCfg;
internal static ConfigEntry<float> QueueProcessFrameDelaySecondsCfg;
internal static ConfigEntry<float> AirstrikeDropDistanceCfg;
internal static ConfigEntry<float> AirstrikeDropDistanceSidewaysCfg;
internal static ConfigEntry<uint> AirstrikeDynamiteCountPerLineCfg;
internal static ConfigEntry<uint> AirstrikeDynamiteLineCountCfg;
internal static ConfigEntry<float> AirstrikeFuseDurationCfg;
internal static ConfigEntry<bool> ReduceExplosionCloudDensityCfg;
internal static ConfigEntry<float> CampfireSafeZoneRadiusCfg;
internal static ConfigEntry<float> CampfirePostLitGracePeriodSecondsCfg;
private static bool Initted;
private float secondsTillNextDrop;
private Vector3 lastPos = Vector3.zero;
private Character airstrikeTarget;
private float timeTillAirstrike = -1f;
private const float airstrikePlayerVelocityEstimationTime = 1f;
private Vector3? lastCampfirePos;
private Queue<Action> SpawnQueue = new Queue<Action>();
private float queueProcessCountdownSeconds;
public const string Id = "RandomAirstrikes";
public bool IsNetHost => PhotonNetwork.IsMasterClient;
private float MeanSecondsBetweenStrikes => meanSecondsBetweenStrikesCfg.Value;
private float RangeSecondsBetweenStrikes => rangeSecondsBetweenStrikesCfg.Value;
private float QueueProcessFrameDelaySeconds => QueueProcessFrameDelaySecondsCfg.Value;
private float AirstrikeDropDistance => AirstrikeDropDistanceCfg.Value;
private float AirstrikeDropDistanceSideways => AirstrikeDropDistanceSidewaysCfg.Value;
private uint AirstrikeDynamiteCountPerLine => AirstrikeDynamiteCountPerLineCfg.Value;
private uint AirstrikeDynamiteLineCount => AirstrikeDynamiteLineCountCfg.Value;
private float AirstrikeFuseDuration => AirstrikeFuseDurationCfg.Value;
private float CampfireSafeZoneRadius => CampfireSafeZoneRadiusCfg.Value;
private float CampfirePostLitGracePeriodSeconds => CampfirePostLitGracePeriodSecondsCfg.Value;
private static bool ReduceExplosionCloudDensity => ReduceExplosionCloudDensityCfg.Value;
public static string Name => "RandomAirstrikes";
public static string Version => "1.0.11";
private float GetNextStrikeDelay()
{
return Random.Range(MeanSecondsBetweenStrikes - RangeSecondsBetweenStrikes, MeanSecondsBetweenStrikes + RangeSecondsBetweenStrikes);
}
internal void Awake()
{
//IL_0216: Unknown result type (might be due to invalid IL or missing references)
Logger = ((BaseUnityPlugin)this).Logger;
meanSecondsBetweenStrikesCfg = ((BaseUnityPlugin)this).Config.Bind<float>("General", "MeanTimeBetweenStrikesInSeconds", 15f, "Time in seconds between strikes, on average.");
rangeSecondsBetweenStrikesCfg = ((BaseUnityPlugin)this).Config.Bind<float>("General", "TimeBetweenStrikesRangeInSeconds", 10f, "How much the drop delay may deviate from the mean (+/-), so the delay is somewhere between [MeanTime-Range, MeanTime+Range]; Min value: MeanTime");
if (rangeSecondsBetweenStrikesCfg.Value > meanSecondsBetweenStrikesCfg.Value)
{
Logger.LogWarning((object)($"TimeBetweenStrikesRangeInSeconds value of {rangeSecondsBetweenStrikesCfg.Value} is too large, " + $"setting it to MeanTimeBetweenStrikesInSeconds={meanSecondsBetweenStrikesCfg.Value}"));
rangeSecondsBetweenStrikesCfg.Value = rangeSecondsBetweenStrikesCfg.Value;
}
QueueProcessFrameDelaySecondsCfg = ((BaseUnityPlugin)this).Config.Bind<float>("General", "DynamiteSpawnDelayInSeconds", 0.05f, "Delay between dynamite spawns.");
AirstrikeDropDistanceCfg = ((BaseUnityPlugin)this).Config.Bind<float>("General", "AirstrikeDropDistance", 2f, "Distance in meters between the individual pieces of dynamite in the drop-line.");
AirstrikeDropDistanceSidewaysCfg = ((BaseUnityPlugin)this).Config.Bind<float>("General", "AirstrikeDropDistance", 2f, "Distance in meters between the individual lines of dynamite drops.");
AirstrikeFuseDurationCfg = ((BaseUnityPlugin)this).Config.Bind<float>("General", "AirstrikeFuseDuration", 15f, "The fuse of the dynamite when it starts dropping.");
CampfireSafeZoneRadiusCfg = ((BaseUnityPlugin)this).Config.Bind<float>("General", "CampfireSafeZoneRadius", 35f, "Distance to the next unlit campfire which is considered a safe-zone, in which, players will not be targeted by airstrikes.");
CampfirePostLitGracePeriodSecondsCfg = ((BaseUnityPlugin)this).Config.Bind<float>("General", "CampfirePostLitGracePeriodSeconds", 15f, "After lighting a campfire, for this duration no airstrikes will be sent.");
AirstrikeDynamiteCountPerLineCfg = ((BaseUnityPlugin)this).Config.Bind<uint>("General", "AirstrikeDynamiteCountPerLine", 7u, "Number of dynamite pieces that a single airstrike line consists of.");
AirstrikeDynamiteLineCountCfg = ((BaseUnityPlugin)this).Config.Bind<uint>("General", "AirstrikeDynamiteLineCount", 1u, "Number of dynamite lines per airstrike.");
ReduceExplosionCloudDensityCfg = ((BaseUnityPlugin)this).Config.Bind<bool>("Performance", "ReduceExplosionCloudDensity", true, "Decreases the amount of explosion cloud objects spawned (by PEAK) per explosion to 1 instead of 13. This affects ALL dynamite explosions but massively helps performance. Set to 'false' for vanilla behaviour.");
secondsTillNextDrop = MeanSecondsBetweenStrikes;
Logger.LogInfo((object)"Plugin RandomAirstrikes is loaded!");
new Harmony("RandomAirstrikes").PatchAll();
}
internal static void Init()
{
if (!Initted)
{
Initted = true;
Logger.LogInfo((object)"Initted");
}
}
private static void ForceSyncForFrames(Item i, int frames = 10)
{
i.ForceSyncForFrames(frames);
}
internal void Update()
{
//IL_01de: Unknown result type (might be due to invalid IL or missing references)
//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
//IL_0123: Unknown result type (might be due to invalid IL or missing references)
//IL_0128: Unknown result type (might be due to invalid IL or missing references)
//IL_012a: Unknown result type (might be due to invalid IL or missing references)
//IL_012d: Unknown result type (might be due to invalid IL or missing references)
//IL_0132: Unknown result type (might be due to invalid IL or missing references)
//IL_013c: Unknown result type (might be due to invalid IL or missing references)
//IL_0141: Unknown result type (might be due to invalid IL or missing references)
//IL_014f: Unknown result type (might be due to invalid IL or missing references)
//IL_0154: Unknown result type (might be due to invalid IL or missing references)
//IL_0173: Unknown result type (might be due to invalid IL or missing references)
//IL_0175: Unknown result type (might be due to invalid IL or missing references)
//IL_0177: Unknown result type (might be due to invalid IL or missing references)
//IL_017c: Unknown result type (might be due to invalid IL or missing references)
//IL_0186: Unknown result type (might be due to invalid IL or missing references)
//IL_018b: Unknown result type (might be due to invalid IL or missing references)
//IL_0190: Unknown result type (might be due to invalid IL or missing references)
//IL_016b: Unknown result type (might be due to invalid IL or missing references)
//IL_0170: Unknown result type (might be due to invalid IL or missing references)
//IL_0254: Unknown result type (might be due to invalid IL or missing references)
//IL_0259: Unknown result type (might be due to invalid IL or missing references)
//IL_027f: Unknown result type (might be due to invalid IL or missing references)
//IL_028a: Unknown result type (might be due to invalid IL or missing references)
//IL_028f: Unknown result type (might be due to invalid IL or missing references)
//IL_026d: Unknown result type (might be due to invalid IL or missing references)
//IL_02ae: Unknown result type (might be due to invalid IL or missing references)
//IL_030c: Unknown result type (might be due to invalid IL or missing references)
//IL_0311: Unknown result type (might be due to invalid IL or missing references)
if (!IsNetHost)
{
return;
}
float deltaTime = Time.deltaTime;
CharacterData val = Character.localCharacter?.data;
if ((Object)(object)val == (Object)null || val.passedOutOnTheBeach > 0f)
{
SpawnQueue.Clear();
lastCampfirePos = null;
return;
}
if (SpawnQueue.Count > 0 && (queueProcessCountdownSeconds -= deltaTime) <= 0f)
{
SpawnQueue.Dequeue()();
queueProcessCountdownSeconds = QueueProcessFrameDelaySeconds;
}
MountainProgressHandler instance = Singleton<MountainProgressHandler>.Instance;
if ((Object)(object)instance == (Object)null || instance.progressPoints.Single((ProgressPoint x) => (int)x.biome == 5).Reached)
{
return;
}
secondsTillNextDrop -= deltaTime;
if ((Object)(object)airstrikeTarget != (Object)null && (timeTillAirstrike -= deltaTime) < 0f)
{
Vector3 center = airstrikeTarget.Center;
Vector3 val2 = (center - lastPos) / 1f;
val2.y = 0f;
Vector3 planeFlightDirection = Vector3.zero;
if ((double)((Vector3)(ref val2)).sqrMagnitude > 0.01)
{
planeFlightDirection = ((Vector3)(ref val2)).normalized;
}
AirstrikeAtPlayerPosition(center + val2 + Vector3.up * 20f, planeFlightDirection);
airstrikeTarget = null;
}
if (secondsTillNextDrop > 0f)
{
return;
}
secondsTillNextDrop = GetNextStrikeDelay();
MapHandler instance2 = Singleton<MapHandler>.Instance;
MapSegment val3 = instance2.segments[instance2.currentSegment];
GameObject currentCampfire = val3.segmentCampfire;
Vector3 currentCampfirePos = Vector3.zero;
if ((Object)(object)currentCampfire == (Object)null)
{
if (lastCampfirePos.HasValue)
{
secondsTillNextDrop = CampfirePostLitGracePeriodSeconds;
lastCampfirePos = null;
return;
}
}
else
{
currentCampfirePos = ((Component)currentCampfire.GetComponentsInChildren<MeshRenderer>().First((MeshRenderer x) => ((Object)x).name == "Cube")).transform.position;
if (!lastCampfirePos.HasValue)
{
lastCampfirePos = currentCampfirePos;
}
else if (Vector3.SqrMagnitude(currentCampfirePos - lastCampfirePos.Value) > 900f)
{
secondsTillNextDrop = CampfirePostLitGracePeriodSeconds;
lastCampfirePos = currentCampfirePos;
return;
}
}
Character[] array = Character.AllCharacters.Where((Character x) => !x.data.dead && ((Object)(object)currentCampfire == (Object)null || Vector3.Distance(x.Center, currentCampfirePos) > CampfireSafeZoneRadius)).ToArray();
if (array.Length != 0)
{
Character val4 = array[Random.Range(0, array.Length)];
if ((Object)(object)airstrikeTarget == (Object)null)
{
timeTillAirstrike = 1f;
lastPos = val4.Center;
airstrikeTarget = val4;
}
}
}
private void AirstrikeAtPlayerPosition(Vector3 playerPos, Vector3 planeFlightDirection)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
Vector3 val = Vector3.Cross(Vector3.up, planeFlightDirection);
for (int i = 0; i < AirstrikeDynamiteCountPerLine; i++)
{
float num = (float)(AirstrikeDynamiteLineCount - 1) / 2f;
for (int j = 0; j < AirstrikeDynamiteLineCount; j++)
{
DropLitDynamiteAtStartPosition(playerPos + planeFlightDirection * (float)i * AirstrikeDropDistance + val * ((float)j - num) * AirstrikeDropDistanceSideways);
}
}
}
private static void DisableShadowsOnGameObject(GameObject obj)
{
Renderer[] componentsInChildren = obj.GetComponentsInChildren<Renderer>();
for (int i = 0; i < componentsInChildren.Length; i++)
{
componentsInChildren[i].shadowCastingMode = (ShadowCastingMode)0;
}
}
private void DropLitDynamiteAtStartPosition(Vector3 pos)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
SpawnQueue.Enqueue(delegate
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
//IL_007a: Unknown result type (might be due to invalid IL or missing references)
//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
//IL_00da: Unknown result type (might be due to invalid IL or missing references)
GameObject val = PhotonNetwork.InstantiateItemRoom("Dynamite", pos, Quaternion.Euler(Vector3.up));
DisableShadowsOnGameObject(val);
Item component = val.GetComponent<Item>();
Dynamite componentInParent = ((Component)component).GetComponentInParent<Dynamite>();
componentInParent.startingFuseTime = AirstrikeFuseDuration;
GlobalEvents.TriggerItemThrown(component);
ForceSyncForFrames(component);
Rigidbody component2 = val.GetComponent<Rigidbody>();
component2.isKinematic = false;
component2.angularVelocity = Vector3.up * 15f;
component2.AddForce(Vector3.down * 5f);
val.GetComponent<PhotonView>().RPC("SetItemInstanceDataRPC", (RpcTarget)0, new object[1] { component.data });
val.GetComponent<PhotonView>().RPC("SetKinematicRPC", (RpcTarget)3, new object[3]
{
false,
((Component)component).transform.position,
((Component)component).transform.rotation
});
componentInParent.LightFlare();
});
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "RandomAirstrikes";
public const string PLUGIN_NAME = "RandomAirstrikes";
public const string PLUGIN_VERSION = "1.0.11";
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}