Decompiled source of DK Brutalizer v1.0.0

DK_Brutalizer.dll

Decompiled 3 weeks ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using DK_LethalMod;
using DK_LethalMod.Events;
using DK_LethalMod.Objects;
using DK_LethalMod.Patches;
using GameNetcodeStuff;
using HarmonyLib;
using LethalConfig.ConfigItems;
using Microsoft.CodeAnalysis;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.AI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("DK_LethalMod")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("DK_LethalMod")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("a0bf24d0-862f-4bc6-87d7-9452a7f63997")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: NeutralResourcesLanguage("en")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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;
		}
	}
}
public class Logger
{
	private static readonly string logFilePath;

	private static readonly string FileName;

	private const long MaxFileSize = 524288000L;

	static Logger()
	{
		FileName = "DK_Logs.txt";
		try
		{
			logFilePath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), FileName);
			if (!File.Exists(logFilePath))
			{
				File.Create(logFilePath).Dispose();
			}
		}
		catch (Exception ex)
		{
			Variables.mls.LogError((object)("Error in Logger static constructor: " + ex.Message));
		}
	}

	public static void Log(string message)
	{
		try
		{
			if (new FileInfo(logFilePath).Length > 524288000)
			{
				File.WriteAllText(logFilePath, "");
			}
			using StreamWriter streamWriter = File.AppendText(logFilePath);
			streamWriter.WriteLine($"{DateTime.Now}: {message}\n");
		}
		catch (Exception ex)
		{
			Variables.mls.LogError((object)("--------- Error in logging: " + ex.Message + " ---------"));
		}
	}

	public static void Close()
	{
		Log("---End of Session---");
	}

	public static void Start()
	{
		Log("---Start of Session---");
	}
}
namespace DK_LethalMod
{
	public class Config
	{
		public ConfigEntry<bool> UseLethalConfigListener;

		public ConfigEntry<bool> MoreEntities;

		public ConfigEntry<bool> EnableFreeMoney;

		public ConfigEntry<int> FreeMoneyValue;

		public ConfigEntry<bool> VanillaRaritySettings;

		public ConfigEntry<bool> VerboseInGame;

		public ConfigEntry<int> DeadlineDaysAmount;

		public Config(ConfigFile cfg)
		{
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Expected O, but got Unknown
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Expected O, but got Unknown
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Expected O, but got Unknown
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Expected O, but got Unknown
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Expected O, but got Unknown
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Expected O, but got Unknown
			UseLethalConfigListener = cfg.Bind<bool>("Lethal Config", "Use Listener", false, "If you use Lethal Config settings this to true will try to load the changes made.");
			MoreEntities = cfg.Bind<bool>("Level", "Allow More Entities", true, new ConfigDescription("If set to true allows more entities to spawn on maps.", (AcceptableValueBase)null, Array.Empty<object>()));
			EnableFreeMoney = cfg.Bind<bool>("Level", "Enable Free Money", true, new ConfigDescription("Should the players receive free money at the end of each successful round?", (AcceptableValueBase)null, Array.Empty<object>()));
			FreeMoneyValue = cfg.Bind<int>("Level", "Free Money Value", 150, new ConfigDescription("The amount of money the players get on a successful round.", (AcceptableValueBase)new AcceptableValueRange<int>(0, 2000), Array.Empty<object>()));
			VanillaRaritySettings = cfg.Bind<bool>("Lobby", "Brutalizer Uses Vanilla rarity", false, new ConfigDescription("If true Brutalizer will use the games default values instead of heavier weights.", (AcceptableValueBase)null, Array.Empty<object>()));
			VerboseInGame = cfg.Bind<bool>("Lobby", "Display Messages in game?", true, new ConfigDescription("If True displays messages in the chat lobby about simple events.", (AcceptableValueBase)null, Array.Empty<object>()));
			DeadlineDaysAmount = cfg.Bind<int>("Lobby", "DeadlineDaysAmount", 3, "Days available before deadline");
		}
	}
	internal class Methods
	{
		public static void CreateBrutalizer()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Expected O, but got Unknown
			try
			{
				GameObject val = new GameObject("Brutalizer");
				val.SetActive(true);
				((Behaviour)val.AddComponent<Brutalizer>()).enabled = true;
				Object.DontDestroyOnLoad((Object)(object)val);
				Variables.brutalizer = val.GetComponent<Brutalizer>();
				Variables.loaded = true;
			}
			catch (Exception ex)
			{
				Variables.mls.LogInfo((object)("Exception in CreateBrutalizer: " + ex.Message));
			}
		}

		private static Dictionary<string, string> ParseConfigRarities(string configValue)
		{
			return (from part in configValue.Split(new char[1] { ',' })
				select part.Split(new char[1] { ':' }) into parts
				where parts.Length == 2
				select parts).ToDictionary((string[] parts) => parts[0].Trim(), (string[] parts) => parts[1].Trim());
		}

		public static GameObject FindEnemyPrefabByType(Type enemyType, List<SpawnableEnemyWithRarity> enemyList, SelectableLevel newLevel)
		{
			foreach (SpawnableEnemyWithRarity enemy in enemyList)
			{
				if ((Object)(object)enemy.enemyType.enemyPrefab.GetComponent(enemyType) != (Object)null)
				{
					return enemy.enemyType.enemyPrefab;
				}
			}
			AddSpecificEnemiesForEvent(newLevel, new List<Type>(1) { enemyType });
			foreach (SpawnableEnemyWithRarity enemy2 in newLevel.Enemies)
			{
				if ((Object)(object)enemy2.enemyType.enemyPrefab.GetComponent(enemyType) != (Object)null)
				{
					return enemy2.enemyType.enemyPrefab;
				}
			}
			throw new Exception("Enemy type " + enemyType.Name + " not found and could not be added.");
		}

		public static void AddSpecificEnemiesForEvent(SelectableLevel newLevel, List<Type> enemyAITypes)
		{
			SelectableLevel[] levels = StartOfRound.Instance.levels;
			for (int i = 0; i < levels.Length; i++)
			{
				foreach (SpawnableEnemyWithRarity enemy in levels[i].Enemies)
				{
					GameObject enemyPrefab = enemy.enemyType.enemyPrefab;
					foreach (Type enemyAIType in enemyAITypes)
					{
						if ((Object)(object)enemyPrefab.GetComponent(enemyAIType) != (Object)null && !newLevel.Enemies.Any((SpawnableEnemyWithRarity e) => (Object)(object)e.enemyType.enemyPrefab == (Object)(object)enemyPrefab))
						{
							newLevel.Enemies.Add(enemy);
							Variables.mls.LogInfo((object)("Added specific Enemy: > " + ((Object)enemy.enemyType.enemyPrefab).name + " < for event"));
						}
					}
				}
			}
		}

