Decompiled source of LethalAnomalies v0.1.2

Zeldahu.LethalAnomalies.dll

Decompiled 3 hours ago
#define DEBUG
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
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 DigitalRuby.ThunderAndLightning;
using HarmonyLib;
using LethalAnomalies.Configuration;
using LethalAnomalies.External;
using LethalLib.Modules;
using Microsoft.CodeAnalysis;
using Unity.Netcode;
using UnityEngine;
using Zeldahu.LethalAnomalies.NetcodePatcher;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: AssemblyCompany("Zeldahu.LethalAnomalies")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+0864a05544691c96bb0f101813317f1ce77b7629")]
[assembly: AssemblyProduct("LethalAnomalies")]
[assembly: AssemblyTitle("Zeldahu.LethalAnomalies")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: NetcodePatchedAssembly]
internal class <Module>
{
	static <Module>()
	{
	}
}
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 LethalAnomalies
{
	internal class SparkTowerAI : EnemyAI
	{
		private enum State
		{
			DetectingPlayers,
			AttackAndCooldown
		}

		public Transform turnCompass = null;

		public Transform attackArea = null;

		private float detectionValue = 0f;

		private int detectedPlayersAmount = 0;

		private int isWarningSoundReady = 0;

		private bool isAlreadyAttacking = false;

		public AudioSource attackAudio = null;

		public AudioSource attackAudioFar = null;

		public AudioSource warningAudio = null;

		private float effectiveRange = Plugin.BoundConfig.SparkTowerEffectiveRange.Value;

		private float detectionThreshold = Plugin.BoundConfig.SparkTowerDetectionThreshold.Value;

		private float cooldownMutiplier = Plugin.BoundConfig.SparkTowerCooldownMultiplier.Value;

		[Conditional("DEBUG")]
		public void LogIfDebugBuild(string text)
		{
			Plugin.Logger.LogInfo((object)text);
		}

		public override void Start()
		{
			((EnemyAI)this).Start();
			warningAudio.maxDistance = effectiveRange + 10f;
			((EnemyAI)this).SwitchToBehaviourClientRpc(0);
		}

		public override void DoAIInterval()
		{
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Invalid comparison between Unknown and I4
			((EnemyAI)this).DoAIInterval();
			if (base.isEnemyDead || StartOfRound.Instance.allPlayersDead)
			{
				return;
			}
			switch (base.currentBehaviourStateIndex)
			{
			case 0:
			{
				float num = 0f;
				detectedPlayersAmount = 0;
				isAlreadyAttacking = false;
				for (int i = 0; i < StartOfRound.Instance.connectedPlayersAmount + 1; i++)
				{
					num = Vector3.Distance(((Component)base.eye).transform.position, ((Component)StartOfRound.Instance.allPlayerScripts[i]).transform.position);
					if (((EnemyAI)this).PlayerIsTargetable(StartOfRound.Instance.allPlayerScripts[i], true, false) && !(num >= effectiveRange))
					{
						detectedPlayersAmount++;
						detectionValue += 0.05f;
						if ((int)TimeOfDay.Instance.currentLevelWeather == 2)
						{
							detectionValue += 0.05f;
						}
						if (!(num >= effectiveRange / 2f))
						{
							detectionValue += 0.05f;
						}
					}
				}
				if (detectedPlayersAmount > 0 && isWarningSoundReady == 0)
				{
					PlayWarningSoundClientRPC();
					isWarningSoundReady = 4;
				}
				if (detectedPlayersAmount == 0)
				{
					detectionValue = Mathf.Max(detectionValue - 0.1f, 0f);
					isWarningSoundReady = Mathf.Max(isWarningSoundReady - 1, 0);
				}
				if (detectionValue > detectionThreshold)
				{
					((EnemyAI)this).SwitchToBehaviourClientRpc(1);
				}
				break;
			}
			case 1:
				if (!isAlreadyAttacking)
				{
					isAlreadyAttacking = true;
					float attackCooldown = Random.Range(3f, 10f) * cooldownMutiplier;
					AttackClientRpc(attackCooldown);
				}
				break;
			default:
				LogIfDebugBuild("This Behavior State doesn't exist!");
				break;
			}
		}

		[ClientRpc]
		private void PlayWarningSoundClientRPC()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(3552027586u, val, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3552027586u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					warningAudio.Play();
				}
			}
		}

		[ClientRpc]
		private void AttackClientRpc(float attackCooldown)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2700346574u, val, (RpcDelivery)0);
					((FastBufferWriter)(ref val2)).WriteValueSafe<float>(ref attackCooldown, default(ForPrimitives));
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2700346574u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					((MonoBehaviour)this).StartCoroutine(AttackCoroutine(attackCooldown));
				}
			}
		}

		private IEnumerator AttackCoroutine(float attackCooldown)
		{
			base.creatureAnimator.Play("Attack");
			attackAudio.Play();
			attackAudioFar.Play();
			yield return (object)new WaitForSeconds(5f);
			List<Vector3> lightningpositions = new List<Vector3>();
			for (int i = 0; i < StartOfRound.Instance.connectedPlayersAmount + 1; i++)
			{
				if (((EnemyAI)this).PlayerIsTargetable(StartOfRound.Instance.allPlayerScripts[i], true, false) && Vector3.Distance(((Component)base.eye).transform.position, ((Component)StartOfRound.Instance.allPlayerScripts[i]).transform.position) <= effectiveRange)
				{
					lightningpositions.Add(((Component)StartOfRound.Instance.allPlayerScripts[i]).transform.position);
				}
			}
			yield return (object)new WaitForSeconds(0.63f);
			if (StartOfRound.Instance.inShipPhase)
			{
				yield break;
			}
			foreach (Vector3 position in lightningpositions)
			{
				ExternalScripts.SpawnLightningBolt(position, isLethal: true);
			}
			yield return (object)new WaitForSeconds(attackCooldown);
			detectionValue = 0f;
			isWarningSoundReady = 0;
			((EnemyAI)this).SwitchToBehaviourClientRpc(0);
		}

		protected override void __initializeVariables()
		{
			((EnemyAI)this).__initializeVariables();
		}

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_SparkTowerAI()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			NetworkManager.__rpc_func_table.Add(3552027586u, new RpcReceiveHandler(__rpc_handler_3552027586));
			NetworkManager.__rpc_func_table.Add(2700346574u, new RpcReceiveHandler(__rpc_handler_2700346574));
		}

		private static void __rpc_handler_3552027586(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0029: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((SparkTowerAI)(object)target).PlayWarningSoundClientRPC();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2700346574(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: 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_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				float attackCooldown = default(float);
				((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref attackCooldown, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((SparkTowerAI)(object)target).AttackClientRpc(attackCooldown);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		protected internal override string __getTypeName()
		{
			return "SparkTowerAI";
		}
	}
	[BepInPlugin("Zeldahu.LethalAnomalies", "LethalAnomalies", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		internal static ManualLogSource Logger;

		public static AssetBundle? ModAssets;

		private readonly Harmony harmony = new Harmony("Zeldahu.LethalAnomalies");

		internal static PluginConfig BoundConfig { get; private set; }

		private void Awake()
		{
			Logger = ((BaseUnityPlugin)this).Logger;
			BoundConfig = new PluginConfig(((BaseUnityPlugin)this).Config);
			InitializeNetworkBehaviours();
			string path = "lethalanomalies";
			ModAssets = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), path));
			if ((Object)(object)ModAssets == (Object)null)
			{
				Logger.LogError((object)"Failed to load custom assets.");
				return;
			}
			EnemyType val = ModAssets.LoadAsset<EnemyType>("Spark Tower");
			TerminalNode val2 = ModAssets.LoadAsset<TerminalNode>("SparkTowerTN");
			TerminalKeyword val3 = ModAssets.LoadAsset<TerminalKeyword>("SparkTowerTK");
			NetworkPrefabs.RegisterNetworkPrefab(val.enemyPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(val.nestSpawnPrefab);
			Enemies.RegisterEnemy(val, BoundConfig.SparkTowerSpawnWeight.Value, (LevelTypes)(-1), val2, val3);
			harmony.PatchAll();
			Logger.LogInfo((object)"Plugin Zeldahu.LethalAnomalies is loaded!");
		}

		private static void InitializeNetworkBehaviours()
		{
			Type[] types = Assembly.GetExecutingAssembly().GetTypes();
			Type[] array = types;
			foreach (Type type in array)
			{
				MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
				MethodInfo[] array2 = methods;
				foreach (MethodInfo methodInfo in array2)
				{
					object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false);
					if (customAttributes.Length != 0)
					{
						methodInfo.Invoke(null, null);
					}
				}
			}
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "Zeldahu.LethalAnomalies";

		public const string PLUGIN_NAME = "LethalAnomalies";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace LethalAnomalies.External
{
	internal class ExternalScripts
	{
		public static void SpawnLightningBolt(Vector3 strikePosition, bool isLethal)
		{
			//IL_0001: 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_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: 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_012f: Unknown result type (might be due to invalid IL or missing references)
			Vector3 zero = Vector3.zero;
			Random random = new Random(StartOfRound.Instance.randomMapSeed);
			float num = random.Next(-32, 32);
			float num2 = random.Next(-32, 32);
			zero = strikePosition + Vector3.up * 160f + new Vector3((float)random.Next(-32, 32), 0f, (float)random.Next(-32, 32));
			StormyWeather val = Object.FindObjectOfType<StormyWeather>(true);
			LightningBoltPrefabScript val2 = Object.Instantiate<LightningBoltPrefabScript>(val.targetedThunder);
			((Behaviour)val2).enabled = true;
			((LightningBoltScript)val2).Camera = GameNetworkManager.Instance.localPlayerController.gameplayCamera;
			((LightningBoltPrefabScriptBase)val2).AutomaticModeSeconds = 0.2f;
			val2.Source.transform.position = zero;
			val2.Destination.transform.position = strikePosition;
			((LightningBoltPrefabScriptBase)val2).CreateLightningBoltsNow();
			AudioSource val3 = Object.Instantiate<AudioSource>(val.targetedStrikeAudio);
			((Component)val3).transform.position = strikePosition + Vector3.up * 0.5f;
			((Behaviour)val3).enabled = true;
			val.PlayThunderEffects(strikePosition, val3);
			if (isLethal)
			{
				Landmine.SpawnExplosion(strikePosition + Vector3.up * 0.25f, false, 2.4f, 5f, 50, 0f, (GameObject)null, false);
			}
		}
	}
	[HarmonyPatch(typeof(Terminal))]
	internal class GetEnemies
	{
		public static SpawnableEnemyWithRarity Masked;

		public static SpawnableEnemyWithRarity HoardingBug;

		public static SpawnableEnemyWithRarity SnareFlea;

		public static SpawnableEnemyWithRarity Jester;

		public static SpawnableEnemyWithRarity Bracken;

		public static SpawnableEnemyWithRarity Thumper;

		public static SpawnableEnemyWithRarity CoilHead;

		public static SpawnableEnemyWithRarity CircuitBees;

		public static SpawnableEnemyWithRarity EarthLeviathan;

		public static SpawnableEnemyWithRarity BunkerSpider;

		public static SpawnableEnemyWithRarity ForestKeeper;

		public static SpawnableEnemyWithRarity GhostGirl;

		public static SpawnableEnemyWithRarity TulipSnake;

		public static SpawnableEnemyWithRarity EyelessDog;

		public static SpawnableEnemyWithRarity Maneater;

		public static SpawnableEnemyWithRarity Nutcracker;

		public static SpawnableEnemyWithRarity Barber;

		public static SpawnableEnemyWithRarity Butler;

		public static SpawnableEnemyWithRarity OldBird;

		public static SpawnableEnemyWithRarity ShyGuy;

		public static SpawnableEnemyWithRarity RedwoodTitan;

		public static SpawnableEnemyWithRarity RedwoodGiant;

		public static SpawnableEnemyWithRarity Locker;

		public static SpawnableEnemyWithRarity Bruce;

		public static SpawnableEnemyWithRarity SparkTower;

		public static SpawnableMapObject Landmine;

		public static SpawnableMapObject Turret;

		public static SpawnableMapObject SpikeTrap;

		public static SpawnableMapObject Seamine;

		public static SpawnableMapObject BigBertha;

		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		public static void GetEnemy(Terminal __instance)
		{
			SelectableLevel[] moonsCatalogueList = __instance.moonsCatalogueList;
			foreach (SelectableLevel val in moonsCatalogueList)
			{
				foreach (SpawnableEnemyWithRarity enemy in val.Enemies)
				{
					if (enemy.enemyType.enemyName == "Masked" && Masked == null)
					{
						Masked = enemy;
					}
					else if (enemy.enemyType.enemyName == "Hoarding bug" && HoardingBug == null)
					{
						HoardingBug = enemy;
					}
					else if (enemy.enemyType.enemyName == "Centipede" && SnareFlea == null)
					{
						SnareFlea = enemy;
					}
					else if (enemy.enemyType.enemyName == "Jester" && Jester == null)
					{
						Jester = enemy;
					}
					else if (enemy.enemyType.enemyName == "Flowerman" && Bracken == null)
					{
						Bracken = enemy;
					}
					else if (enemy.enemyType.enemyName == "Crawler" && Thumper == null)
					{
						Thumper = enemy;
					}
					else if (enemy.enemyType.enemyName == "Spring" && CoilHead == null)
					{
						CoilHead = enemy;
					}
					else if (enemy.enemyType.enemyName == "Bunker Spider" && BunkerSpider == null)
					{
						BunkerSpider = enemy;
					}
					else if (enemy.enemyType.enemyName == "Girl" && GhostGirl == null)
					{
						GhostGirl = enemy;
					}
					else if (enemy.enemyType.enemyName == "Maneater" && Maneater == null)
					{
						Maneater = enemy;
					}
					else if (enemy.enemyType.enemyName == "Nutcracker" && Nutcracker == null)
					{
						Nutcracker = enemy;
					}
					else if (enemy.enemyType.enemyName == "Clay Surgeon" && Barber == null)
					{
						Barber = enemy;
					}
					else if (enemy.enemyType.enemyName == "Butler" && Butler == null)
					{
						Butler = enemy;
					}
					else if (enemy.enemyType.enemyName == "Shy guy" && ShyGuy == null)
					{
						ShyGuy = enemy;
					}
					else if (enemy.enemyType.enemyName == "Locker" && Locker == null)
					{
						Locker = enemy;
					}
				}
				foreach (SpawnableEnemyWithRarity daytimeEnemy in val.DaytimeEnemies)
				{
					if (daytimeEnemy.enemyType.enemyName == "Red Locust Bees" && CircuitBees == null)
					{
						CircuitBees = daytimeEnemy;
					}
					else if (daytimeEnemy.enemyType.enemyName == "Tulip Snake" && TulipSnake == null)
					{
						TulipSnake = daytimeEnemy;
					}
				}
				foreach (SpawnableEnemyWithRarity outsideEnemy in val.OutsideEnemies)
				{
					if (outsideEnemy.enemyType.enemyName == "Earth Leviathan" && EarthLeviathan == null)
					{
						EarthLeviathan = outsideEnemy;
					}
					else if (outsideEnemy.enemyType.enemyName == "ForestGiant" && ForestKeeper == null)
					{
						ForestKeeper = outsideEnemy;
					}
					else if (outsideEnemy.enemyType.enemyName == "MouthDog" && EyelessDog == null)
					{
						EyelessDog = outsideEnemy;
					}
					else if (outsideEnemy.enemyType.enemyName == "RadMech" && OldBird == null)
					{
						OldBird = outsideEnemy;
					}
					else if (outsideEnemy.enemyType.enemyName == "Redwood Titan" && RedwoodTitan == null)
					{
						RedwoodTitan = outsideEnemy;
					}
					else if (outsideEnemy.enemyType.enemyName == "RedWoodGiant" && RedwoodGiant == null)
					{
						RedwoodGiant = outsideEnemy;
					}
					else if (outsideEnemy.enemyType.enemyName == "Bruce" && Bruce == null)
					{
						Bruce = outsideEnemy;
					}
					else if (outsideEnemy.enemyType.enemyName == "SparkTower" && SparkTower == null)
					{
						SparkTower = outsideEnemy;
					}
				}
				SpawnableMapObject[] spawnableMapObjects = val.spawnableMapObjects;
				foreach (SpawnableMapObject val2 in spawnableMapObjects)
				{
					if (((Object)val2.prefabToSpawn).name == "Landmine" && Landmine == null)
					{
						Landmine = val2;
					}
					else if (((Object)val2.prefabToSpawn).name == "TurretContainer" && Turret == null)
					{
						Turret = val2;
					}
					else if (((Object)val2.prefabToSpawn).name == "SpikeRoofTrapHazard" && SpikeTrap == null)
					{
						SpikeTrap = val2;
					}
					else if (((Object)val2.prefabToSpawn).name == "Seamine" && Seamine == null)
					{
						Seamine = val2;
					}
					else if (((Object)val2.prefabToSpawn).name == "Bertha" && BigBertha == null)
					{
						BigBertha = val2;
					}
				}
			}
		}
	}
	[HarmonyPatch(typeof(StartOfRound))]
	internal class StartOfRoundPatch
	{
		[HarmonyPostfix]
		[HarmonyPatch("OnShipLandedMiscEvents")]
		public static void OnShipLandedMiscEventsPatch(ref StartOfRound __instance)
		{
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			if (!((NetworkBehaviour)__instance).IsServer || GetEnemies.SparkTower == null)
			{
				return;
			}
			EnemyAINestSpawnObject[] array = Object.FindObjectsByType<EnemyAINestSpawnObject>((FindObjectsSortMode)0);
			for (int i = 0; i < array.Length; i++)
			{
				if ((Object)(object)array[i].enemyType == (Object)(object)GetEnemies.SparkTower.enemyType)
				{
					RoundManager.Instance.SpawnEnemyGameObject(RoundManager.Instance.outsideAINodes[0].transform.position, 0f, -1, GetEnemies.SparkTower.enemyType);
				}
			}
		}
	}
}
namespace LethalAnomalies.Configuration
{
	public class PluginConfig
	{
		public ConfigEntry<int> SparkTowerSpawnWeight;

		public ConfigEntry<float> SparkTowerEffectiveRange;

		public ConfigEntry<float> SparkTowerDetectionThreshold;

		public ConfigEntry<float> SparkTowerCooldownMultiplier;

		public PluginConfig(ConfigFile cfg)
		{
			SparkTowerSpawnWeight = cfg.Bind<int>("Spark Tower", "Spawn weight", 50, "The spawn chance weight for the Spark Tower, relative to other existing enemies.\nGoes up from 0, lower is more rare, 100 and up is very common.");
			SparkTowerEffectiveRange = cfg.Bind<float>("Spark Tower", "Effective Range", 30f, "The range at which the tower detects and attacks enemies");
			SparkTowerDetectionThreshold = cfg.Bind<float>("Spark Tower", "Attack speed", 2f, "Determines how long it takes for the tower to attack players while they stand in its detection range.\nLower values make the tower attack faster, higher values require players to stand close for longer before being attacked");
			SparkTowerCooldownMultiplier = cfg.Bind<float>("Spark Tower", "Cooldown multiplier", 1f, "Modifies how long the tower takes after attacking, before detecting players again \nThe normal cooldown value is randomly chosen between 3-10 seconds.");
			ClearUnusedEntries(cfg);
		}

		private void ClearUnusedEntries(ConfigFile cfg)
		{
			PropertyInfo property = ((object)cfg).GetType().GetProperty("OrphanedEntries", BindingFlags.Instance | BindingFlags.NonPublic);
			Dictionary<ConfigDefinition, string> dictionary = (Dictionary<ConfigDefinition, string>)property.GetValue(cfg, null);
			dictionary.Clear();
			cfg.Save();
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}
namespace Zeldahu.LethalAnomalies.NetcodePatcher
{
	[AttributeUsage(AttributeTargets.Module)]
	internal class NetcodePatchedAssemblyAttribute : Attribute
	{
	}
}