		public static void ModifyEnemySpawnChances(SelectableLevel newLevel)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: 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_002f: 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_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Expected O, but got Unknown
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: 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_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Expected O, but got Unknown
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Expected O, but got Unknown
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: 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_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Expected O, but got Unknown
			newLevel.enemySpawnChanceThroughoutDay = new AnimationCurve((Keyframe[])(object)new Keyframe[3]
			{
				new Keyframe(0f, 0.1f),
				new Keyframe(0.5f, 10f),
				new Keyframe(1f, 70f)
			});
			newLevel.outsideEnemySpawnChanceThroughDay = new AnimationCurve((Keyframe[])(object)new Keyframe[3]
			{
				new Keyframe(0f, -30f),
				new Keyframe(20f, -20f),
				new Keyframe(21f, 10f)
			});
			if (Variables.isBadDay)
			{
				newLevel.outsideEnemySpawnChanceThroughDay = new AnimationCurve((Keyframe[])(object)new Keyframe[2]
				{
					new Keyframe(0f, 999f),
					new Keyframe(21f, 999f)
				});
				newLevel.enemySpawnChanceThroughoutDay = new AnimationCurve((Keyframe[])(object)new Keyframe[2]
				{
					new Keyframe(0f, 500f),
					new Keyframe(0.5f, 500f)
				});
				Variables.isBadDay = false;
			}
		}

		public static void UpdateAIInNewLevel(SelectableLevel newLevel)
		{
			foreach (SpawnableEnemyWithRarity enemy in newLevel.Enemies)
			{
				GameObject enemyPrefab = enemy.enemyType.enemyPrefab;
				foreach (Type item in Variables.aiPresence.Keys.ToList())
				{
					if ((Object)(object)enemyPrefab.GetComponent(item) != (Object)null)
					{
						Variables.aiPresence[item] = true;
					}
				}
			}
		}

		public static void AddMissingAIToNewLevel(SelectableLevel newLevel)
		{
			SelectableLevel[] levels = StartOfRound.Instance.levels;
			for (int i = 0; i < levels.Length; i++)
			{
				foreach (SpawnableEnemyWithRarity enemy in levels[i].Enemies)
				{
					GameObject enemyPrefab = enemy.enemyType.enemyPrefab;
					foreach (Type item in Variables.aiPresence.Keys.ToList())
					{
						if ((Object)(object)enemyPrefab.GetComponent(item) != (Object)null && !Variables.aiPresence[item] && item != typeof(PumaAI))
						{
							Variables.aiPresence[item] = true;
							newLevel.Enemies.Add(enemy);
							Variables.mls.LogWarning((object)("\n\nAdded Enemy: > " + ((Object)enemy.enemyType.enemyPrefab).name + " < to the Enemy list\n\n"));
						}
					}
				}
				foreach (SpawnableEnemyWithRarity outsideEnemy in levels[i].OutsideEnemies)
				{
					GameObject enemyPrefab2 = outsideEnemy.enemyType.enemyPrefab;
					foreach (Type item2 in Variables.aiPresence.Keys.ToList())
					{
						if ((Object)(object)enemyPrefab2.GetComponent(item2) != (Object)null && !Variables.aiPresence[item2] && item2 != typeof(PumaAI))
						{
							Variables.aiPresence[item2] = true;
							newLevel.Enemies.Add(outsideEnemy);
							Variables.mls.LogWarning((object)("\n\nAdded Enemy: > " + ((Object)outsideEnemy.enemyType.enemyPrefab).name + " < to the Enemy list\n\n"));
						}
					}
				}
				foreach (SpawnableEnemyWithRarity daytimeEnemy in levels[i].DaytimeEnemies)
				{
					GameObject enemyPrefab3 = daytimeEnemy.enemyType.enemyPrefab;
					foreach (Type item3 in Variables.aiPresence.Keys.ToList())
					{
						if ((Object)(object)enemyPrefab3.GetComponent(item3) != (Object)null && !Variables.aiPresence[item3] && item3 != typeof(PumaAI))
						{
							Variables.aiPresence[item3] = true;
							newLevel.Enemies.Add(daytimeEnemy);
							Variables.mls.LogWarning((object)("\n\nAdded Enemy: > " + ((Object)daytimeEnemy.enemyType.enemyPrefab).name + " < to the Enemy list\n\n"));
						}
					}
				}
			}
		}

		public static void LogMissingAI(SelectableLevel newLevel)
		{
			foreach (Type item in Variables.aiPresence.Keys.ToList())
			{
				if (!Variables.aiPresence[item])
				{
					Logger.Log(newLevel.sceneName + " Missing AI: " + item.ToString());
				}
			}
		}

		public static void InitializeLevelHeatValues(SelectableLevel newLevel)
		{
			if (!Variables.levelHeatVal.ContainsKey(newLevel))
			{
				Variables.levelHeatVal.Add(newLevel, 0f);
			}
			if (!Variables.levelEnemySpawns.ContainsKey(newLevel))
			{
				List<SpawnableEnemyWithRarity> value = newLevel.Enemies.ToList();
				Variables.levelEnemySpawns.Add(newLevel, value);
			}
		}

		public static void LogEnemyInformation(SelectableLevel newLevel)
		{
			Variables.mls.LogWarning((object)"Map Objects");
			SpawnableMapObject[] spawnableMapObjects = newLevel.spawnableMapObjects;
			SpawnableMapObject[] array = spawnableMapObjects;
			foreach (SpawnableMapObject val in array)
			{
				Variables.mls.LogInfo((object)((object)val.prefabToSpawn).ToString());
			}
			Variables.mls.LogWarning((object)"Enemies");
			foreach (SpawnableEnemyWithRarity enemy in newLevel.Enemies)
			{
				Variables.mls.LogInfo((object)(enemy.enemyType.enemyName + "--rarity = " + enemy.rarity));
			}
		}

		public static void SpawnMultipleEnemies(List<Variables.EnemySpawnInfo> enemiesToSpawn)
		{
			foreach (Variables.EnemySpawnInfo item in enemiesToSpawn)
			{
				for (int i = 0; i < item.Amount; i++)
				{
					switch (item.Location)
					{
					case Variables.SpawnLocation.Outside:
						SpawnEnemyOutside(item.EnemyType, item.ForceOutside);
						break;
					case Variables.SpawnLocation.Vent:
						SpawnEnemyFromVent(item.EnemyType, item.ForceInside);
						break;
					}
				}
			}
		}

		public static EnemyAI SpawnEnemyFromVent(Type enemyType, bool ForceInside)
		{
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = ((!ForceInside) ? FindEnemyPrefabByType(enemyType, RoundManager.Instance.currentLevel.Enemies, Variables.CurrentLevel) : FindEnemyPrefabByType(enemyType, RoundManager.Instance.currentLevel.OutsideEnemies, Variables.CurrentLevel));
			int num = Random.Range(0, RoundManager.Instance.allEnemyVents.Length);
			Vector3 position = RoundManager.Instance.allEnemyVents[num].floorNode.position;
			Quaternion val2 = Quaternion.Euler(0f, RoundManager.Instance.allEnemyVents[num].floorNode.eulerAngles.y, 0f);
			GameObject val3 = Object.Instantiate<GameObject>(val, position, val2);
			val3.GetComponentInChildren<NetworkObject>().Spawn(true);
			EnemyAI component = val3.GetComponent<EnemyAI>();
			if (ForceInside)
			{
				component.enemyType.isOutsideEnemy = false;
				component.allAINodes = GameObject.FindGameObjectsWithTag("AINode");
				component.SyncPositionToClients();
			}
			RoundManager.Instance.SpawnedEnemies.Add(component);
			return component;
		}

		public static EnemyAI SpawnEnemyOutside(Type enemyType, bool ForceOutside)
		{
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: 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)
			GameObject val = ((!ForceOutside) ? FindEnemyPrefabByType(enemyType, RoundManager.Instance.currentLevel.OutsideEnemies, Variables.CurrentLevel) : FindEnemyPrefabByType(enemyType, RoundManager.Instance.currentLevel.Enemies, Variables.CurrentLevel));
			GameObject[] array = GameObject.FindGameObjectsWithTag("OutsideAINode");
			Vector3 position = array[Random.Range(0, array.Length)].transform.position;
			GameObject val2 = Object.Instantiate<GameObject>(val, position, Quaternion.identity);
			val2.GetComponentInChildren<NetworkObject>().Spawn(true);
			EnemyAI component = val2.GetComponent<EnemyAI>();
			if (ForceOutside)
			{
				component.enemyType.isOutsideEnemy = true;
				component.allAINodes = GameObject.FindGameObjectsWithTag("OutsideAINode");
				component.SyncPositionToClients();
			}
			RoundManager.Instance.SpawnedEnemies.Add(component);
			return component;
		}

		public static void EnterLunge(MouthDogAI __instance, Ray ray, RaycastHit rayHit, RoundManager roundManager)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: 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_0052: 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_0067: 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_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: 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)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			((EnemyAI)__instance).SwitchToBehaviourState(3);
			__instance.endingLunge = false;
			((Ray)(ref ray))..ctor(((Component)__instance).transform.position + Vector3.up, ((Component)__instance).transform.forward);
			Vector3 val = ((!Physics.Raycast(ray, ref rayHit, 17f, StartOfRound.Instance.collidersAndRoomMask)) ? ((Ray)(ref ray)).GetPoint(17f) : ((RaycastHit)(ref rayHit)).point);
			val = roundManager.GetNavMeshPosition(val, default(NavMeshHit), 5f, -1);
			((EnemyAI)__instance).SetDestinationToPosition(val, false);
			((EnemyAI)__instance).agent.speed = 13f;
		}

		public static Vector3 GetNearbyLocation(Vector3 baseLocation)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			float num = 10f;
			Vector3 val = Random.insideUnitSphere * num;
			return baseLocation + val;
		}

		public static void OpenDoors()
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			DoorLock[] array = Object.FindObjectsOfType<DoorLock>();
			DoorLock[] array2 = array;
			foreach (DoorLock val in array2)
			{
				Collider[] array3 = Physics.OverlapSphere(((Component)val).transform.position, 2f);
				bool flag = false;
				Collider[] array4 = array3;
				for (int j = 0; j < array4.Length; j++)
				{
					if (((Component)array4[j]).CompareTag("Enemy"))
					{
						flag = true;
						break;
					}
				}
				if (flag)
				{
					FieldInfo field = typeof(DoorLock).GetField("isDoorOpened", BindingFlags.Instance | BindingFlags.NonPublic);
					if (field == null)
					{
						break;
					}
					if (!val.isLocked && !(bool)field.GetValue(val))
					{
						val.OpenOrCloseDoor((PlayerControllerB)null);
					}
				}
			}
		}

		public static void CleanUpAllVariables()
		{
			Variables.DogForceOwnership = false;
			Variables.InsideOutOwnership = false;
			Variables.WaitUntilPlayerInside = false;
			Variables.SpawnInsideOut = false;
			Variables.Landed = false;
			Variables.SpawnedInsideOutID.Clear();
			Variables.presetEnemiesToSpawn.Clear();
			Variables.BrutalizerEnemiesToSpawn.Clear();
			Variables.DogsSpawnedInside.Clear();
			Variables.TheRumbling = false;
			Variables.BlobsHaveEvolved = false;
			Variables.HauntedElectronics = false;
			Variables.AllHauntedElectronics = null;
			foreach (Type item in Variables.aiPresence.Keys.ToList())
			{
				Variables.aiPresence[item] = false;
			}
			Variables.CurrentLevel.minScrap = Variables.minScrap;
			Variables.CurrentLevel.maxScrap = Variables.maxScrap;
			Variables.CurrentLevel.minTotalScrapValue = Variables.minScrapValue;
			Variables.CurrentLevel.maxTotalScrapValue = Variables.maxScrapValue;
		}

		public static void CleanupAndResetAI()
		{
			CleanUpAllVariables();
			CleanupAllSpawns();
		}

		public static void CleanupAllSpawns()
		{
			foreach (GameObject item in Variables.objectsToCleanUp)
			{
				if (item != null)
				{
					item.GetComponent<NetworkObject>().Despawn(true);
				}
			}
			Variables.objectsToCleanUp.Clear();
		}
	}
	[BepInPlugin("DarklordKnaag.Brutalizer", "DK Brutalizer", "1.0.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		private const string modGUID = "DarklordKnaag.Brutalizer";

		private const string modName = "DK Brutalizer";

		private const string modVersion = "1.0.0.0";

		private bool brutalizerInitialized = false;

		private bool allowUpdate = false;

		public static Plugin instance;

		private readonly Harmony harmony = new Harmony("DarklordKnaag.Brutalizer");

		private void Awake()
		{
			if ((Object)(object)instance == (Object)null)
			{
				instance = this;
			}
			Variables.mls = Logger.CreateLogSource("DarklordKnaag.Brutalizer");
			Variables.config = new Config(((BaseUnityPlugin)this).Config);
			harmony.PatchAll(typeof(Plugin));
			harmony.PatchAll(typeof(DeleteFileButton_Patch));
			InitializeVariables();
			harmony.PatchAll(typeof(EnemyAI_Patch));
			harmony.PatchAll(typeof(TerminalAccessibleObject_Patch));
			harmony.PatchAll(typeof(GameNetworkManager_Patch));
			harmony.PatchAll(typeof(RoundManager_Patch));
			harmony.PatchAll(typeof(TimeOfDay_Patch));
			if (Variables.config.UseLethalConfigListener.Value)
			{
				harmony.PatchAll(typeof(LethalConfig_Patch));
			}
			Variables.mls.LogInfo((object)"Base Awake :)");
			allowUpdate = true;
		}

		private void Start()
		{
			if (!brutalizerInitialized)
			{
				Methods.CreateBrutalizer();
				brutalizerInitialized = true;
			}
		}

		private void OnDestroy()
		{
			if (!brutalizerInitialized)
			{
				Methods.CreateBrutalizer();
				brutalizerInitialized = true;
			}
		}

		private void InitializeVariables()
		{
			Variables.levelHeatVal = new Dictionary<SelectableLevel, float>();
			Variables.enemyRarities = new Dictionary<SpawnableEnemyWithRarity, int>();
			Variables.levelEnemySpawns = new Dictionary<SelectableLevel, List<SpawnableEnemyWithRarity>>();
			Variables.enemyPropCurves = new Dictionary<SpawnableEnemyWithRarity, AnimationCurve>();
		}

		private void Update()
		{
			if (allowUpdate && Variables.config.UseLethalConfigListener.Value && Variables.reloadConfig > 0f)
			{
				Variables.reloadConfig -= Time.deltaTime;
				if (Variables.reloadConfig < 0f)
				{
					Variables.config = new Config(((BaseUnityPlugin)this).Config);
				}
			}
		}
	}
	public static class Variables
	{
		public class BrutalizerEnemySpawnInfo
		{
			public bool forceTimeStay = false;

			public int random;

			public float timeUntilActive;

			public EnemySpawnInfo enemySpawnInfo;

			public BrutalizerEnemySpawnInfo(EnemySpawnInfo enemy, float timer, bool forceTimerStay = false)
			{
				timeUntilActive = timer;
				enemySpawnInfo = enemy;
				forceTimeStay = forceTimerStay;
				random = Random.Range(int.MinValue, int.MaxValue);
			}
		}

		public struct EnemySpawnInfo
		{
			public Type EnemyType;

			public int Amount;

			public SpawnLocation Location;

			public bool ForceInside;

			public bool ForceOutside;

			public EnemySpawnInfo(Type enemyType, int amount, SpawnLocation location, bool forceInside, bool forceOutside)
			{
				EnemyType = enemyType;
				Amount = amount;
				Location = location;
				ForceInside = forceInside;
				ForceOutside = forceOutside;
			}
		}

		public enum SpawnLocation
		{
			Outside,
			Vent
		}

		public static ManualLogSource mls;

		public static Config config;

		public static float reloadConfig = -1f;

		public static bool loaded = false;

		public static Brutalizer brutalizer;

		public static SelectableLevel CurrentLevel;

		public static List<EnemySpawnInfo> presetEnemiesToSpawn = new List<EnemySpawnInfo>();

		public static List<BrutalizerEnemySpawnInfo> BrutalizerEnemiesToSpawn = new List<BrutalizerEnemySpawnInfo>();

		public static bool Landed = false;

		public static bool TakeOffExecuted = false;

		public static bool WaitUntilPlayerInside = false;

		public static HashSet<int> DogsSpawnedInside = new HashSet<int>();

		public static bool DogForceOwnership = false;

		public static bool InsideOutOwnership = false;

		public static bool HauntedElectronics = false;

		public static bool SpawnInsideOut = false;

		public static bool BlobsHaveEvolved = false;

		public static HashSet<int> SpawnedInsideOutID = new HashSet<int>();

		public static List<GameObject> objectsToCleanUp = new List<GameObject>();

		public static List<HauntedElectronics> AllHauntedElectronics;

		public static Dictionary<Type, bool> aiPresence = new Dictionary<Type, bool>
		{
			{
				typeof(BaboonBirdAI),
				false
			},
			{
				typeof(BlobAI),
				false
			},
			{
				typeof(BushWolfEnemy),
				false
			},
			{
				typeof(ButlerBeesEnemyAI),
				false
			},
			{
				typeof(ButlerEnemyAI),
				false
			},
			{
				typeof(CadaverBloomAI),
				false
			},
			{
				typeof(CadaverGrowthAI),
				false
			},
			{
				typeof(CaveDwellerAI),
				false
			},
			{
				typeof(CentipedeAI),
				false
			},
			{
				typeof(ClaySurgeonAI),
				false
			},
			{
				typeof(CrawlerAI),
				false
			},
			{
				typeof(DocileLocustBeesAI),
				false
			},
			{
				typeof(DoublewingAI),
				false
			},
			{
				typeof(DressGirlAI),
				false
			},
			{
				typeof(FlowermanAI),
				false
			},
			{
				typeof(FlowerSnakeEnemy),
				false
			},
			{
				typeof(ForestGiantAI),
				false
			},
			{
				typeof(GiantKiwiAI),
				false
			},
			{
				typeof(HoarderBugAI),
				false
			},
			{
				typeof(JesterAI),
				false
			},
			{
				typeof(LassoManAI),
				false
			},
			{
				typeof(MaskedPlayerEnemy),
				false
			},
			{
				typeof(MouthDogAI),
				false
			},
			{
				typeof(NutcrackerEnemyAI),
				false
			},
			{
				typeof(PufferAI),
				false
			},
			{
				typeof(PumaAI),
				false
			},
			{
				typeof(RedLocustBees),
				false
			},
			{
				typeof(SandSpiderAI),
				false
			},
			{
				typeof(SandWormAI),
				false
			},
			{
				typeof(SpringManAI),
				false
			},
			{
				typeof(StingrayAI),
				false
			}
		};

		public static List<string> correctEnemyNames = new List<string>(30)
		{
			"Centipede", "Bunker Spider", "Hoarding bug", "Flowerman", "Crawler", "Blob", "Girl", "Puffer", "Nutcracker", "Spring",
			"Jester", "Masked", "LassoMan", "Butler", "Clay Surgeon", "Maneater", "Stringray", "Cadaver Growths", "Mouthdog", "Earth Leviathan",
			"Baboon Hawk", "RadMech", "Bush Wolf", "GiantKiwi", "Feiopar", "Cadaver Bloom", "Red Locust Bees", "Docile Locust Bees", "Manticoil", "Tulip Snake"
		};

		public static Dictionary<SpawnableEnemyWithRarity, AnimationCurve> enemyPropCurves;

		public static Dictionary<SpawnableEnemyWithRarity, int> enemyRarities;

		public static Dictionary<string, Dictionary<string, int>> DefaultEnemyRarities = new Dictionary<string, Dictionary<string, int>>();

		public static bool isBadDay = false;

		public static bool TheRumbling = false;

		public static Dictionary<SelectableLevel, float> levelHeatVal;

		public static Dictionary<SelectableLevel, List<SpawnableEnemyWithRarity>> levelEnemySpawns;

		public static bool HideEventBlips = true;

		public static int minScrap;

		public static int maxScrap;

		public static int minScrapValue;

		public static int maxScrapValue;
	}
}
namespace DK_LethalMod.Patches
{
	internal class DeleteFileButton_Patch
	{
		[HarmonyPatch(typeof(DeleteFileButton), "DeleteFile")]
		[HarmonyPostfix]
		public static void ResetMoonHeatOnDeleteFile(DeleteFileButton __instance)
		{
			foreach (SelectableLevel item in Variables.levelHeatVal.Keys.ToList())
			{
				if (Variables.levelHeatVal.Count != 0)
				{
					Variables.levelHeatVal[item] = 0f;
				}
			}
		}
	}
	internal class EnemyAI_Patch
	{
		public static bool HoldState;

		[HarmonyPatch(typeof(BlobAI), "Update")]
		[HarmonyPostfix]
		public static void BlobModifications(BlobAI __instance)
		{
			if (((EnemyAI)__instance).isOutside && ((NetworkBehaviour)__instance).OwnerClientId != GameNetworkManager.Instance.localPlayerController.actualClientId)
			{
				((EnemyAI)__instance).ChangeOwnershipOfEnemy(GameNetworkManager.Instance.localPlayerController.actualClientId);
			}
			if (Variables.BlobsHaveEvolved && ((NetworkBehaviour)RoundManager.Instance).IsHost)
			{
				if (((NetworkBehaviour)__instance).OwnerClientId != GameNetworkManager.Instance.localPlayerController.actualClientId)
				{
					((EnemyAI)__instance).ChangeOwnershipOfEnemy(GameNetworkManager.Instance.localPlayerController.actualClientId);
					return;
				}
				((EnemyAI)__instance).agent.speed = 3.8f;
				Methods.OpenDoors();
			}
		}

		[HarmonyPatch(typeof(BlobAI), "OnCollideWithPlayer")]
		[HarmonyPostfix]
		public static void BlobAIOnCollideWithPlayerPatch(BlobAI __instance, ref Collider other)
		{
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			PlayerControllerB component = ((Component)other).gameObject.GetComponent<PlayerControllerB>();
			if (!((Object)(object)component != (Object)null) || component.isPlayerDead || !component.isPlayerControlled)
			{
				return;
			}
			Type typeFromHandle = typeof(BlobAI);
			FieldInfo field = typeFromHandle.GetField("timeSinceHittingLocalPlayer", BindingFlags.Instance | BindingFlags.NonPublic);
			FieldInfo field2 = typeFromHandle.GetField("tamedTimer", BindingFlags.Instance | BindingFlags.NonPublic);
			FieldInfo field3 = typeFromHandle.GetField("angeredTimer", BindingFlags.Instance | BindingFlags.NonPublic);
			if (!((float)field.GetValue(__instance) < 0.25f) && (!((float)field2.GetValue(__instance) > 0f) || !((float)field3.GetValue(__instance) < 0f)))
			{
				field.SetValue(__instance, 0);
				component.DamagePlayer(35, true, true, (CauseOfDeath)0, 0, false, default(Vector3));
				if (component.isPlayerDead)
				{
					__instance.SlimeKillPlayerEffectServerRpc((int)component.playerClientId);
				}
			}
		}

		[HarmonyPatch(typeof(FlowermanAI), "Update")]
		[HarmonyPostfix]
		public static void FlowerManModifications(FlowermanAI __instance)
		{
			if (((EnemyAI)__instance).isOutside && ((NetworkBehaviour)__instance).OwnerClientId != GameNetworkManager.Instance.localPlayerController.actualClientId)
			{
				((EnemyAI)__instance).ChangeOwnershipOfEnemy(GameNetworkManager.Instance.localPlayerController.actualClientId);
			}
		}

		[HarmonyPatch(typeof(FlowermanAI), "OnCollideWithPlayer")]
		[HarmonyPostfix]
		public static void FlowerManAIOnCollideWithPlayerPatch(FlowermanAI __instance, ref Collider other, bool ___startingKillAnimationLocalClient)
		{
			PlayerControllerB component = ((Component)other).gameObject.GetComponent<PlayerControllerB>();
			if ((Object)(object)component != (Object)null && !component.isPlayerDead && component.isPlayerControlled && !__instance.inKillAnimation && !((EnemyAI)__instance).isEnemyDead && !___startingKillAnimationLocalClient)
			{
				__instance.KillPlayerAnimationServerRpc((int)component.playerClientId);
				___startingKillAnimationLocalClient = true;
			}
		}

		[HarmonyPatch(typeof(HoarderBugAI), "Update")]
		[HarmonyPostfix]
		public static void HoarderBugModifications(HoarderBugAI __instance)
		{
			if (((EnemyAI)__instance).isOutside && ((NetworkBehaviour)__instance).OwnerClientId != GameNetworkManager.Instance.localPlayerController.actualClientId)
			{
				((EnemyAI)__instance).ChangeOwnershipOfEnemy(GameNetworkManager.Instance.localPlayerController.actualClientId);
			}
		}

		[HarmonyPatch(typeof(HoarderBugAI), "OnCollideWithPlayer")]
		[HarmonyPostfix]
		public static void HoarderBugAIOnCollideWithPlayerPatch(HoarderBugAI __instance, ref Collider other)
		{
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			PlayerControllerB component = ((Component)other).gameObject.GetComponent<PlayerControllerB>();
			if (!((Object)(object)component != (Object)null) || component.isPlayerDead || !component.isPlayerControlled)
			{
				return;
			}
			Type typeFromHandle = typeof(HoarderBugAI);
			FieldInfo field = typeFromHandle.GetField("timeSinceHittingPlayer", BindingFlags.Instance | BindingFlags.NonPublic);
			if ((bool)typeFromHandle.GetField("inChase", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__instance) && !((float)field.GetValue(__instance) < 0.5f))
			{
				field.SetValue(__instance, 0);
				component.DamagePlayer(30, true, true, (CauseOfDeath)6, 0, false, default(Vector3));
				if (component.isPlayerDead)
				{
					__instance.HitPlayerServerRpc();
				}
			}
		}

		[HarmonyPatch(typeof(JesterAI), "Update")]
		[HarmonyPostfix]
		public static void InsideOutJesterModifications(JesterAI __instance)
		{
			if (!((NetworkBehaviour)RoundManager.Instance).IsHost || !((EnemyAI)__instance).isOutside)
			{
				return;
			}
			if (((NetworkBehaviour)__instance).OwnerClientId != GameNetworkManager.Instance.localPlayerController.actualClientId)
			{
				((EnemyAI)__instance).ChangeOwnershipOfEnemy(GameNetworkManager.Instance.localPlayerController.actualClientId);
			}
			if (((EnemyAI)__instance).previousBehaviourStateIndex != 1 && !HoldState)
			{
				return;
			}
			((EnemyAI)__instance).SwitchToBehaviourState(2);
			((EnemyAI)__instance).agent.stoppingDistance = 0f;
			HoldState = true;
			bool flag = true;
			for (int i = 0; i < StartOfRound.Instance.allPlayerScripts.Length; i++)
			{
				if (!StartOfRound.Instance.allPlayerScripts[i].isInsideFactory && StartOfRound.Instance.allPlayerScripts[i].isPlayerControlled)
				{
					flag = false;
					break;
				}
			}
			if (flag || StartOfRound.Instance.shipIsLeaving)
			{
				((EnemyAI)__instance).previousBehaviourStateIndex = 0;
				((EnemyAI)__instance).agent.stoppingDistance = 4f;
				((EnemyAI)__instance).SwitchToBehaviourState(0);
				HoldState = false;
			}
		}

		[HarmonyPatch(typeof(JesterAI), "OnCollideWithPlayer")]
		[HarmonyPostfix]
		public static void JesterAIOnCollideWithPlayerPatch(JesterAI __instance, ref Collider other, bool ___inKillAnimation)
		{
			PlayerControllerB component = ((Component)other).gameObject.GetComponent<PlayerControllerB>();
			if ((Object)(object)component != (Object)null && !component.isPlayerDead && component.isPlayerControlled && !___inKillAnimation && !((EnemyAI)__instance).isEnemyDead && ((EnemyAI)__instance).currentBehaviourStateIndex == 2)
			{
				__instance.KillPlayerServerRpc((int)component.playerClientId);
				___inKillAnimation = true;
			}
		}

		[HarmonyPatch(typeof(SpringManAI), "Update")]
		[HarmonyPostfix]
		public static void InsideOutSpringManModifications(SpringManAI __instance)
		{
			if (((EnemyAI)__instance).isOutside && ((NetworkBehaviour)__instance).OwnerClientId != GameNetworkManager.Instance.localPlayerController.actualClientId)
			{
				((EnemyAI)__instance).ChangeOwnershipOfEnemy(GameNetworkManager.Instance.localPlayerController.actualClientId);
			}
		}

		[HarmonyPatch(typeof(MouthDogAI), "Update")]
		[HarmonyPostfix]
		public static void InsideMouthDogModifications(MouthDogAI __instance)
		{
			if (Variables.DogForceOwnership && ((NetworkBehaviour)RoundManager.Instance).IsHost && ((NetworkBehaviour)__instance).OwnerClientId != GameNetworkManager.Instance.localPlayerController.actualClientId)
			{
				((EnemyAI)__instance).ChangeOwnershipOfEnemy(GameNetworkManager.Instance.localPlayerController.actualClientId);
			}
		}

		[HarmonyPatch(typeof(MouthDogAI), "OnCollideWithPlayer")]
		[HarmonyPrefix]
		public static bool MouthDogAIOnCollideWithPlayerPatch(MouthDogAI __instance, ref Collider other, bool ___inKillAnimation, Collider ___debugCollider, bool ___inLunge, Ray ___ray, RaycastHit ___rayHit, RoundManager ___roundManager)
		{
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: 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_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: 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)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
			if (Variables.DogForceOwnership && ((NetworkBehaviour)RoundManager.Instance).IsHost)
			{
				PlayerControllerB component = ((Component)other).gameObject.GetComponent<PlayerControllerB>();
				if ((Object)(object)component != (Object)null && !component.isPlayerDead && component.isPlayerControlled && !___inKillAnimation)
				{
					Vector3 val = Vector3.Normalize((((Component)__instance).transform.position + Vector3.up - ((Component)component.gameplayCamera).transform.position) * 100f);
					RaycastHit val2 = default(RaycastHit);
					if (Physics.Linecast(((Component)__instance).transform.position + Vector3.up + val * 0.5f, ((Component)component.gameplayCamera).transform.position, ref val2, StartOfRound.Instance.collidersAndRoomMask, (QueryTriggerInteraction)1))
					{
						if ((Object)(object)((RaycastHit)(ref val2)).collider == (Object)(object)___debugCollider)
						{
							return false;
						}
						___debugCollider = ((RaycastHit)(ref val2)).collider;
						return false;
					}
					if (((EnemyAI)__instance).currentBehaviourStateIndex == 3)
					{
						component.inAnimationWithEnemy = (EnemyAI)(object)__instance;
						__instance.KillPlayerServerRpc((int)component.playerClientId);
						return false;
					}
					if (((EnemyAI)__instance).currentBehaviourStateIndex == 0 || ((EnemyAI)__instance).currentBehaviourStateIndex == 1)
					{
						((EnemyAI)__instance).SwitchToBehaviourState(2);
						((EnemyAI)__instance).SetDestinationToPosition(((Component)component).transform.position, false);
						return false;
					}
					if (((EnemyAI)__instance).currentBehaviourStateIndex == 2 && !___inLunge)
					{
						((Component)__instance).transform.LookAt(((Component)other).transform.position);
						((Component)__instance).transform.localEulerAngles = new Vector3(0f, ((Component)__instance).transform.eulerAngles.y, 0f);
						___inLunge = true;
						Methods.EnterLunge(__instance, ___ray, ___rayHit, ___roundManager);
						return false;
					}
				}
			}
			return true;
		}

		[HarmonyPatch(typeof(ForestGiantAI), "Update")]
		[HarmonyPostfix]
		public static void RumblingForestGiantModifications(ForestGiantAI __instance, bool ___inEatingPlayerAnimation)
		{
			if (Variables.TheRumbling && ((NetworkBehaviour)RoundManager.Instance).IsHost)
			{
				if (((NetworkBehaviour)__instance).OwnerClientId != GameNetworkManager.Instance.localPlayerController.actualClientId && ((EnemyAI)__instance).currentBehaviourStateIndex < 2)
				{
					((EnemyAI)__instance).ChangeOwnershipOfEnemy(GameNetworkManager.Instance.localPlayerController.actualClientId);
				}
				else if (((EnemyAI)__instance).currentBehaviourStateIndex == 1 && !___inEatingPlayerAnimation)
				{
					((EnemyAI)__instance).agent.speed = 6f;
				}
			}
		}

		[HarmonyPatch(typeof(ButlerEnemyAI), "Update")]
		[HarmonyPostfix]
		public static void InsideOutButlerModifications(ButlerEnemyAI __instance)
		{
			if (((EnemyAI)__instance).isOutside && ((NetworkBehaviour)__instance).OwnerClientId != GameNetworkManager.Instance.localPlayerController.actualClientId)
			{
				((EnemyAI)__instance).ChangeOwnershipOfEnemy(GameNetworkManager.Instance.localPlayerController.actualClientId);
			}
		}

		[HarmonyPatch(typeof(EnemyAI), "StartSearch")]
		[HarmonyPrefix]
		public static bool InsideOutStartSearchModification(EnemyAI __instance, ref Vector3 startOfSearch, AISearchRoutine newSearch)
		{
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: 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_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			if (Variables.InsideOutOwnership && ((NetworkBehaviour)RoundManager.Instance).IsHost && Variables.SpawnedInsideOutID.Contains(((Object)__instance).GetInstanceID()))
			{
				Vector3 position = StartOfRound.Instance.playerSpawnPositions[0].position;
				startOfSearch = Methods.GetNearbyLocation(position);
				Variables.mls.LogError((object)"Changed Search Start Location of Enemy insideOut");
				return true;
			}
			return true;
		}
	}
	internal class GameNetworkManager_Patch
	{
		[HarmonyPatch(typeof(GameNetworkManager), "ResetSavedGameValues")]
		[HarmonyPostfix]
		public static void ResetMoonHeatOnFire(GameNetworkManager __instance)
		{
			foreach (SelectableLevel item in Variables.levelHeatVal.Keys.ToList())
			{
				if (Variables.levelHeatVal.Count != 0)
				{
					Variables.levelHeatVal[item] = 0f;
				}
			}
		}
	}
	internal class LethalConfig_Patch
	{
		[HarmonyPatch(typeof(BaseConfigItem), "ApplyChanges")]
		[HarmonyPostfix]
		internal static void BeginUpdateConfiguration()
		{
			Variables.reloadConfig = 3f;
		}
	}
	internal static class RoundManager_Patch
	{
		private static List<string> alteredLevels;

		[HarmonyPatch(typeof(RoundManager), "LoadNewLevel")]
		[HarmonyPrefix]
		private static bool ModifyLevel(ref SelectableLevel newLevel)
		{
			if (!((NetworkBehaviour)RoundManager.Instance).IsHost)
			{
				return true;
			}
			Variables.CurrentLevel = newLevel;
			if (alteredLevels == null)
			{
				alteredLevels = new List<string>();
			}
			if (!alteredLevels.Contains(newLevel.PlanetName))
			{
				if (Variables.config.MoreEntities.Value)
				{
					SelectableLevel obj = newLevel;
					obj.maxEnemyPowerCount += 150;
					SelectableLevel obj2 = newLevel;
					obj2.maxOutsideEnemyPowerCount += 10;
					SelectableLevel obj3 = newLevel;
					obj3.maxDaytimeEnemyPowerCount += 150;
					Variables.mls.LogMessage((object)("Affected spawn cap of " + newLevel.PlanetName));
				}
				alteredLevels.Add(newLevel.PlanetName);
			}
			Variables.minScrap = newLevel.minScrap;
			Variables.maxScrap = newLevel.maxScrap;
			Variables.minScrapValue = newLevel.minTotalScrapValue;
			Variables.maxScrapValue = newLevel.maxTotalScrapValue;
			Logger.Log("~~~Now arriving: " + newLevel.sceneName + "~~~");
			Methods.CleanupAndResetAI();
			Methods.UpdateAIInNewLevel(newLevel);
			Methods.AddMissingAIToNewLevel(newLevel);
			Methods.InitializeLevelHeatValues(newLevel);
			DK_LethalMod.Events.Methods.HandleEventSpecificAdjustments(newLevel);
			Methods.LogEnemyInformation(newLevel);
			Methods.ModifyEnemySpawnChances(newLevel);
			return true;
		}
	}
	public static class TerminalAccessibleObject_Patch
	{
		[HarmonyPatch(typeof(TerminalAccessibleObject), "CallFunctionFromTerminal")]
		[HarmonyPostfix]
		public static void CallFunctionFromTerminal_Postfix(TerminalAccessibleObject __instance)
		{
			if (Variables.HauntedElectronics)
			{
				__instance.codeAccessCooldownTimer = 10f;
			}
		}
	}
	internal class TimeOfDay_Patch
	{
		[HarmonyPatch(typeof(TimeOfDay), "Awake")]
		[HarmonyPostfix]
		private static void ModifyTimeOfDay(TimeOfDay __instance)
		{
			__instance.quotaVariables.deadlineDaysAmount = Variables.config.DeadlineDaysAmount.Value;
		}
	}
}
namespace DK_LethalMod.Objects
{
	public class Brutalizer : MonoBehaviour
	{
		private void Awake()
		{
			Variables.mls.LogMessage((object)"Brutalizer GO Awake");
		}

		private void Update()
		{
			try
			{
				if (!((Object)(object)StartOfRound.Instance != (Object)null) || !((NetworkBehaviour)RoundManager.Instance).IsHost)
				{
					return;
				}
				if (StartOfRound.Instance.shipHasLanded)
				{
					DK_LethalMod.Events.Methods.BrutalizerUpdate();
				}
				if (Variables.presetEnemiesToSpawn.Count > 0 && Variables.WaitUntilPlayerInside)
				{
					for (int i = 0; i < StartOfRound.Instance.allPlayerScripts.Length; i++)
					{
						if (StartOfRound.Instance.allPlayerScripts[i].isInsideFactory)
						{
							Methods.SpawnMultipleEnemies(Variables.presetEnemiesToSpawn);
							Variables.presetEnemiesToSpawn.Clear();
						}
					}
				}
				if (StartOfRound.Instance.shipHasLanded && !Variables.Landed)
				{
					Variables.Landed = true;
					if (Variables.presetEnemiesToSpawn.Count > 0 && !Variables.WaitUntilPlayerInside)
					{
						Methods.SpawnMultipleEnemies(Variables.presetEnemiesToSpawn);
					}
				}
				if (StartOfRound.Instance.shipIsLeaving)
				{
					if (Variables.TakeOffExecuted)
					{
						return;
					}
					if (Variables.CurrentLevel.sceneName != "CompanyBuilding" && Variables.config.EnableFreeMoney.Value && !StartOfRound.Instance.allPlayersDead)
					{
						Terminal val = Object.FindObjectOfType<Terminal>();
						val.groupCredits += Variables.config.FreeMoneyValue.Value;
						val.SyncGroupCreditsServerRpc(val.groupCredits, val.numberOfItemsInDropship);
						if (Variables.config.VerboseInGame.Value)
						{
							HUDManager.Instance.AddTextToChatOnServer("<size=10><color=green>Survival Bonus awarded: " + Variables.config.FreeMoneyValue.Value + "</color></size>", -1);
						}
					}
					Logger.Log("~~~Now departing: " + Variables.CurrentLevel.sceneName + "~~~");
					Methods.CleanUpAllVariables();
					Variables.TakeOffExecuted = true;
				}
				else
				{
					Variables.TakeOffExecuted = false;
				}
			}
			catch (Exception ex)
			{
				Variables.mls.LogError((object)("Error in Update: " + ex.Message));
			}
		}

		public void Start()
		{
			Logger.Start();
		}

		public void OnDestroy()
		{
			Logger.Close();
		}
	}
}
namespace DK_LethalMod.Events
{
	internal class Methods
	{
		public static void HandleEventSpecificAdjustments(SelectableLevel newLevel)
		{
			if (newLevel.sceneName == "CompanyBuilding")
			{
				return;
			}
			Variables.CurrentLevel = newLevel;
			int num = 0;
			bool flag = false;
			if (Random.Range(0, 255) < 16)
			{
				Variables.isBadDay = true;
				num = 65535;
				MultiplyScrapLootForEvent(3f);
				Logger.Log("Very Bad day");
			}
			else if (Random.Range(0, 255) < 16)
			{
				num = 0;
				Logger.Log("Nice conditions");
			}
			else
			{
				float num2 = 1f;
				string text = Variables.CurrentLevel.PlanetName.ToLower();
				if (text.Contains("embrion"))
				{
					num2 = 2f;
				}
				else if (text.Contains("artifice"))
				{
					num2 = 2f;
				}
				else if (text.Contains("titan"))
				{
					num2 = 2f;
				}
				else if (text.Contains("rend"))
				{
					num2 = 1.66f;
				}
				else if (text.Contains("dine"))
				{
					num2 = 1.66f;
				}
				else if (text.Contains("assurance"))
				{
					num2 = 1.33f;
				}
				else if (!text.Contains("offense"))
				{
					if (text.Contains("adamance"))
					{
						num2 = 1.33f;
					}
					else if (!text.Contains("vow") && !text.Contains("march") && !text.Contains("experimentation") && !text.Contains("assurance"))
					{
					}
				}
				int num3 = (int)(51f * num2);
				if (Random.Range(0, 255) < num3)
				{
					Variables.SpawnInsideOut = true;
					InsideOutEnemies();
					MultiplyScrapLootForEvent(1.05f);
					num++;
				}
				if (Random.Range(0, 255) < num3)
				{
					BrakenOutside();
					MultiplyScrapLootForEvent(1.05f);
					num = Blip(num, 2);
				}
				if (Random.Range(0, 255) < num3)
				{
					TheBeastsInside();
					MultiplyScrapLootForEvent(1.05f);
					num = Blip(num, 4);
				}
				if (Random.Range(0, 255) < num3)
				{
					JesterOutside();
					MultiplyScrapLootForEvent(1.05f);
					num = Blip(num, 8);
				}
				if (Random.Range(0, 255) < num3)
				{
					EvolveBlobs();
					MultiplyScrapLootForEvent(1.05f);
					num = Blip(num, 16);
				}
				if (Random.Range(0, 255) < num3)
				{
					TheRumbling();
					MultiplyScrapLootForEvent(1.05f);
					num = Blip(num, 32);
				}
				if (Random.Range(0, 255) < num3)
				{
					DoNotLookAway();
					MultiplyScrapLootForEvent(1.05f);
					num = Blip(num, 64);
				}
				if (Random.Range(0, 255) < num3)
				{
					ItsABaby();
					MultiplyScrapLootForEvent(1.05f);
					num = Blip(num, 128);
				}
				if (Random.Range(0, 255) < num3)
				{
					ChaoticWeather();
					MultiplyScrapLootForEvent(1.05f);
					num = Blip(num, 256);
				}
				if (Random.Range(0, 255) < num3)
				{
					Hoarders();
					MultiplyScrapLootForEvent(1.05f);
					num = Blip(num, 512);
				}
				if (Random.Range(0, 255) < num3)
				{
					Nutcrackers();
					MultiplyScrapLootForEvent(1.05f);
					num = Blip(num, 1024);
				}
				if (Random.Range(0, 255) < num3)
				{
					LittleGirls();
					MultiplyScrapLootForEvent(1.05f);
					num = Blip(num, 2048);
				}
				if (Random.Range(0, 255) < num3)
				{
					Butlers();
					MultiplyScrapLootForEvent(1.05f);
					num = Blip(num, 4096);
				}
				if (Random.Range(0, 255) < num3)
				{
					Mechs();
					MultiplyScrapLootForEvent(1.05f);
					num = Blip(num, 8192);
				}
				if (Random.Range(0, 255) < num3)
				{
					FreeMasks();
					MultiplyScrapLootForEvent(1.05f);
					num = Blip(num, 16384);
				}
				if (Random.Range(0, 255) < num3)
				{
					HauntedFacilityElectronics();
					MultiplyScrapLootForEvent(1.4430513f);
					num = Blip(num, 32768);
				}
			}
			if (Random.Range(0, 255) < 64)
			{
				GiveFreeEquipment();
				flag = true;
			}
			string text2 = "[" + (((num & 1) == 1) ? "=" : "_") + (((num & 2) == 2) ? "=" : "_") + (((num & 4) == 4) ? "=" : "_") + (((num & 8) == 8) ? "=" : "_") + (((num & 0x10) == 16) ? "=" : "_") + (((num & 0x20) == 32) ? "=" : "_") + (((num & 0x40) == 64) ? "=" : "_") + (((num & 0x80) == 128) ? "=" : "_") + (((num & 0x100) == 256) ? "=" : "_") + (((num & 0x200) == 512) ? "=" : "_") + (((num & 0x400) == 1024) ? "=" : "_") + (((num & 0x800) == 2048) ? "=" : "_") + (((num & 0x1000) == 4096) ? "=" : "_") + (((num & 0x2000) == 8192) ? "=" : "_") + (((num & 0x4000) == 16384) ? "=" : "_") + (((num & 0x8000) == 32768) ? "=" : "_") + "]";
			if (Variables.config.VerboseInGame.Value)
			{
				HUDManager.Instance.AddTextToChatOnServer("<color=red>Danger Level <size=10>" + text2 + (flag ? "</size>, Supplies inbound</color>" : "</color>"), -1);
			}
			ConfigureEnemySpawnTimes();
		}

		private static int Blip(int data, int flagValue)
		{
			if (Variables.HideEventBlips)
			{
				data *= 2;
				data++;
			}
			else
			{
				data += flagValue;
			}
			return data;
		}

		private static void MultiplyScrapLootForEvent(float multiplier)
		{
			Variables.CurrentLevel.minScrap = (int)((float)Variables.CurrentLevel.minScrap * multiplier);
			Variables.CurrentLevel.maxScrap = (int)((float)Variables.CurrentLevel.maxScrap * multiplier);
			Variables.CurrentLevel.minTotalScrapValue = (int)((float)Variables.CurrentLevel.minTotalScrapValue * multiplier);
			Variables.CurrentLevel.maxTotalScrapValue = (int)((float)Variables.CurrentLevel.maxTotalScrapValue * multiplier);
		}

		public static void HauntedFacilityElectronics()
		{
			Logger.Log("Haunted Doors");
			Variables.HauntedElectronics = true;
		}

		public static void FreeMasks()
		{
			Logger.Log("Free Masks");
			try
			{
				DK_LethalMod.Methods.FindEnemyPrefabByType(typeof(MaskedPlayerEnemy), Variables.CurrentLevel.Enemies, Variables.CurrentLevel);
				AddEnemyToDelayedSpawn(new Variables.EnemySpawnInfo(typeof(MaskedPlayerEnemy), 1, Variables.SpawnLocation.Outside, forceInside: false, forceOutside: true));
				AddEnemyToDelayedSpawn(new Variables.EnemySpawnInfo(typeof(MaskedPlayerEnemy), 1, Variables.SpawnLocation.Vent, forceInside: true, forceOutside: false));
			}
			catch (Exception ex)
			{
				Logger.Log("Event: Free Masks Exception: " + ex.Message);
			}
		}

		public static void Hoarders()
		{
			Logger.Log("Extra Hoarders");
			try
			{
				DK_LethalMod.Methods.FindEnemyPrefabByType(typeof(HoarderBugAI), Variables.CurrentLevel.Enemies, Variables.CurrentLevel);
				AddEnemyToDelayedSpawn(new Variables.EnemySpawnInfo(typeof(HoarderBugAI), 1, Variables.SpawnLocation.Outside, forceInside: false, forceOutside: true));
				AddEnemyToDelayedSpawn(new Variables.EnemySpawnInfo(typeof(HoarderBugAI), 1, Variables.SpawnLocation.Vent, forceInside: true, forceOutside: false));
			}
			catch (Exception ex)
			{
				Logger.Log("Event: Extra hoarders Exception: " + ex.Message);
			}
		}

		public static void Nutcrackers()
		{
			Logger.Log("Nutcracker Guardians");
			try
			{
				DK_LethalMod.Methods.FindEnemyPrefabByType(typeof(NutcrackerEnemyAI), Variables.CurrentLevel.Enemies, Variables.CurrentLevel);
				AddEnemyToDelayedSpawn(new Variables.EnemySpawnInfo(typeof(NutcrackerEnemyAI), 1, Variables.SpawnLocation.Outside, forceInside: false, forceOutside: true));
				AddEnemyToDelayedSpawn(new Variables.EnemySpawnInfo(typeof(NutcrackerEnemyAI), 1, Variables.SpawnLocation.Vent, forceInside: true, forceOutside: false));
			}
			catch (Exception ex)
			{
				Logger.Log("Event: Nutcracker Guardians Exception: " + ex.Message);
			}
		}

		public static void LittleGirls()
		{
			Logger.Log("Extra Ghost Girls");
			try
			{
				DK_LethalMod.Methods.FindEnemyPrefabByType(typeof(DressGirlAI), Variables.CurrentLevel.Enemies, Variables.CurrentLevel);
				AddEnemyToDelayedSpawn(new Variables.EnemySpawnInfo(typeof(DressGirlAI), 1, Variables.SpawnLocation.Outside, forceInside: false, forceOutside: true));
				AddEnemyToDelayedSpawn(new Variables.EnemySpawnInfo(typeof(DressGirlAI), 1, Variables.SpawnLocation.Vent, forceInside: true, forceOutside: false));
			}
			catch (Exception ex)
			{
				Logger.Log("Event: Extra Ghost Girls Exception: " + ex.Message);
			}
		}

		public static void Butlers()
		{
			Logger.Log("Outside Butler");
			try
			{
				DK_LethalMod.Methods.FindEnemyPrefabByType(typeof(ButlerEnemyAI), Variables.CurrentLevel.Enemies, Variables.CurrentLevel);
				AddEnemyToDelayedSpawn(new Variables.EnemySpawnInfo(typeof(ButlerEnemyAI), 1, Variables.SpawnLocation.Outside, forceInside: false, forceOutside: true));
			}
			catch (Exception ex)
			{
				Logger.Log("Event: Outside Butlers Exception: " + ex.Message);
			}
		}

		public static void Mechs()
		{
			Logger.Log("Extra RadMechs");
			try
			{
				DK_LethalMod.Methods.FindEnemyPrefabByType(typeof(RadMechAI), Variables.CurrentLevel.Enemies, Variables.CurrentLevel);
				int num = Random.Range(2, 3);
				for (int i = 0; i < num; i++)
				{
					AddEnemyToDelayedSpawn(new Variables.EnemySpawnInfo(typeof(RadMechAI), 1, Variables.SpawnLocation.Outside, forceInside: false, forceOutside: true));
				}
			}
			catch (Exception ex)
			{
				Logger.Log("Event: Extra RadMechs Exception: " + ex.Message);
			}
		}

		public static void ChaoticWeather()
		{
			try
			{
				Logger.Log("Event: Chaotic Weather - False Pip - Broken Event");
			}
			catch (Exception ex)
			{
				Logger.Log("Event: Chaotic Weather Exception: " + ex.Message);
			}
		}

		public static void BrakenOutside()
		{
			Logger.Log("Braken outside");
			int num = Random.Range(2, 4);
			for (int i = 0; i < num; i++)
			{
				AddEnemyToDelayedSpawn(new Variables.EnemySpawnInfo(typeof(FlowermanAI), 1, Variables.SpawnLocation.Outside, forceInside: false, forceOutside: true));
			}
		}

		public static void JesterOutside()
		{
			Logger.Log("Jester Outside");
			DK_LethalMod.Methods.FindEnemyPrefabByType(typeof(JesterAI), Variables.CurrentLevel.Enemies, Variables.CurrentLevel);
			AddEnemyToDelayedSpawn(new Variables.EnemySpawnInfo(typeof(JesterAI), 2, Variables.SpawnLocation.Outside, forceInside: false, forceOutside: true));
		}

		public static void EvolveBlobs()
		{
			Logger.Log("Evolved Blobs");
			AddEnemyToDelayedSpawn(new Variables.EnemySpawnInfo(typeof(BlobAI), Random.Range(2, 3), Variables.SpawnLocation.Vent, forceInside: false, forceOutside: false));
			AddEnemyToDelayedSpawn(new Variables.EnemySpawnInfo(typeof(BlobAI), 1, Variables.SpawnLocation.Outside, forceInside: false, forceOutside: true));
			Variables.BlobsHaveEvolved = true;
		}

		public static void TheBeastsInside()
		{
			Logger.Log("Mouthdog Inside");
			string sceneName = Variables.CurrentLevel.sceneName;
			Variables.DogForceOwnership = true;
			if (1 == 0)
			{
			}
			int num;
			switch (sceneName)
			{
			case "Embrion":
				num = 3;
				break;
			case "Artifice":
			case "Titan":
				num = 3;
				break;
			case "Rend":
			case "Dine":
				num = 2;
				break;
			case "March":
			case "Offense":
				num = 2;
				break;
			default:
				num = 2;
				break;
			}
			if (1 == 0)
			{
			}
			int num2 = num;
			for (int i = 0; i < num2; i++)
			{
				AddEnemyToDelayedSpawn(new Variables.EnemySpawnInfo(typeof(MouthDogAI), 1, Variables.SpawnLocation.Vent, forceInside: true, forceOutside: false));
			}
		}

		public static void TheRumbling()
		{
			Logger.Log("Rumbling");
			Variables.TheRumbling = true;
			string sceneName = Variables.CurrentLevel.sceneName;
			if (1 == 0)
			{
			}
			int num;
			switch (sceneName)
			{
			case "Embrion":
				num = 4;
				break;
			case "Artifice":
			case "March":
			case "Titan":
			case "Offense":
			case "Vow":
				num = 4;
				break;
			case "Dine":
			case "Rend":
				num = 5;
				break;
			case "Experimentation":
				num = 3;
				break;
			default:
				num = 4;
				break;
			}
			if (1 == 0)
			{
			}
			int num2 = num;
			for (int i = 0; i < num2; i++)
			{
				AddEnemyToDelayedSpawn(new Variables.EnemySpawnInfo(typeof(ForestGiantAI), 1, Variables.SpawnLocation.Outside, forceInside: false, forceOutside: false));
			}
		}

		public static void DoNotLookAway()
		{
			Logger.Log("Do not look away");
			DK_LethalMod.Methods.FindEnemyPrefabByType(typeof(FlowermanAI), Variables.CurrentLevel.Enemies, Variables.CurrentLevel);
			DK_LethalMod.Methods.FindEnemyPrefabByType(typeof(SpringManAI), Variables.CurrentLevel.Enemies, Variables.CurrentLevel);
			AddEnemyToDelayedSpawn(new Variables.EnemySpawnInfo(typeof(SpringManAI), 1, Variables.SpawnLocation.Vent, forceInside: false, forceOutside: false));
			AddEnemyToDelayedSpawn(new Variables.EnemySpawnInfo(typeof(FlowermanAI), 1, Variables.SpawnLocation.Vent, forceInside: false, forceOutside: false));
			AddEnemyToDelayedSpawn(new Variables.EnemySpawnInfo(typeof(FlowermanAI), 1, Variables.SpawnLocation.Outside, forceInside: false, forceOutside: true));
			AddEnemyToDelayedSpawn(new Variables.EnemySpawnInfo(typeof(SpringManAI), 1, Variables.SpawnLocation.Outside, forceInside: false, forceOutside: true));
		}

		public static void BadKitties()
		{
			Logger.Log("Event - Bad kitties - False Pip - broken event");
			try
			{
			}
			catch (Exception ex)
			{
				Logger.Log("Event: Bad Kitties Exception: " + ex.Message);
			}
		}

		public static void ItsABaby()
		{
			Logger.Log("Event: Its A Baby!");
			try
			{
				DK_LethalMod.Methods.FindEnemyPrefabByType(typeof(CaveDwellerAI), Variables.CurrentLevel.Enemies, Variables.CurrentLevel);
				Variables.BrutalizerEnemiesToSpawn.Add(new Variables.BrutalizerEnemySpawnInfo(new Variables.EnemySpawnInfo(typeof(CaveDwellerAI), 1, Variables.SpawnLocation.Outside, forceInside: false, forceOutside: true), 60f));
			}
			catch (Exception ex)
			{
				Logger.Log("Event: Its A Baby! Exception: " + ex.Message);
			}
		}

		public static void GiveFreeEquipment()
		{
			Logger.Log("Free Equipment");
			Terminal val = Object.FindObjectOfType<Terminal>();
			for (int i = 0; i < Random.Range(4, 8); i++)
			{
				val.orderedItemsFromTerminal.Add(Random.Range(0, val.buyableItemsList.Length));
			}
		}

		public static void InsideOutEnemies()
		{
			Logger.Log("Inside Out");
			Variables.InsideOutOwnership = true;
			for (int i = 0; i < 4; i++)
			{
				AddEnemyToDelayedSpawn(new Variables.EnemySpawnInfo(typeof(SpringManAI), 2, Variables.SpawnLocation.Outside, forceInside: false, forceOutside: true));
			}
		}

		public static void BrutalizerUpdate()
		{
			try
			{
				if (Variables.BrutalizerEnemiesToSpawn.Count > 0)
				{
					for (int num = Variables.BrutalizerEnemiesToSpawn.Count - 1; num >= 0; num--)
					{
						Variables.BrutalizerEnemiesToSpawn[num].timeUntilActive -= Time.deltaTime;
						if (Variables.BrutalizerEnemiesToSpawn[num].timeUntilActive < 0f)
						{
							SpawnEnemy(Variables.BrutalizerEnemiesToSpawn[num].enemySpawnInfo);
							Variables.BrutalizerEnemiesToSpawn.RemoveAt(num);
						}
					}
				}
				if (!Variables.HauntedElectronics)
				{
					return;
				}
				if (Variables.AllHauntedElectronics == null)
				{
					Variables.AllHauntedElectronics = new List<HauntedElectronics>();
					TerminalAccessibleObject[] array = Object.FindObjectsOfType<TerminalAccessibleObject>();
					TerminalAccessibleObject[] array2 = array;
					foreach (TerminalAccessibleObject accessibleObject in array2)
					{
						Variables.AllHauntedElectronics.Add(new HauntedElectronics(accessibleObject, Random.Range(10, 60)));
					}
					Turret[] array3 = Object.FindObjectsOfType<Turret>();
					Turret[] array4 = array3;
					foreach (Turret turret in array4)
					{
						Variables.AllHauntedElectronics.Add(new HauntedElectronics(turret, Random.Range(10, 60)));
					}
				}
				else
				{
					if (Variables.AllHauntedElectronics == null)
					{
						return;
					}
					{
						foreach (HauntedElectronics allHauntedElectronic in Variables.AllHauntedElectronics)
						{
							allHauntedElectronic.Update();
						}
						return;
					}
				}
			}
			catch (Exception ex)
			{
				Variables.mls.LogError((object)("Error in BrutalizerUpdate(): " + ex.Message));
			}
		}

		private static void AddEnemyToDelayedSpawn(Variables.EnemySpawnInfo enemy)
		{
			Variables.BrutalizerEnemiesToSpawn.Add(new Variables.BrutalizerEnemySpawnInfo(enemy, 60f));
		}

		private static void ConfigureEnemySpawnTimes()
		{
			Variables.BrutalizerEnemiesToSpawn.Sort((Variables.BrutalizerEnemySpawnInfo a, Variables.BrutalizerEnemySpawnInfo b) => a.random.CompareTo(b.random));
			float num = 143f;
			float num2 = 30f;
			float num3 = 700f;
			num2 = (num3 - num) / (float)(Variables.BrutalizerEnemiesToSpawn.Count + 1);
			for (int num4 = 0; num4 < Variables.BrutalizerEnemiesToSpawn.Count; num4++)
			{
				if (!Variables.BrutalizerEnemiesToSpawn[num4].forceTimeStay)
				{
					Variables.BrutalizerEnemiesToSpawn[num4].timeUntilActive = num;
					num2 += 30f;
					Variables.BrutalizerEnemiesToSpawn[num4].forceTimeStay = false;
				}
			}
		}

		private static void SpawnEnemy(Variables.EnemySpawnInfo enemy)
		{
			DK_LethalMod.Methods.SpawnMultipleEnemies(new List<Variables.EnemySpawnInfo>(1) { enemy });
		}
	}
	public class HauntedElectronics
	{
		public float timeUntilChange;

		public TerminalAccessibleObject TerminalObject;

		public Turret TurretObject;

		public HauntedElectronics(TerminalAccessibleObject accessibleObject, float timer)
		{
			TerminalObject = accessibleObject;
			timeUntilChange = timer;
		}

		public HauntedElectronics(Turret turret, float timer)
		{
			TurretObject = turret;
			timeUntilChange = timer;
		}

		public void Update()
		{
			try
			{
				timeUntilChange -= Time.deltaTime;
				if (timeUntilChange < 0f)
				{
					timeUntilChange = Random.Range(20, 40);
					TerminalAccessibleObject terminalObject = TerminalObject;
					if (terminalObject != null)
					{
						terminalObject.CallFunctionFromTerminal();
					}
					if (!((Object)(object)TurretObject == (Object)null))
					{
						TurretObject.ToggleTurretEnabled(!TurretObject.turretActive);
					}
				}
			}
			catch (Exception ex)
			{
				Logger.Log("Haunted Object Exception: " + ex.Message);
			}
		}
	}
}