Decompiled source of SavageCompany v1.1.3

SavageCompany.dll

Decompiled 10 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using LethalCompanyInputUtils.Api;
using TMPro;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("SavageCompany")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("SavageCompany")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("845e3576-b8ae-4948-a195-5a28667a638c")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace SavageCompany;

public class UIAnimation
{
	public enum AnimationState
	{
		None,
		WaitingToFadeOut,
		WaitingToFadeIn,
		FadingIn,
		FadingOut,
		FadingInThenOut,
		FadingOutThenIn,
		FadingInFast,
		FadingOutFast
	}

	public static float WaitingTimer;

	public static AnimationState UIState;

	public static AnimationState QueuedUIState;

	public static void PlayState()
	{
		if (UIState != AnimationState.WaitingToFadeIn && UIState != AnimationState.WaitingToFadeOut)
		{
			WaitingTimer = 0f;
		}
		if (UIState == AnimationState.None && QueuedUIState != 0)
		{
			UIState = QueuedUIState;
		}
		switch (UIState)
		{
		case AnimationState.None:
			break;
		case AnimationState.FadingIn:
			FadingIn();
			break;
		case AnimationState.FadingOut:
			FadingOut();
			break;
		case AnimationState.WaitingToFadeOut:
			WaitingToFadeOut();
			break;
		case AnimationState.WaitingToFadeIn:
			WaitingToFadeIn();
			break;
		case AnimationState.FadingInFast:
			FadingInFast();
			break;
		case AnimationState.FadingOutFast:
			FadingOutFast();
			break;
		case AnimationState.FadingInThenOut:
			FadingInThenOut();
			break;
		case AnimationState.FadingOutThenIn:
			FadingOutThenIn();
			break;
		}
	}

	public static void FadingOutThenIn()
	{
		float num = Time.deltaTime / 0.2f;
		if (((TMP_Text)GamePatches.EventsText).alpha - num <= 0f)
		{
			((TMP_Text)GamePatches.EventsText).alpha = 0f;
			UIState = AnimationState.WaitingToFadeIn;
			((TMP_Text)GamePatches.EventsText).text = GamePatches.EventsTextText;
		}
		else
		{
			TextMeshProUGUI eventsText = GamePatches.EventsText;
			((TMP_Text)eventsText).alpha = ((TMP_Text)eventsText).alpha - num;
		}
	}

	public static void FadingInThenOut()
	{
		float num = Time.deltaTime / 0.2f;
		if (num + ((TMP_Text)GamePatches.EventsText).alpha >= 1f)
		{
			((TMP_Text)GamePatches.EventsText).alpha = 1f;
			UIState = AnimationState.WaitingToFadeOut;
		}
		else
		{
			TextMeshProUGUI eventsText = GamePatches.EventsText;
			((TMP_Text)eventsText).alpha = ((TMP_Text)eventsText).alpha + num;
		}
	}

	public static void FadingOutFast()
	{
		float num = Time.deltaTime / 0.2f;
		if (((TMP_Text)GamePatches.EventsText).alpha - num <= 0f)
		{
			((TMP_Text)GamePatches.EventsText).alpha = 0f;
			UIState = AnimationState.None;
			((TMP_Text)GamePatches.EventsText).text = GamePatches.EventsTextText;
		}
		else
		{
			TextMeshProUGUI eventsText = GamePatches.EventsText;
			((TMP_Text)eventsText).alpha = ((TMP_Text)eventsText).alpha - num;
		}
	}

	public static void FadingInFast()
	{
		float num = Time.deltaTime / 0.2f;
		if (num + ((TMP_Text)GamePatches.EventsText).alpha >= 1f)
		{
			((TMP_Text)GamePatches.EventsText).alpha = 1f;
			UIState = AnimationState.None;
		}
		else
		{
			TextMeshProUGUI eventsText = GamePatches.EventsText;
			((TMP_Text)eventsText).alpha = ((TMP_Text)eventsText).alpha + num;
		}
	}

	public static void WaitingToFadeIn()
	{
		if (WaitingTimer >= 2.5f)
		{
			WaitingTimer = 0f;
			UIState = AnimationState.FadingInFast;
			((TMP_Text)GamePatches.EventsText).text = GamePatches.EventsTextText;
		}
		else
		{
			WaitingTimer += Time.deltaTime;
		}
	}

	public static void WaitingToFadeOut()
	{
		if (WaitingTimer >= 2.5f)
		{
			WaitingTimer = 0f;
			UIState = AnimationState.FadingOutFast;
		}
		else
		{
			WaitingTimer += Time.deltaTime;
		}
	}

	public static void FadingOut()
	{
		float num = Time.deltaTime / 0.25f;
		if (((TMP_Text)GamePatches.EventsText).alpha - num <= 0f)
		{
			((TMP_Text)GamePatches.EventsText).alpha = 0f;
			UIState = AnimationState.None;
			((TMP_Text)GamePatches.EventsText).text = GamePatches.EventsTextText;
		}
		else
		{
			TextMeshProUGUI eventsText = GamePatches.EventsText;
			((TMP_Text)eventsText).alpha = ((TMP_Text)eventsText).alpha - num;
		}
	}

	public static void FadingIn()
	{
		float num = Time.deltaTime / 0.25f;
		if (num + ((TMP_Text)GamePatches.EventsText).alpha >= 1f)
		{
			((TMP_Text)GamePatches.EventsText).alpha = 1f;
			UIState = AnimationState.None;
		}
		else
		{
			TextMeshProUGUI eventsText = GamePatches.EventsText;
			((TMP_Text)eventsText).alpha = ((TMP_Text)eventsText).alpha + num;
		}
	}
}
public class WorldEvent
{
	public int Cost;

	public int MaxLevels;

	public int Severity = 1;

	public string EventName;

	public int GetCost()
	{
		return Cost;
	}

	public bool Purchase(int PointsToSpend, out int NewPoints)
	{
		if (PointsToSpend < Cost)
		{
			NewPoints = PointsToSpend;
			return false;
		}
		int num = Math.Min((int)Math.Floor((float)PointsToSpend / (float)Cost), MaxLevels);
		NewPoints = PointsToSpend - (Severity = new Random().Next(1, num + 1)) * Cost;
		SavageCompanyBase.mls.LogInfo((object)("The " + EventName + " event has begun at severity level: " + Severity));
		return true;
	}

	public virtual void Update()
	{
	}

	public virtual void OnStart()
	{
	}

	public virtual void OnStop()
	{
	}
}
public class MinesweeperEvent : WorldEvent
{
	public static int ConfigCost;

	public static int ConfigMaxLvls;

	public static string ConfigEventName;

	public static int ConfigMinLandmines;

	public static int ConfigMaxLandmines;

	public MinesweeperEvent()
	{
		Cost = ConfigCost;
		MaxLevels = ConfigMaxLvls;
		Severity = 1;
		EventName = "Minesweeper";
		if (ConfigEventName != null)
		{
			EventName = ConfigEventName;
		}
	}

	public override void OnStart()
	{
		//IL_0047: Unknown result type (might be due to invalid IL or missing references)
		//IL_004c: 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_006f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0079: Expected O, but got Unknown
		SpawnableMapObject[] spawnableMapObjects = SavageCompanyBase.CurrentLevel.spawnableMapObjects;
		foreach (SpawnableMapObject val in spawnableMapObjects)
		{
			if ((Object)(object)val.prefabToSpawn.GetComponentInChildren<Landmine>() != (Object)null)
			{
				val.numberToSpawn = new AnimationCurve((Keyframe[])(object)new Keyframe[2]
				{
					new Keyframe(0f, (float)(ConfigMinLandmines * Severity)),
					new Keyframe(1f, (float)(ConfigMaxLandmines * Severity))
				});
			}
		}
	}

	public override void OnStop()
	{
		//IL_003f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0044: Unknown result type (might be due to invalid IL or missing references)
		//IL_0055: Unknown result type (might be due to invalid IL or missing references)
		//IL_005a: Unknown result type (might be due to invalid IL or missing references)
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0069: Expected O, but got Unknown
		SpawnableMapObject[] spawnableMapObjects = SavageCompanyBase.CurrentLevel.spawnableMapObjects;
		foreach (SpawnableMapObject val in spawnableMapObjects)
		{
			if ((Object)(object)val.prefabToSpawn.GetComponentInChildren<Landmine>() != (Object)null)
			{
				val.numberToSpawn = new AnimationCurve((Keyframe[])(object)new Keyframe[2]
				{
					new Keyframe(0f, 0f),
					new Keyframe(1f, 20f)
				});
			}
		}
	}
}
public class HeavyWeaponryEvent : WorldEvent
{
	public static int ConfigCost;

	public static int ConfigMaxLvls;

	public static string ConfigEventName;

	public static int ConfigMinTurrets;

	public static int ConfigMaxTurrets;

	public HeavyWeaponryEvent()
	{
		Cost = ConfigCost;
		MaxLevels = ConfigMaxLvls;
		Severity = 1;
		EventName = "Heavy Weaponry";
		if (ConfigEventName != null)
		{
			EventName = ConfigEventName;
		}
	}

	public override void OnStart()
	{
		//IL_0047: Unknown result type (might be due to invalid IL or missing references)
		//IL_004c: 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_006f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0079: Expected O, but got Unknown
		SpawnableMapObject[] spawnableMapObjects = SavageCompanyBase.CurrentLevel.spawnableMapObjects;
		foreach (SpawnableMapObject val in spawnableMapObjects)
		{
			if ((Object)(object)val.prefabToSpawn.GetComponentInChildren<Turret>() != (Object)null)
			{
				val.numberToSpawn = new AnimationCurve((Keyframe[])(object)new Keyframe[2]
				{
					new Keyframe(0f, (float)(ConfigMinTurrets * Severity)),
					new Keyframe(1f, (float)(ConfigMaxTurrets * Severity))
				});
			}
		}
	}

	public override void OnStop()
	{
		//IL_003f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0044: Unknown result type (might be due to invalid IL or missing references)
		//IL_0055: Unknown result type (might be due to invalid IL or missing references)
		//IL_005a: Unknown result type (might be due to invalid IL or missing references)
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0069: Expected O, but got Unknown
		SpawnableMapObject[] spawnableMapObjects = SavageCompanyBase.CurrentLevel.spawnableMapObjects;
		foreach (SpawnableMapObject val in spawnableMapObjects)
		{
			if ((Object)(object)val.prefabToSpawn.GetComponentInChildren<Turret>() != (Object)null)
			{
				val.numberToSpawn = new AnimationCurve((Keyframe[])(object)new Keyframe[2]
				{
					new Keyframe(0f, 0f),
					new Keyframe(1f, 10f)
				});
			}
		}
	}
}
public class ThumpThumpEvent : WorldEvent
{
	public static int ConfigCost;

	public static int ConfigMaxLvls;

	public static string ConfigEventName;

	public static bool hasSpawnedEnemiesYet;

	public static float timePassed;

	public static float ConfigSpawnDelay;

	public static int ConfigSpawnAmount;

	public ThumpThumpEvent()
	{
		Cost = ConfigCost;
		MaxLevels = ConfigMaxLvls;
		Severity = 1;
		EventName = "RUN";
		timePassed = 0f;
		hasSpawnedEnemiesYet = false;
		if (ConfigEventName != null)
		{
			EventName = ConfigEventName;
		}
	}

	public override void Update()
	{
		//IL_018d: Unknown result type (might be due to invalid IL or missing references)
		//IL_019b: Unknown result type (might be due to invalid IL or missing references)
		EnemyVent[] allEnemyVents = RoundManager.Instance.allEnemyVents;
		if (allEnemyVents.Length != 0)
		{
			timePassed += Time.deltaTime;
		}
		if (hasSpawnedEnemiesYet || !(timePassed >= ConfigSpawnDelay))
		{
			return;
		}
		int num = -1;
		foreach (SpawnableEnemyWithRarity enemy in SavageCompanyBase.CurrentLevel.Enemies)
		{
			if (enemy.enemyType.enemyName.ToLower().Contains("crawler"))
			{
				num = SavageCompanyBase.CurrentLevel.Enemies.IndexOf(enemy);
			}
		}
		if (num == -1 && GamePatches.GetEnemyIsInList("crawler"))
		{
			SavageCompanyBase.CurrentLevel.Enemies.Add(GamePatches.GetEnemyToSpawn("crawler"));
			foreach (SpawnableEnemyWithRarity enemy2 in SavageCompanyBase.CurrentLevel.Enemies)
			{
				if (enemy2.enemyType.enemyName.ToLower().Contains("crawler"))
				{
					num = SavageCompanyBase.CurrentLevel.Enemies.IndexOf(enemy2);
				}
			}
		}
		if (num != -1)
		{
			for (int i = 0; i < Severity * ConfigSpawnAmount; i++)
			{
				int num2 = new Random().Next(allEnemyVents.Length);
				RoundManager.Instance.SpawnEnemyOnServer(allEnemyVents[num2].floorNode.position, allEnemyVents[num2].floorNode.eulerAngles.y, num);
				SavageCompanyBase.mls.LogInfo((object)"Thumper spawned!");
			}
			hasSpawnedEnemiesYet = true;
		}
	}
}
public class ArachnophobiaEvent : WorldEvent
{
	public static int ConfigCost;

	public static int ConfigMaxLvls;

	public static string ConfigEventName;

	public static bool hasSpawnedEnemiesYet;

	public static float timePassed;

	public static float ConfigSpawnDelay;

	public static int ConfigSpawnAmount;

	public ArachnophobiaEvent()
	{
		Cost = ConfigCost;
		MaxLevels = ConfigMaxLvls;
		Severity = 1;
		EventName = "Arachnophobia";
		timePassed = 0f;
		hasSpawnedEnemiesYet = false;
		if (ConfigEventName != null)
		{
			EventName = ConfigEventName;
		}
	}

	public override void Update()
	{
		//IL_018d: Unknown result type (might be due to invalid IL or missing references)
		//IL_019b: Unknown result type (might be due to invalid IL or missing references)
		EnemyVent[] allEnemyVents = RoundManager.Instance.allEnemyVents;
		if (allEnemyVents.Length != 0)
		{
			timePassed += Time.deltaTime;
		}
		if (hasSpawnedEnemiesYet || !(timePassed >= ConfigSpawnDelay))
		{
			return;
		}
		int num = -1;
		foreach (SpawnableEnemyWithRarity enemy in SavageCompanyBase.CurrentLevel.Enemies)
		{
			if (enemy.enemyType.enemyName.ToLower().Contains("spider"))
			{
				num = SavageCompanyBase.CurrentLevel.Enemies.IndexOf(enemy);
			}
		}
		if (num == -1 && GamePatches.GetEnemyIsInList("spider"))
		{
			SavageCompanyBase.CurrentLevel.Enemies.Add(GamePatches.GetEnemyToSpawn("spider"));
			foreach (SpawnableEnemyWithRarity enemy2 in SavageCompanyBase.CurrentLevel.Enemies)
			{
				if (enemy2.enemyType.enemyName.ToLower().Contains("spider"))
				{
					num = SavageCompanyBase.CurrentLevel.Enemies.IndexOf(enemy2);
				}
			}
		}
		if (num != -1)
		{
			for (int i = 0; i < Severity * ConfigSpawnAmount; i++)
			{
				int num2 = new Random().Next(allEnemyVents.Length);
				RoundManager.Instance.SpawnEnemyOnServer(allEnemyVents[num2].floorNode.position, allEnemyVents[num2].floorNode.eulerAngles.y, num);
				SavageCompanyBase.mls.LogInfo((object)"Spider spawned!");
			}
			hasSpawnedEnemiesYet = true;
		}
	}
}
public class BugMafiaEvent : WorldEvent
{
	public static int ConfigCost;

	public static int ConfigMaxLvls;

	public static string ConfigEventName;

	public static bool hasSpawnedEnemiesYet;

	public static float timePassed;

	public static float ConfigSpawnDelay;

	public static int ConfigSpawnAmount;

	public BugMafiaEvent()
	{
		Cost = ConfigCost;
		MaxLevels = ConfigMaxLvls;
		Severity = 1;
		EventName = "Bug Mafia";
		timePassed = 0f;
		hasSpawnedEnemiesYet = false;
		if (ConfigEventName != null)
		{
			EventName = ConfigEventName;
		}
	}

	public override void Update()
	{
		//IL_018d: Unknown result type (might be due to invalid IL or missing references)
		//IL_019b: Unknown result type (might be due to invalid IL or missing references)
		EnemyVent[] allEnemyVents = RoundManager.Instance.allEnemyVents;
		if (allEnemyVents.Length != 0)
		{
			timePassed += Time.deltaTime;
		}
		if (hasSpawnedEnemiesYet || !(timePassed >= ConfigSpawnDelay))
		{
			return;
		}
		int num = -1;
		foreach (SpawnableEnemyWithRarity enemy in SavageCompanyBase.CurrentLevel.Enemies)
		{
			if (enemy.enemyType.enemyName.ToLower().Contains("hoarding"))
			{
				num = SavageCompanyBase.CurrentLevel.Enemies.IndexOf(enemy);
			}
		}
		if (num == -1 && GamePatches.GetEnemyIsInList("hoarding"))
		{
			SavageCompanyBase.CurrentLevel.Enemies.Add(GamePatches.GetEnemyToSpawn("hoarding"));
			foreach (SpawnableEnemyWithRarity enemy2 in SavageCompanyBase.CurrentLevel.Enemies)
			{
				if (enemy2.enemyType.enemyName.ToLower().Contains("hoarding"))
				{
					num = SavageCompanyBase.CurrentLevel.Enemies.IndexOf(enemy2);
				}
			}
		}
		if (num != -1)
		{
			for (int i = 0; i < Severity * ConfigSpawnAmount; i++)
			{
				int num2 = new Random().Next(allEnemyVents.Length);
				RoundManager.Instance.SpawnEnemyOnServer(allEnemyVents[num2].floorNode.position, allEnemyVents[num2].floorNode.eulerAngles.y, num);
				SavageCompanyBase.mls.LogInfo((object)"Hoarder spawned!");
			}
			hasSpawnedEnemiesYet = true;
		}
	}
}
public class LizardManiaEvent : WorldEvent
{
	public static int ConfigCost;

	public static int ConfigMaxLvls;

	public static string ConfigEventName;

	public static bool hasSpawnedEnemiesYet;

	public static float timePassed;

	public static float ConfigSpawnDelay;

	public static int ConfigSpawnAmount;

	public LizardManiaEvent()
	{
		Cost = ConfigCost;
		MaxLevels = ConfigMaxLvls;
		Severity = 1;
		EventName = "Lizard Mania";
		timePassed = 0f;
		hasSpawnedEnemiesYet = false;
		if (ConfigEventName != null)
		{
			EventName = ConfigEventName;
		}
	}

	public override void Update()
	{
		//IL_018d: Unknown result type (might be due to invalid IL or missing references)
		//IL_019b: Unknown result type (might be due to invalid IL or missing references)
		EnemyVent[] allEnemyVents = RoundManager.Instance.allEnemyVents;
		if (allEnemyVents.Length != 0)
		{
			timePassed += Time.deltaTime;
		}
		if (hasSpawnedEnemiesYet || !(timePassed >= ConfigSpawnDelay))
		{
			return;
		}
		int num = -1;
		foreach (SpawnableEnemyWithRarity enemy in SavageCompanyBase.CurrentLevel.Enemies)
		{
			if (enemy.enemyType.enemyName.ToLower().Contains("puffer"))
			{
				num = SavageCompanyBase.CurrentLevel.Enemies.IndexOf(enemy);
			}
		}
		if (num == -1 && GamePatches.GetEnemyIsInList("puffer"))
		{
			SavageCompanyBase.CurrentLevel.Enemies.Add(GamePatches.GetEnemyToSpawn("puffer"));
			foreach (SpawnableEnemyWithRarity enemy2 in SavageCompanyBase.CurrentLevel.Enemies)
			{
				if (enemy2.enemyType.enemyName.ToLower().Contains("puffer"))
				{
					num = SavageCompanyBase.CurrentLevel.Enemies.IndexOf(enemy2);
				}
			}
		}
		if (num != -1)
		{
			for (int i = 0; i < Severity * ConfigSpawnAmount; i++)
			{
				int num2 = new Random().Next(allEnemyVents.Length);
				RoundManager.Instance.SpawnEnemyOnServer(allEnemyVents[num2].floorNode.position, allEnemyVents[num2].floorNode.eulerAngles.y, num);
				SavageCompanyBase.mls.LogInfo((object)"Spore lizard spawned!");
			}
			hasSpawnedEnemiesYet = true;
		}
	}
}
public class FlowerMenEvent : WorldEvent
{
	public static int ConfigCost;

	public static int ConfigMaxLvls;

	public static string ConfigEventName;

	public static bool hasSpawnedEnemiesYet;

	public static float timePassed;

	public static float ConfigSpawnDelay;

	public static int ConfigSpawnAmount;

	public FlowerMenEvent()
	{
		Cost = ConfigCost;
		MaxLevels = ConfigMaxLvls;
		Severity = 1;
		EventName = "Behind You";
		timePassed = 0f;
		hasSpawnedEnemiesYet = false;
		if (ConfigEventName != null)
		{
			EventName = ConfigEventName;
		}
	}

	public override void Update()
	{
		//IL_018d: Unknown result type (might be due to invalid IL or missing references)
		//IL_019b: Unknown result type (might be due to invalid IL or missing references)
		EnemyVent[] allEnemyVents = RoundManager.Instance.allEnemyVents;
		if (allEnemyVents.Length != 0)
		{
			timePassed += Time.deltaTime;
		}
		if (hasSpawnedEnemiesYet || !(timePassed >= ConfigSpawnDelay))
		{
			return;
		}
		int num = -1;
		foreach (SpawnableEnemyWithRarity enemy in SavageCompanyBase.CurrentLevel.Enemies)
		{
			if (enemy.enemyType.enemyName.ToLower().Contains("flowerman"))
			{
				num = SavageCompanyBase.CurrentLevel.Enemies.IndexOf(enemy);
			}
		}
		if (num == -1 && GamePatches.GetEnemyIsInList("flowerman"))
		{
			SavageCompanyBase.CurrentLevel.Enemies.Add(GamePatches.GetEnemyToSpawn("flowerman"));
			foreach (SpawnableEnemyWithRarity enemy2 in SavageCompanyBase.CurrentLevel.Enemies)
			{
				if (enemy2.enemyType.enemyName.ToLower().Contains("flowerman"))
				{
					num = SavageCompanyBase.CurrentLevel.Enemies.IndexOf(enemy2);
				}
			}
		}
		if (num != -1)
		{
			for (int i = 0; i < Severity * ConfigSpawnAmount; i++)
			{
				int num2 = new Random().Next(allEnemyVents.Length);
				RoundManager.Instance.SpawnEnemyOnServer(allEnemyVents[num2].floorNode.position, allEnemyVents[num2].floorNode.eulerAngles.y, num);
				SavageCompanyBase.mls.LogInfo((object)"Bracken spawned!");
			}
			hasSpawnedEnemiesYet = true;
		}
	}
}
public class GullibleEvent : WorldEvent
{
	public static int ConfigCost;

	public static int ConfigMaxLvls;

	public static string ConfigEventName;

	public static bool hasSpawnedEnemiesYet;

	public static float timePassed;

	public static float ConfigSpawnDelay;

	public static int ConfigSpawnAmount;

	public GullibleEvent()
	{
		Cost = ConfigCost;
		MaxLevels = ConfigMaxLvls;
		Severity = 1;
		EventName = "It Says Gullible On The Ceiling";
		timePassed = 0f;
		hasSpawnedEnemiesYet = false;
		if (ConfigEventName != null)
		{
			EventName = ConfigEventName;
		}
	}

	public override void Update()
	{
		//IL_018d: Unknown result type (might be due to invalid IL or missing references)
		//IL_019b: Unknown result type (might be due to invalid IL or missing references)
		EnemyVent[] allEnemyVents = RoundManager.Instance.allEnemyVents;
		if (allEnemyVents.Length != 0)
		{
			timePassed += Time.deltaTime;
		}
		if (hasSpawnedEnemiesYet || !(timePassed >= ConfigSpawnDelay))
		{
			return;
		}
		int num = -1;
		foreach (SpawnableEnemyWithRarity enemy in SavageCompanyBase.CurrentLevel.Enemies)
		{
			if (enemy.enemyType.enemyName.ToLower().Contains("centipede"))
			{
				num = SavageCompanyBase.CurrentLevel.Enemies.IndexOf(enemy);
			}
		}
		if (num == -1 && GamePatches.GetEnemyIsInList("centipede"))
		{
			SavageCompanyBase.CurrentLevel.Enemies.Add(GamePatches.GetEnemyToSpawn("centipede"));
			foreach (SpawnableEnemyWithRarity enemy2 in SavageCompanyBase.CurrentLevel.Enemies)
			{
				if (enemy2.enemyType.enemyName.ToLower().Contains("centipede"))
				{
					num = SavageCompanyBase.CurrentLevel.Enemies.IndexOf(enemy2);
				}
			}
		}
		if (num != -1)
		{
			for (int i = 0; i < Severity * ConfigSpawnAmount; i++)
			{
				int num2 = new Random().Next(allEnemyVents.Length);
				RoundManager.Instance.SpawnEnemyOnServer(allEnemyVents[num2].floorNode.position, allEnemyVents[num2].floorNode.eulerAngles.y, num);
				SavageCompanyBase.mls.LogInfo((object)"Snare flea spawned!");
			}
			hasSpawnedEnemiesYet = true;
		}
	}
}
public class SlimeEvent : WorldEvent
{
	public static int ConfigCost;

	public static int ConfigMaxLvls;

	public static string ConfigEventName;

	public static bool hasSpawnedEnemiesYet;

	public static float timePassed;

	public static float ConfigSpawnDelay;

	public static int ConfigSpawnAmount;

	public SlimeEvent()
	{
		Cost = ConfigCost;
		MaxLevels = ConfigMaxLvls;
		Severity = 1;
		EventName = "SLIME";
		timePassed = 0f;
		hasSpawnedEnemiesYet = false;
		if (ConfigEventName != null)
		{
			EventName = ConfigEventName;
		}
	}

	public override void Update()
	{
		//IL_018d: Unknown result type (might be due to invalid IL or missing references)
		//IL_019b: Unknown result type (might be due to invalid IL or missing references)
		EnemyVent[] allEnemyVents = RoundManager.Instance.allEnemyVents;
		if (allEnemyVents.Length != 0)
		{
			timePassed += Time.deltaTime;
		}
		if (hasSpawnedEnemiesYet || !(timePassed >= ConfigSpawnDelay))
		{
			return;
		}
		int num = -1;
		foreach (SpawnableEnemyWithRarity enemy in SavageCompanyBase.CurrentLevel.Enemies)
		{
			if (enemy.enemyType.enemyName.ToLower().Contains("blob"))
			{
				num = SavageCompanyBase.CurrentLevel.Enemies.IndexOf(enemy);
			}
		}
		if (num == -1 && GamePatches.GetEnemyIsInList("blob"))
		{
			SavageCompanyBase.CurrentLevel.Enemies.Add(GamePatches.GetEnemyToSpawn("blob"));
			foreach (SpawnableEnemyWithRarity enemy2 in SavageCompanyBase.CurrentLevel.Enemies)
			{
				if (enemy2.enemyType.enemyName.ToLower().Contains("blob"))
				{
					num = SavageCompanyBase.CurrentLevel.Enemies.IndexOf(enemy2);
				}
			}
		}
		if (num != -1)
		{
			for (int i = 0; i < Severity * ConfigSpawnAmount; i++)
			{
				int num2 = new Random().Next(allEnemyVents.Length);
				RoundManager.Instance.SpawnEnemyOnServer(allEnemyVents[num2].floorNode.position, allEnemyVents[num2].floorNode.eulerAngles.y, num);
				SavageCompanyBase.mls.LogInfo((object)"Hygrodere spawned!");
			}
			hasSpawnedEnemiesYet = true;
		}
	}
}
public class SchizoEvent : WorldEvent
{
	public static int ConfigCost;

	public static int ConfigMaxLvls;

	public static string ConfigEventName;

	public static bool hasSpawnedEnemiesYet;

	public static float timePassed;

	public static float ConfigSpawnDelay;

	public static int ConfigSpawnAmount;

	public SchizoEvent()
	{
		Cost = ConfigCost;
		MaxLevels = ConfigMaxLvls;
		Severity = 1;
		EventName = "Schizophrenia";
		timePassed = 0f;
		hasSpawnedEnemiesYet = false;
		if (ConfigEventName != null)
		{
			EventName = ConfigEventName;
		}
	}

	public override void Update()
	{
		//IL_018d: Unknown result type (might be due to invalid IL or missing references)
		//IL_019b: Unknown result type (might be due to invalid IL or missing references)
		EnemyVent[] allEnemyVents = RoundManager.Instance.allEnemyVents;
		if (allEnemyVents.Length != 0)
		{
			timePassed += Time.deltaTime;
		}
		if (hasSpawnedEnemiesYet || !(timePassed >= ConfigSpawnDelay))
		{
			return;
		}
		int num = -1;
		foreach (SpawnableEnemyWithRarity enemy in SavageCompanyBase.CurrentLevel.Enemies)
		{
			if (enemy.enemyType.enemyName.ToLower().Contains("girl"))
			{
				num = SavageCompanyBase.CurrentLevel.Enemies.IndexOf(enemy);
			}
		}
		if (num == -1 && GamePatches.GetEnemyIsInList("girl"))
		{
			SavageCompanyBase.CurrentLevel.Enemies.Add(GamePatches.GetEnemyToSpawn("girl"));
			foreach (SpawnableEnemyWithRarity enemy2 in SavageCompanyBase.CurrentLevel.Enemies)
			{
				if (enemy2.enemyType.enemyName.ToLower().Contains("girl"))
				{
					num = SavageCompanyBase.CurrentLevel.Enemies.IndexOf(enemy2);
				}
			}
		}
		if (num != -1)
		{
			for (int i = 0; i < Severity * ConfigSpawnAmount; i++)
			{
				int num2 = new Random().Next(allEnemyVents.Length);
				RoundManager.Instance.SpawnEnemyOnServer(allEnemyVents[num2].floorNode.position, allEnemyVents[num2].floorNode.eulerAngles.y, num);
				SavageCompanyBase.mls.LogInfo((object)"Ghost Girl spawned!");
			}
			hasSpawnedEnemiesYet = true;
		}
	}
}
public class MaskedEvent : WorldEvent
{
	public static int ConfigCost;

	public static int ConfigMaxLvls;

	public static string ConfigEventName;

	public static bool hasSpawnedEnemiesYet;

	public static float timePassed;

	public static float ConfigSpawnDelay;

	public static int ConfigSpawnAmount;

	public MaskedEvent()
	{
		Cost = ConfigCost;
		MaxLevels = ConfigMaxLvls;
		Severity = 1;
		EventName = "The Masquerade";
		timePassed = 0f;
		hasSpawnedEnemiesYet = false;
		if (ConfigEventName != null)
		{
			EventName = ConfigEventName;
		}
	}

	public override void Update()
	{
		//IL_018d: Unknown result type (might be due to invalid IL or missing references)
		//IL_019b: Unknown result type (might be due to invalid IL or missing references)
		EnemyVent[] allEnemyVents = RoundManager.Instance.allEnemyVents;
		if (allEnemyVents.Length != 0)
		{
			timePassed += Time.deltaTime;
		}
		if (hasSpawnedEnemiesYet || !(timePassed >= ConfigSpawnDelay))
		{
			return;
		}
		int num = -1;
		foreach (SpawnableEnemyWithRarity enemy in SavageCompanyBase.CurrentLevel.Enemies)
		{
			if (enemy.enemyType.enemyName.ToLower().Contains("masked"))
			{
				num = SavageCompanyBase.CurrentLevel.Enemies.IndexOf(enemy);
			}
		}
		if (num == -1 && GamePatches.GetEnemyIsInList("masked"))
		{
			SavageCompanyBase.CurrentLevel.Enemies.Add(GamePatches.GetEnemyToSpawn("masked"));
			foreach (SpawnableEnemyWithRarity enemy2 in SavageCompanyBase.CurrentLevel.Enemies)
			{
				if (enemy2.enemyType.enemyName.ToLower().Contains("masked"))
				{
					num = SavageCompanyBase.CurrentLevel.Enemies.IndexOf(enemy2);
				}
			}
		}
		if (num != -1)
		{
			for (int i = 0; i < Severity * ConfigSpawnAmount; i++)
			{
				int num2 = new Random().Next(allEnemyVents.Length);
				RoundManager.Instance.SpawnEnemyOnServer(allEnemyVents[num2].floorNode.position, allEnemyVents[num2].floorNode.eulerAngles.y, num);
				SavageCompanyBase.mls.LogInfo((object)"Masked spawned!");
			}
			hasSpawnedEnemiesYet = true;
		}
	}
}
public class NutcrackerEvent : WorldEvent
{
	public static int ConfigCost;

	public static int ConfigMaxLvls;

	public static string ConfigEventName;

	public static bool hasSpawnedEnemiesYet;

	public static float timePassed;

	public static float ConfigSpawnDelay;

	public static int ConfigSpawnAmount;

	public NutcrackerEvent()
	{
		Cost = ConfigCost;
		MaxLevels = ConfigMaxLvls;
		Severity = 1;
		EventName = "Nutcracker Ballet";
		timePassed = 0f;
		hasSpawnedEnemiesYet = false;
		if (ConfigEventName != null)
		{
			EventName = ConfigEventName;
		}
	}

	public override void Update()
	{
		//IL_018d: Unknown result type (might be due to invalid IL or missing references)
		//IL_019b: Unknown result type (might be due to invalid IL or missing references)
		EnemyVent[] allEnemyVents = RoundManager.Instance.allEnemyVents;
		if (allEnemyVents.Length != 0)
		{
			timePassed += Time.deltaTime;
		}
		if (hasSpawnedEnemiesYet || !(timePassed >= ConfigSpawnDelay))
		{
			return;
		}
		int num = -1;
		foreach (SpawnableEnemyWithRarity enemy in SavageCompanyBase.CurrentLevel.Enemies)
		{
			if (enemy.enemyType.enemyName.ToLower().Contains("nutcracker"))
			{
				num = SavageCompanyBase.CurrentLevel.Enemies.IndexOf(enemy);
			}
		}
		if (num == -1 && GamePatches.GetEnemyIsInList("nutcracker"))
		{
			SavageCompanyBase.CurrentLevel.Enemies.Add(GamePatches.GetEnemyToSpawn("nutcracker"));
			foreach (SpawnableEnemyWithRarity enemy2 in SavageCompanyBase.CurrentLevel.Enemies)
			{
				if (enemy2.enemyType.enemyName.ToLower().Contains("nutcracker"))
				{
					num = SavageCompanyBase.CurrentLevel.Enemies.IndexOf(enemy2);
				}
			}
		}
		if (num != -1)
		{
			for (int i = 0; i < Severity * ConfigSpawnAmount; i++)
			{
				int num2 = new Random().Next(allEnemyVents.Length);
				RoundManager.Instance.SpawnEnemyOnServer(allEnemyVents[num2].floorNode.position, allEnemyVents[num2].floorNode.eulerAngles.y, num);
				SavageCompanyBase.mls.LogInfo((object)"Nutcracker spawned!");
			}
			hasSpawnedEnemiesYet = true;
		}
	}
}
public class CoilEvent : WorldEvent
{
	public static int ConfigCost;

	public static int ConfigMaxLvls;

	public static string ConfigEventName;

	public static bool hasSpawnedEnemiesYet;

	public static float timePassed;

	public static float ConfigSpawnDelay;

	public static int ConfigSpawnAmount;

	public CoilEvent()
	{
		Cost = ConfigCost;
		MaxLevels = ConfigMaxLvls;
		Severity = 1;
		EventName = "Weeping Angels";
		timePassed = 0f;
		hasSpawnedEnemiesYet = false;
		if (ConfigEventName != null)
		{
			EventName = ConfigEventName;
		}
	}

	public override void Update()
	{
		//IL_018d: Unknown result type (might be due to invalid IL or missing references)
		//IL_019b: Unknown result type (might be due to invalid IL or missing references)
		EnemyVent[] allEnemyVents = RoundManager.Instance.allEnemyVents;
		if (allEnemyVents.Length != 0)
		{
			timePassed += Time.deltaTime;
		}
		if (hasSpawnedEnemiesYet || !(timePassed >= ConfigSpawnDelay))
		{
			return;
		}
		int num = -1;
		foreach (SpawnableEnemyWithRarity enemy in SavageCompanyBase.CurrentLevel.Enemies)
		{
			if (enemy.enemyType.enemyName.ToLower().Contains("spring"))
			{
				num = SavageCompanyBase.CurrentLevel.Enemies.IndexOf(enemy);
			}
		}
		if (num == -1 && GamePatches.GetEnemyIsInList("spring"))
		{
			SavageCompanyBase.CurrentLevel.Enemies.Add(GamePatches.GetEnemyToSpawn("spring"));
			foreach (SpawnableEnemyWithRarity enemy2 in SavageCompanyBase.CurrentLevel.Enemies)
			{
				if (enemy2.enemyType.enemyName.ToLower().Contains("spring"))
				{
					num = SavageCompanyBase.CurrentLevel.Enemies.IndexOf(enemy2);
				}
			}
		}
		if (num != -1)
		{
			for (int i = 0; i < Severity * ConfigSpawnAmount; i++)
			{
				int num2 = new Random().Next(allEnemyVents.Length);
				RoundManager.Instance.SpawnEnemyOnServer(allEnemyVents[num2].floorNode.position, allEnemyVents[num2].floorNode.eulerAngles.y, num);
				SavageCompanyBase.mls.LogInfo((object)"Coilhead spawned!");
			}
			hasSpawnedEnemiesYet = true;
		}
	}
}
public class JesterEvent : WorldEvent
{
	public static int ConfigCost;

	public static int ConfigMaxLvls;

	public static string ConfigEventName;

	public static bool hasSpawnedEnemiesYet;

	public static float timePassed;

	public static float ConfigSpawnDelay;

	public static int ConfigSpawnAmount;

	public JesterEvent()
	{
		Cost = ConfigCost;
		MaxLevels = ConfigMaxLvls;
		Severity = 1;
		EventName = "Music MAYHEM";
		timePassed = 0f;
		hasSpawnedEnemiesYet = false;
		if (ConfigEventName != null)
		{
			EventName = ConfigEventName;
		}
	}

	public override void Update()
	{
		//IL_018d: Unknown result type (might be due to invalid IL or missing references)
		//IL_019b: Unknown result type (might be due to invalid IL or missing references)
		EnemyVent[] allEnemyVents = RoundManager.Instance.allEnemyVents;
		if (allEnemyVents.Length != 0)
		{
			timePassed += Time.deltaTime;
		}
		if (hasSpawnedEnemiesYet || !(timePassed >= ConfigSpawnDelay))
		{
			return;
		}
		int num = -1;
		foreach (SpawnableEnemyWithRarity enemy in SavageCompanyBase.CurrentLevel.Enemies)
		{
			if (enemy.enemyType.enemyName.ToLower().Contains("jester"))
			{
				num = SavageCompanyBase.CurrentLevel.Enemies.IndexOf(enemy);
			}
		}
		if (num == -1 && GamePatches.GetEnemyIsInList("jester"))
		{
			SavageCompanyBase.CurrentLevel.Enemies.Add(GamePatches.GetEnemyToSpawn("jester"));
			foreach (SpawnableEnemyWithRarity enemy2 in SavageCompanyBase.CurrentLevel.Enemies)
			{
				if (enemy2.enemyType.enemyName.ToLower().Contains("jester"))
				{
					num = SavageCompanyBase.CurrentLevel.Enemies.IndexOf(enemy2);
				}
			}
		}
		if (num != -1)
		{
			for (int i = 0; i < Severity * ConfigSpawnAmount; i++)
			{
				int num2 = new Random().Next(allEnemyVents.Length);
				RoundManager.Instance.SpawnEnemyOnServer(allEnemyVents[num2].floorNode.position, allEnemyVents[num2].floorNode.eulerAngles.y, num);
				SavageCompanyBase.mls.LogInfo((object)"Jester spawned!");
			}
			hasSpawnedEnemiesYet = true;
		}
	}
}
public class DangerSurfaceEvent : WorldEvent
{
	public static int ConfigCost;

	public static int ConfigMaxLvls;

	public static string ConfigEventName;

	public static bool hasSpawnedEnemiesYet;

	public static float timePassed;

	public static float ConfigSpawnDelay;

	public static int ConfigSpawnAmount;

	public DangerSurfaceEvent()
	{
		Cost = ConfigCost;
		MaxLevels = ConfigMaxLvls;
		Severity = 1;
		EventName = "Dangerous Surface";
		timePassed = 0f;
		hasSpawnedEnemiesYet = false;
		if (ConfigEventName != null)
		{
			EventName = ConfigEventName;
		}
	}

	public override void Update()
	{
		//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
		//IL_0172: Unknown result type (might be due to invalid IL or missing references)
		//IL_0177: Unknown result type (might be due to invalid IL or missing references)
		//IL_017c: Unknown result type (might be due to invalid IL or missing references)
		//IL_020c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0211: Unknown result type (might be due to invalid IL or missing references)
		//IL_0216: Unknown result type (might be due to invalid IL or missing references)
		GameObject[] outsideAINodes = RoundManager.Instance.outsideAINodes;
		if (outsideAINodes.Length != 0)
		{
			timePassed += Time.deltaTime;
		}
		if (hasSpawnedEnemiesYet || !(timePassed >= ConfigSpawnDelay))
		{
			return;
		}
		for (int i = 0; i < Severity * ConfigSpawnAmount; i++)
		{
			int num = new Random().Next(0, 3);
			foreach (SpawnableEnemyWithRarity outsideEnemy in SavageCompanyBase.CurrentLevel.OutsideEnemies)
			{
				if (num == 0 && outsideEnemy.enemyType.enemyName.ToLower().Contains("forest"))
				{
					for (int j = 0; j < 2; j++)
					{
						int num2 = new Random().Next(outsideAINodes.Length);
						GameObject val = Object.Instantiate<GameObject>(outsideEnemy.enemyType.enemyPrefab, outsideAINodes[num2].transform.position, Quaternion.Euler(Vector3.zero));
						val.gameObject.GetComponentInChildren<NetworkObject>().Spawn(true);
						SavageCompanyBase.mls.LogInfo((object)"Forest giant spawned!");
					}
				}
				if (num == 1 && outsideEnemy.enemyType.enemyName.ToLower().Contains("mouth"))
				{
					for (int k = 0; k < 2; k++)
					{
						int num3 = new Random().Next(outsideAINodes.Length);
						GameObject val2 = Object.Instantiate<GameObject>(outsideEnemy.enemyType.enemyPrefab, outsideAINodes[num3].transform.position, Quaternion.Euler(Vector3.zero));
						val2.gameObject.GetComponentInChildren<NetworkObject>().Spawn(true);
						SavageCompanyBase.mls.LogInfo((object)"Eyeless dog spawned!");
					}
				}
				if (num == 2 && outsideEnemy.enemyType.enemyName.ToLower().Contains("earth"))
				{
					int num4 = new Random().Next(outsideAINodes.Length);
					GameObject val3 = Object.Instantiate<GameObject>(outsideEnemy.enemyType.enemyPrefab, outsideAINodes[num4].transform.position, Quaternion.Euler(Vector3.zero));
					val3.gameObject.GetComponentInChildren<NetworkObject>().Spawn(true);
					SavageCompanyBase.mls.LogInfo((object)"Sandworm spawned!");
				}
			}
			hasSpawnedEnemiesYet = true;
		}
	}
}
public class DangerBuildingEvent : WorldEvent
{
	public static int ConfigCost;

	public static int ConfigMaxLvls;

	public static string ConfigEventName;

	public static bool hasSpawnedEnemiesYet;

	public static float timePassed;

	public static float ConfigSpawnDelay;

	public static int ConfigSpawnAmount;

	public DangerBuildingEvent()
	{
		Cost = ConfigCost;
		MaxLevels = ConfigMaxLvls;
		Severity = 1;
		EventName = "Dangerous Building";
		timePassed = 0f;
		hasSpawnedEnemiesYet = false;
		if (ConfigEventName != null)
		{
			EventName = ConfigEventName;
		}
	}

	public override void Update()
	{
		//IL_0082: Unknown result type (might be due to invalid IL or missing references)
		//IL_0090: Unknown result type (might be due to invalid IL or missing references)
		EnemyVent[] allEnemyVents = RoundManager.Instance.allEnemyVents;
		if (allEnemyVents.Length != 0)
		{
			timePassed += Time.deltaTime;
		}
		if (!hasSpawnedEnemiesYet && timePassed >= ConfigSpawnDelay)
		{
			for (int i = 0; i < Severity * ConfigSpawnAmount; i++)
			{
				int num = new Random().Next(SavageCompanyBase.CurrentLevel.Enemies.Count);
				int num2 = new Random().Next(allEnemyVents.Length);
				RoundManager.Instance.SpawnEnemyOnServer(allEnemyVents[num2].floorNode.position, allEnemyVents[num2].floorNode.eulerAngles.y, num);
				hasSpawnedEnemiesYet = true;
			}
		}
	}
}
public class TurretDefenseEvent : WorldEvent
{
	public static int ConfigCost;

	public static int ConfigMaxLvls;

	public static string ConfigEventName;

	public bool HasSpawnedYet = false;

	public float Timer = 0f;

	public TurretDefenseEvent()
	{
		Cost = ConfigCost;
		MaxLevels = ConfigMaxLvls;
		Severity = 1;
		Timer = 0f;
		EventName = "Ship Defense System";
		if (ConfigEventName != null)
		{
			EventName = ConfigEventName;
		}
		HasSpawnedYet = false;
	}

	public override void Update()
	{
		//IL_008e: 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_00b2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
		Timer += Time.deltaTime;
		if (HasSpawnedYet || !(Timer >= 1f))
		{
			return;
		}
		SpawnableMapObject[] spawnableMapObjects = SavageCompanyBase.CurrentLevel.spawnableMapObjects;
		foreach (SpawnableMapObject val in spawnableMapObjects)
		{
			if ((Object)(object)val.prefabToSpawn.GetComponentInChildren<Turret>() != (Object)null)
			{
				float num = 3.87f;
				for (int j = 0; j < Severity; j++)
				{
					GameObject val2 = Object.Instantiate<GameObject>(val.prefabToSpawn, new Vector3(3.87f, 0.25f, -14.23f), Quaternion.identity);
					val2.transform.position = new Vector3(num, 0.25f, -14.23f);
					val2.transform.forward = new Vector3(1f, 0f, 0f);
					val2.GetComponent<NetworkObject>().Spawn(true);
					SavageCompanyBase.ObjectsToCleanUp.Add(val2);
					num -= 0.25f;
				}
				SavageCompanyBase.mls.LogInfo((object)"Spawned turrets!");
				HasSpawnedYet = true;
				break;
			}
		}
	}
}
public class LANDMinesEvent : WorldEvent
{
	public static int ConfigCost;

	public static int ConfigMaxLvls;

	public static string ConfigEventName;

	public static bool hasSpawnedYet;

	public static float timePassed;

	public static int ConfigLandminesToSpawn;

	public LANDMinesEvent()
	{
		Cost = ConfigCost;
		MaxLevels = ConfigMaxLvls;
		Severity = 1;
		EventName = "LAND Mines";
		hasSpawnedYet = false;
		timePassed = 0f;
		if (ConfigEventName != null)
		{
			EventName = ConfigEventName;
		}
	}

	public override void Update()
	{
		//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
		//IL_0108: Unknown result type (might be due to invalid IL or missing references)
		//IL_010d: Unknown result type (might be due to invalid IL or missing references)
		//IL_00da: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ee: 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_0117: Unknown result type (might be due to invalid IL or missing references)
		//IL_0119: Unknown result type (might be due to invalid IL or missing references)
		//IL_012c: Unknown result type (might be due to invalid IL or missing references)
		if (RoundManager.Instance.outsideAINodes.Length != 0)
		{
			timePassed += Time.deltaTime;
		}
		if (hasSpawnedYet || !(timePassed > 2.5f) || RoundManager.Instance.outsideAINodes.Length == 0)
		{
			return;
		}
		SpawnableMapObject[] spawnableMapObjects = SavageCompanyBase.CurrentLevel.spawnableMapObjects;
		RaycastHit val2 = default(RaycastHit);
		foreach (SpawnableMapObject val in spawnableMapObjects)
		{
			if ((Object)(object)val.prefabToSpawn.GetComponentInChildren<Landmine>() != (Object)null)
			{
				GameObject[] outsideAINodes = RoundManager.Instance.outsideAINodes;
				for (int j = 0; j < Severity * ConfigLandminesToSpawn; j++)
				{
					int num = new Random().Next(outsideAINodes.Length);
					Vector3 val3 = ((!Physics.Raycast(outsideAINodes[num].transform.position, Vector3.down, ref val2, 80f, 268437760, (QueryTriggerInteraction)1)) ? outsideAINodes[num].transform.position : (((RaycastHit)(ref val2)).point + new Vector3(0f, 0.25f, 0f)));
					GameObject val4 = Object.Instantiate<GameObject>(val.prefabToSpawn, val3, Quaternion.identity);
					val4.transform.position = val3;
					val4.GetComponent<NetworkObject>().Spawn(true);
					SavageCompanyBase.ObjectsToCleanUp.Add(val4);
				}
				hasSpawnedYet = true;
				break;
			}
		}
	}
}
public class GuardedPlanetEvent : WorldEvent
{
	public static int ConfigCost;

	public static int ConfigMaxLvls;

	public static string ConfigEventName;

	public static bool hasSpawnedYet;

	public static float timePassed;

	public static int ConfigTurretsToSpawn;

	public GuardedPlanetEvent()
	{
		Cost = ConfigCost;
		MaxLevels = ConfigMaxLvls;
		Severity = 1;
		EventName = "Armageddon";
		hasSpawnedYet = false;
		timePassed = 0f;
		if (ConfigEventName != null)
		{
			EventName = ConfigEventName;
		}
	}

	public override void Update()
	{
		//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
		//IL_0108: Unknown result type (might be due to invalid IL or missing references)
		//IL_010d: Unknown result type (might be due to invalid IL or missing references)
		//IL_00da: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ee: 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_0117: Unknown result type (might be due to invalid IL or missing references)
		//IL_0119: Unknown result type (might be due to invalid IL or missing references)
		//IL_012c: Unknown result type (might be due to invalid IL or missing references)
		if (RoundManager.Instance.outsideAINodes.Length != 0)
		{
			timePassed += Time.deltaTime;
		}
		if (hasSpawnedYet || !(timePassed > 2.5f) || RoundManager.Instance.outsideAINodes.Length == 0)
		{
			return;
		}
		SpawnableMapObject[] spawnableMapObjects = SavageCompanyBase.CurrentLevel.spawnableMapObjects;
		RaycastHit val2 = default(RaycastHit);
		foreach (SpawnableMapObject val in spawnableMapObjects)
		{
			if ((Object)(object)val.prefabToSpawn.GetComponentInChildren<Turret>() != (Object)null)
			{
				GameObject[] outsideAINodes = RoundManager.Instance.outsideAINodes;
				for (int j = 0; j < Severity * ConfigTurretsToSpawn; j++)
				{
					int num = new Random().Next(outsideAINodes.Length);
					Vector3 val3 = ((!Physics.Raycast(outsideAINodes[num].transform.position, Vector3.down, ref val2, 80f, 268437760, (QueryTriggerInteraction)1)) ? outsideAINodes[num].transform.position : (((RaycastHit)(ref val2)).point + new Vector3(0f, 0.25f, 0f)));
					GameObject val4 = Object.Instantiate<GameObject>(val.prefabToSpawn, val3, Quaternion.identity);
					val4.transform.position = val3;
					val4.GetComponent<NetworkObject>().Spawn(true);
					SavageCompanyBase.ObjectsToCleanUp.Add(val4);
				}
				hasSpawnedYet = true;
				break;
			}
		}
	}
}
public class WeaponsOfDestructionEvent : WorldEvent
{
	public static int ConfigCost;

	public static int ConfigMaxLvls;

	public static string ConfigEventName;

	public WeaponsOfDestructionEvent()
	{
		Cost = ConfigCost;
		MaxLevels = ConfigMaxLvls;
		Severity = 1;
		EventName = "Weapons of Mass Destruction";
		if (ConfigEventName != null)
		{
			EventName = ConfigEventName;
		}
	}
}
public class StronkMonstersEvent : WorldEvent
{
	public static int ConfigCost;

	public static int ConfigMaxLvls;

	public static string ConfigEventName;

	public StronkMonstersEvent()
	{
		Cost = ConfigCost;
		MaxLevels = ConfigMaxLvls;
		Severity = 1;
		EventName = "Stronk Monsters";
		if (ConfigEventName != null)
		{
			EventName = ConfigEventName;
		}
	}
}
public class GamePatches
{
	public static int DefaultHeatValue;

	public static int HeatValueIncreaseMin;

	public static int HeatValueIncreaseMax;

	public static int MaxHeatValue;

	public static bool RandomPoints;

	public static int MinPoints;

	public static int MaxPoints;

	public static bool FunnyPlanets;

	public static float PointsMarginBeginning;

	public static float PointsMarginIncreaseMulti;

	public static int TextBoxXOffset;

	public static int TextBoxYOffset;

	public static bool UIIsToggle;

	public static bool MinesweeperEventEnabled;

	public static bool HeavyWeaponryEventEnabled;

	public static bool RUNEventEnabled;

	public static bool ArachnophobiaEventEnabled;

	public static bool BugMafiaEventEnabled;

	public static bool LizardManiaEventEnabled;

	public static bool BehindYouEventEnabled;

	public static bool GullibleEventEnabled;

	public static bool SlimeEventEnabled;

	public static bool SchizoEventEnabled;

	public static bool MaskedEventEnabled;

	public static bool NutcrackerEventEnabled;

	public static bool WeepingAngelEventEnabled;

	public static bool JesterEventEnabled;

	public static bool DangerSurfaceEventEnabled;

	public static bool DangerBuildingEventEnabled;

	public static bool DefenseTurretEventEnabled;

	public static bool LANDMinesEventEnabled;

	public static bool ArmageddonEventEnabled;

	public static bool WeaponsDestructionEventEnabled;

	public static bool StronkMonstersEventEnabled;

	public static bool NeedUIUpdate = false;

	public static int HeatValueDecrease;

	public static TextMeshProUGUI EventsText = null;

	public static string EventsTextText = "<color=green>Land on a moon to view the currently ongoing events!";

	public static bool IsPercentageText = true;

	public static bool IsEventsTextEnabled = false;

	public static bool UIFormatting = true;

	public static bool HasPressedKey;

	public static bool ReadyToToggle = true;

	public static bool IsShowingTutorial = false;

	public static bool NeedToShowTutorial = false;

	public static bool WaitingToPressAgainTutorial = false;

	public static bool NeedsUIUpdate = false;

	public static int UIFontSize = 11;

	public static int UIHeaderFontSize = 15;

	public static string UITextAlignment = "Top Left";

	public static bool DisableUI = false;

	public static bool ClearChat = true;

	public static bool HeatMessages = false;

	public static bool ShowTutorialBool = true;

	public static bool UpKeyHeld = false;

	public static bool DownKeyHeld = false;

	public static bool LeftKeyHeld = false;

	public static bool RightKeyHeld = false;

	public static int StartingCredits = 1000;

	public static float ScrapDensityMultiplier = 2.5f;

	public static bool InfiniteCredits = false;

	public static Terminal terminal = null;

	public static Dictionary<Landmine, float> TimeToExplode = new Dictionary<Landmine, float>();

	[HarmonyPatch(typeof(RoundManager), "LoadNewLevel")]
	[HarmonyPrefix]
	private static bool LoadLevelPatch(ref SelectableLevel newLevel)
	{
		if (StartOfRound.Instance.gameStats.daysSpent == 0)
		{
			SavageCompanyBase.GameEvents = new List<WorldEvent>();
			SavageCompanyBase.heatValues = new Dictionary<SelectableLevel, int>();
		}
		if (IsShowingTutorial && (Object)(object)EventsText != (Object)null)
		{
			IsShowingTutorial = false;
			IsEventsTextEnabled = false;
			NeedToShowTutorial = false;
			((TMP_Text)EventsText).text = "";
		}
		if (!newLevel.sceneName.Equals("CompanyBuilding"))
		{
			SavageCompanyBase.IsAtCompanyBuilding = false;
			Dictionary<SelectableLevel, int> heatValues = SavageCompanyBase.heatValues;
			if (!heatValues.ContainsKey(newLevel))
			{
				heatValues.Add(newLevel, DefaultHeatValue);
			}
			SavageCompanyBase.heatValues = heatValues;
			int num = SavageCompanyBase.heatValues[newLevel];
			int num3;
			if (RandomPoints)
			{
				int num2 = Math.Min((int)((float)MinPoints * (1f + (float)num / 100f)), MaxPoints);
				num3 = Random.Range(num2, MaxPoints);
			}
			else
			{
				float num4 = PointsMarginBeginning;
				for (int i = 0; i < StartOfRound.Instance.gameStats.daysSpent; i++)
				{
					float num5 = (float)Math.Max((int)Math.Min((float)i / 4f, 5f), 1) * PointsMarginIncreaseMulti;
					num4 += num5;
				}
				int num6 = (int)((float)MinPoints * ((float)(num / 100) + 1f) + (float)MaxPoints * (num4 / 2f));
				int num7 = (int)((float)MaxPoints * Math.Min(num4, 1f));
				if (num >= 80)
				{
					num7 = (int)((float)num7 * ((float)num / 100f + 1f));
				}
				if (num6 > num7)
				{
					num6 = num7;
				}
				num3 = Random.Range(num6, num7);
				SavageCompanyBase.mls.LogInfo((object)("Points Margin: " + num4));
				SavageCompanyBase.mls.LogInfo((object)("Min Points: " + num6));
				SavageCompanyBase.mls.LogInfo((object)("Max Points: " + num7));
			}
			if (FunnyPlanets)
			{
				if (((Object)newLevel).name.ToLower().Contains("assurance"))
				{
					num3 *= 5;
				}
				else if (((Object)newLevel).name.ToLower().Contains("titan"))
				{
					num3 *= 10;
				}
			}
			SavageCompanyBase.mls.LogInfo((object)("Points: " + num3));
			List<WorldEvent> list = new List<WorldEvent>();
			SavageCompanyBase.GameEvents = new List<WorldEvent>();
			SavageCompanyBase.CurrentLevel = newLevel;
			if (MinesweeperEventEnabled)
			{
				list.Add(new MinesweeperEvent());
			}
			if (HeavyWeaponryEventEnabled)
			{
				list.Add(new HeavyWeaponryEvent());
			}
			if (GetEnemyIsInList("crawler") && RUNEventEnabled)
			{
				list.Add(new ThumpThumpEvent());
			}
			if (GetEnemyIsInList("spider") && ArachnophobiaEventEnabled)
			{
				list.Add(new ArachnophobiaEvent());
			}
			if (GetEnemyIsInList("hoarding") && BugMafiaEventEnabled)
			{
				list.Add(new BugMafiaEvent());
			}
			if (GetEnemyIsInList("puffer") && LizardManiaEventEnabled)
			{
				list.Add(new LizardManiaEvent());
			}
			if (GetEnemyIsInList("flowerman") && BehindYouEventEnabled)
			{
				list.Add(new FlowerMenEvent());
			}
			if (GetEnemyIsInList("centipede") && GullibleEventEnabled)
			{
				list.Add(new GullibleEvent());
			}
			if (GetEnemyIsInList("blob") && SlimeEventEnabled)
			{
				list.Add(new SlimeEvent());
			}
			if (GetEnemyIsInList("girl") && SchizoEventEnabled)
			{
				list.Add(new SchizoEvent());
			}
			if (GetEnemyIsInList("masked") && MaskedEventEnabled)
			{
				list.Add(new MaskedEvent());
			}
			if (GetEnemyIsInList("nutcracker") && NutcrackerEventEnabled)
			{
				list.Add(new NutcrackerEvent());
			}
			if (GetEnemyIsInList("spring") && WeepingAngelEventEnabled)
			{
				list.Add(new CoilEvent());
			}
			if (GetEnemyIsInList("jester") && JesterEventEnabled)
			{
				list.Add(new JesterEvent());
			}
			if (DangerSurfaceEventEnabled)
			{
				list.Add(new DangerSurfaceEvent());
			}
			if (DangerBuildingEventEnabled)
			{
				list.Add(new DangerBuildingEvent());
			}
			if (DefenseTurretEventEnabled)
			{
				list.Add(new TurretDefenseEvent());
			}
			if (LANDMinesEventEnabled)
			{
				list.Add(new LANDMinesEvent());
			}
			if (ArmageddonEventEnabled)
			{
				list.Add(new GuardedPlanetEvent());
			}
			if (WeaponsDestructionEventEnabled)
			{
				list.Add(new WeaponsOfDestructionEvent());
			}
			if (StronkMonstersEventEnabled)
			{
				list.Add(new StronkMonstersEvent());
			}
			while (list.Count > 0)
			{
				int index = new Random().Next(0, list.Count);
				if (!list[index].Purchase(num3, out var NewPoints))
				{
					list.RemoveAt(index);
					if (list.Count <= 0)
					{
						break;
					}
					continue;
				}
				num3 = NewPoints;
				SavageCompanyBase.GameEvents.Add(list[index]);
				list.RemoveAt(index);
				if (list.Count > 0)
				{
					continue;
				}
				break;
			}
			foreach (WorldEvent gameEvent in SavageCompanyBase.GameEvents)
			{
				gameEvent.OnStart();
			}
		}
		else
		{
			SavageCompanyBase.IsAtCompanyBuilding = true;
		}
		NeedUIUpdate = true;
		if (((NetworkBehaviour)HUDManager.Instance).IsHost || ((NetworkBehaviour)HUDManager.Instance).IsServer)
		{
			foreach (GameObject item in SavageCompanyBase.ObjectsToCleanUp)
			{
				if ((Object)(object)item != (Object)null)
				{
					Object.Destroy((Object)(object)item);
				}
			}
		}
		SetCredits();
		return true;
	}

	public static void SendHeatValueMessages(SelectableLevel level)
	{
		if (!HeatMessages)
		{
			int num = SavageCompanyBase.heatValues[level];
			if (num <= 0)
			{
				HUDManager.Instance.AddTextToChatOnServer("<color=green>Moon Heat: 0%", -1);
			}
			else if (num <= 33)
			{
				HUDManager.Instance.AddTextToChatOnServer("<color=yellow>Moon Heat: " + num + "%", -1);
			}
			else if (num <= 67)
			{
				HUDManager.Instance.AddTextToChatOnServer("<color=orange>Moon Heat: " + num + "%", -1);
				HUDManager.Instance.AddTextToChatOnServer("<color=orange>Moon heat is rising, please consider moving to another moon.", -1);
			}
			else
			{
				HUDManager.Instance.AddTextToChatOnServer("<color=red>Moon Heat: " + num + "%", -1);
				HUDManager.Instance.AddTextToChatOnServer("<color=red>Moon heat is dangerously high, move to another moon to lower the danger level!", -1);
			}
		}
	}

	[HarmonyPatch(typeof(Terminal), "Start")]
	[HarmonyPostfix]
	private static void GetEnemies(SelectableLevel[] ___moonsCatalogueList)
	{
		foreach (SelectableLevel val in ___moonsCatalogueList)
		{
			foreach (SpawnableEnemyWithRarity enemy in val.Enemies)
			{
				bool flag = false;
				foreach (SpawnableEnemyWithRarity foundEnemy in SavageCompanyBase.FoundEnemies)
				{
					if (((Object)foundEnemy.enemyType).name == ((Object)enemy.enemyType).name)
					{
						flag = true;
					}
				}
				if (!flag)
				{
					SavageCompanyBase.mls.LogInfo((object)("Adding " + enemy.enemyType.enemyName + " to list of enemies."));
					SavageCompanyBase.FoundEnemies.Add(enemy);
				}
			}
		}
	}

	public static SpawnableEnemyWithRarity GetEnemyToSpawn(string EnemyName)
	{
		foreach (SpawnableEnemyWithRarity foundEnemy in SavageCompanyBase.FoundEnemies)
		{
			if (((Object)foundEnemy.enemyType).name.ToLower().Contains(EnemyName.ToLower()))
			{
				return foundEnemy;
			}
		}
		return null;
	}

	public static bool GetEnemyIsInList(string EnemyName)
	{
		foreach (SpawnableEnemyWithRarity foundEnemy in SavageCompanyBase.FoundEnemies)
		{
			if (((Object)foundEnemy.enemyType).name.ToLower().Contains(EnemyName.ToLower()))
			{
				return true;
			}
		}
		return false;
	}

	[HarmonyPatch(typeof(StartOfRound), "ShipLeave")]
	[HarmonyPostfix]
	private static void GameEndingPatch()
	{
		Dictionary<SelectableLevel, int> heatValues = SavageCompanyBase.heatValues;
		SelectableLevel currentLevel = SavageCompanyBase.CurrentLevel;
		foreach (SelectableLevel item in heatValues.Keys.ToList())
		{
			if ((Object)(object)item == (Object)(object)currentLevel)
			{
				if (HeatValueIncreaseMax < HeatValueIncreaseMin)
				{
					HeatValueIncreaseMax = HeatValueIncreaseMin;
					SavageCompanyBase.mls.LogError((object)"Config Entry: Heat Value Increase Maximum was less than the Heat Value Increase Minimum. Setting Maximum value to Minimum value to avoid errors.");
				}
				if (HeatValueIncreaseMin > HeatValueIncreaseMax)
				{
					HeatValueIncreaseMin = HeatValueIncreaseMax;
					SavageCompanyBase.mls.LogError((object)"Config Entry: Heat Value Increase Minimum was greater than the Heat Value Increase Maximum. Setting Minimum value to Maximum value to avoid errors.");
				}
				heatValues[item] = Math.Min(new Random().Next(HeatValueIncreaseMin, HeatValueIncreaseMax) + heatValues[item], MaxHeatValue);
			}
			else
			{
				heatValues[item] = Math.Max(0, heatValues[item] - HeatValueDecrease);
			}
		}
		SavageCompanyBase.heatValues = heatValues;
		if (((NetworkBehaviour)HUDManager.Instance).IsHost || ((NetworkBehaviour)HUDManager.Instance).IsServer)
		{
			foreach (GameObject item2 in SavageCompanyBase.ObjectsToCleanUp)
			{
				if ((Object)(object)item2 != (Object)null)
				{
					Object.Destroy((Object)(object)item2);
				}
			}
		}
		foreach (WorldEvent gameEvent in SavageCompanyBase.GameEvents)
		{
			gameEvent.OnStop();
		}
		if ((((NetworkBehaviour)TimeOfDay.Instance).IsServer || ((NetworkBehaviour)TimeOfDay.Instance).IsHost) && !DisableUI)
		{
			HUDManager.Instance.AddTextToChatOnServer("NEWUITEXTIGNOREME <color=green>Land on a moon to view the currently ongoing events!", -1);
			if (ClearChat)
			{
				HUDManager.Instance.AddTextToChatOnServer("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n", -1);
			}
		}
		SavageCompanyBase.GameEvents = new List<WorldEvent>();
		TimeToExplode.Clear();
		SetCredits();
	}

	[HarmonyPatch(typeof(StartOfRound), "Update")]
	[HarmonyPostfix]
	private static void RoundUpdatePatch()
	{
		foreach (WorldEvent gameEvent in SavageCompanyBase.GameEvents)
		{
			gameEvent.Update();
		}
	}

	[HarmonyPatch(typeof(HUDManager), "Update")]
	[HarmonyPostfix]
	private static void AddToHUDPatch(HUDManager __instance)
	{
		//IL_0047: Unknown result type (might be due to invalid IL or missing references)
		//IL_004d: Expected O, but got Unknown
		//IL_010f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0130: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f8: Expected O, but got Unknown
		//IL_027e: Unknown result type (might be due to invalid IL or missing references)
		//IL_029d: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b4: Unknown result type (might be due to invalid IL or missing references)
		//IL_02cb: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d8: Unknown result type (might be due to invalid IL or missing references)
		//IL_02dd: Unknown result type (might be due to invalid IL or missing references)
		//IL_0303: Unknown result type (might be due to invalid IL or missing references)
		//IL_0264: Unknown result type (might be due to invalid IL or missing references)
		//IL_025c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0274: Unknown result type (might be due to invalid IL or missing references)
		//IL_024c: Unknown result type (might be due to invalid IL or missing references)
		//IL_026c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0254: Unknown result type (might be due to invalid IL or missing references)
		//IL_0244: Unknown result type (might be due to invalid IL or missing references)
		//IL_08fa: Unknown result type (might be due to invalid IL or missing references)
		//IL_08ff: Unknown result type (might be due to invalid IL or missing references)
		//IL_091b: Unknown result type (might be due to invalid IL or missing references)
		//IL_093a: Unknown result type (might be due to invalid IL or missing references)
		//IL_093f: Unknown result type (might be due to invalid IL or missing references)
		//IL_095b: Unknown result type (might be due to invalid IL or missing references)
		//IL_097a: Unknown result type (might be due to invalid IL or missing references)
		//IL_097f: Unknown result type (might be due to invalid IL or missing references)
		//IL_099b: Unknown result type (might be due to invalid IL or missing references)
		//IL_09ba: Unknown result type (might be due to invalid IL or missing references)
		//IL_09bf: Unknown result type (might be due to invalid IL or missing references)
		//IL_09db: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)EventsText == (Object)null)
		{
			GameObject val = GameObject.Find("Systems/UI/Canvas/IngamePlayerHUD/TopRightCorner");
			if ((Object)(object)val == (Object)null)
			{
				SavageCompanyBase.mls.LogError((object)"Couldn't find TopRightCorner, UI may not show up correctly.");
				return;
			}
			GameObject val2 = new GameObject("EventTextObject");
			val2.transform.SetParent(val.transform, false);
			EventsText = val2.AddComponent<TextMeshProUGUI>();
			if ((Object)(object)__instance.weightCounter != (Object)null)
			{
				TextMeshProUGUI weightCounter = __instance.weightCounter;
				((TMP_Text)EventsText).font = ((TMP_Text)weightCounter).font;
				((TMP_Text)EventsText).enableAutoSizing = ((TMP_Text)weightCounter).enableAutoSizing;
				((TMP_Text)EventsText).fontSizeMin = ((TMP_Text)weightCounter).fontSizeMin;
				((TMP_Text)EventsText).fontSizeMax = ((TMP_Text)weightCounter).fontSizeMax;
				if ((Object)(object)((TMP_Text)weightCounter).fontMaterial != (Object)null)
				{
					((TMP_Text)EventsText).fontSharedMaterial = new Material(((TMP_Text)weightCounter).fontMaterial);
				}
			}
			((Graphic)EventsText).color = new Color(255f, 255f, 0f);
			((TMP_Text)EventsText).fontSize = UIFontSize;
			TextAlignmentOptions alignment = (TextAlignmentOptions)257;
			UITextAlignment = UITextAlignment.ToLower().Replace(" ", "").Replace("-", "")
				.Replace("_", "")
				.Replace(".", "");
			switch (UITextAlignment)
			{
			case "bottomright":
				alignment = (TextAlignmentOptions)1028;
				break;
			case "bottom":
				alignment = (TextAlignmentOptions)1026;
				break;
			case "bottomleft":
				alignment = (TextAlignmentOptions)1025;
				break;
			case "left":
				alignment = (TextAlignmentOptions)513;
				break;
			case "top":
				alignment = (TextAlignmentOptions)258;
				break;
			case "topright":
				alignment = (TextAlignmentOptions)260;
				break;
			case "right":
				alignment = (TextAlignmentOptions)516;
				break;
			}
			((TMP_Text)EventsText).alignment = alignment;
			RectTransform component = ((Component)EventsText).GetComponent<RectTransform>();
			component.anchorMin = new Vector2(1f, 1f);
			component.anchorMax = new Vector2(1f, 1f);
			component.pivot = new Vector2(1f, 1f);
			Vector2 anchoredPosition = component.anchoredPosition;
			anchoredPosition.x += TextBoxXOffset;
			anchoredPosition.y += TextBoxYOffset;
			component.anchoredPosition = anchoredPosition;
			((Behaviour)EventsText).enabled = true;
			((TMP_Text)EventsText).alpha = 0f;
		}
		if (!((Object)(object)EventsText != (Object)null))
		{
			return;
		}
		if (NeedToShowTutorial)
		{
			ShowTutorial();
		}
		if ((((NetworkBehaviour)TimeOfDay.Instance).IsServer || ((NetworkBehaviour)TimeOfDay.Instance).IsHost) && NeedUIUpdate)
		{
			int num = 0;
			foreach (WorldEvent gameEvent in SavageCompanyBase.GameEvents)
			{
				num += gameEvent.GetCost() * gameEvent.Severity;
			}
			string text = ((!UIFormatting) ? (num + " Points were Distributed: \n") : ((num <= 500) ? ("<i><size=" + UIHeaderFontSize + "><color=green>" + num + " Points were Distributed: </i></size></color>\n") : ((num > 1000) ? ("<i><size=" + UIHeaderFontSize + "><color=red>" + num + " Points were Distributed: </i></size></color>\n") : ("<i><size=" + UIHeaderFontSize + "><color=orange>" + num + " Points were Distributed: </i></size></color>\n"))));
			if (IsPercentageText)
			{
				foreach (WorldEvent gameEvent2 in SavageCompanyBase.GameEvents)
				{
					text = text + "- " + gameEvent2.EventName + " (" + Math.Round((float)gameEvent2.GetCost() * (float)gameEvent2.Severity / (float)num * 100f) + "%)\n";
				}
			}
			else
			{
				foreach (WorldEvent gameEvent3 in SavageCompanyBase.GameEvents)
				{
					text = text + "- " + gameEvent3.EventName + " (Level " + gameEvent3.Severity + ")\n";
				}
			}
			if (!DisableUI)
			{
				HUDManager.Instance.AddTextToChatOnServer("NEWUITEXTIGNOREME " + text, -1);
				if (ClearChat)
				{
					HUDManager.Instance.AddTextToChatOnServer("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n", -1);
				}
			}
			NeedsUIUpdate = true;
			if ((Object)(object)SavageCompanyBase.CurrentLevel != (Object)null && !SavageCompanyBase.IsAtCompanyBuilding && !StartOfRound.Instance.inShipPhase)
			{
				SendHeatValueMessages(SavageCompanyBase.CurrentLevel);
			}
			NeedUIUpdate = false;
			SetCredits();
		}
		else if (((NetworkBehaviour)TimeOfDay.Instance).IsServer || ((NetworkBehaviour)TimeOfDay.Instance).IsHost)
		{
			SetCredits();
		}
		if (!IsShowingTutorial && UIAnimation.UIState == UIAnimation.AnimationState.None)
		{
			if (UIIsToggle)
			{
				if (HasPressedKey && ReadyToToggle)
				{
					ReadyToToggle = false;
					IsEventsTextEnabled = !IsEventsTextEnabled;
					if (IsEventsTextEnabled)
					{
						UIAnimation.UIState = UIAnimation.AnimationState.FadingIn;
					}
					else
					{
						UIAnimation.UIState = UIAnimation.AnimationState.FadingOut;
					}
				}
				if (!HasPressedKey && !ReadyToToggle)
				{
					ReadyToToggle = true;
				}
			}
			else if (HasPressedKey)
			{
				UIAnimation.UIState = UIAnimation.AnimationState.FadingIn;
			}
			else
			{
				UIAnimation.UIState = UIAnimation.AnimationState.FadingOut;
			}
		}
		else if (UIAnimation.UIState == UIAnimation.AnimationState.None)
		{
			if (HasPressedKey && !WaitingToPressAgainTutorial)
			{
				UIAnimation.UIState = UIAnimation.AnimationState.FadingOut;
				WaitingToPressAgainTutorial = true;
			}
			else if (!HasPressedKey && WaitingToPressAgainTutorial)
			{
				WaitingToPressAgainTutorial = false;
				IsShowingTutorial = false;
			}
		}
		if (IsShowingTutorial && !UIIsToggle)
		{
			UIAnimation.UIState = UIAnimation.AnimationState.None;
			((TMP_Text)EventsText).alpha = 1f;
		}
		if (((TMP_Text)EventsText).alpha == 0f && !IsShowingTutorial)
		{
			((TMP_Text)EventsText).text = EventsTextText;
		}
		UIAnimation.PlayState();
		if (NeedsUIUpdate && UIAnimation.UIState == UIAnimation.AnimationState.None && ((TMP_Text)EventsText).alpha == 1f)
		{
			UIAnimation.UIState = UIAnimation.AnimationState.FadingOutThenIn;
			NeedsUIUpdate = false;
		}
		else if (NeedsUIUpdate && UIAnimation.UIState == UIAnimation.AnimationState.None && ((TMP_Text)EventsText).alpha == 0f)
		{
			UIAnimation.UIState = UIAnimation.AnimationState.FadingInThenOut;
			NeedsUIUpdate = false;
		}
		else if (NeedsUIUpdate && UIAnimation.UIState == UIAnimation.AnimationState.FadingIn)
		{
			UIAnimation.QueuedUIState = UIAnimation.AnimationState.FadingOutThenIn;
			NeedsUIUpdate = false;
		}
		else if (NeedsUIUpdate && UIAnimation.UIState == UIAnimation.AnimationState.FadingOut)
		{
			UIAnimation.QueuedUIState = UIAnimation.AnimationState.FadingInThenOut;
			NeedsUIUpdate = false;
		}
		if (UpKeyHeld)
		{
			Vector2 anchoredPosition2 = ((Component)EventsText).GetComponent<RectTransform>().anchoredPosition;
			anchoredPosition2.y += 1f;
			((Component)EventsText).GetComponent<RectTransform>().anchoredPosition = anchoredPosition2;
		}
		if (DownKeyHeld)
		{
			Vector2 anchoredPosition3 = ((Component)EventsText).GetComponent<RectTransform>().anchoredPosition;
			anchoredPosition3.y -= 1f;
			((Component)EventsText).GetComponent<RectTransform>().anchoredPosition = anchoredPosition3;
		}
		if (LeftKeyHeld)
		{
			Vector2 anchoredPosition4 = ((Component)EventsText).GetComponent<RectTransform>().anchoredPosition;
			anchoredPosition4.x -= 1f;
			((Component)EventsText).GetComponent<RectTransform>().anchoredPosition = anchoredPosition4;
		}
		if (RightKeyHeld)
		{
			Vector2 anchoredPosition5 = ((Component)EventsText).GetComponent<RectTransform>().anchoredPosition;
			anchoredPosition5.x += 1f;
			((Component)EventsText).GetComponent<RectTransform>().anchoredPosition = anchoredPosition5;
		}
	}

	[HarmonyPatch(typeof(TimeOfDay), "Awake")]
	[HarmonyPostfix]
	private static void TimeOfDayAwakePatch(TimeOfDay __instance)
	{
		if (__instance.quotaVariables != null && StartingCredits != 0)
		{
			QuotaSettings quotaVariables = __instance.quotaVariables;
			quotaVariables.startingCredits += StartingCredits;
		}
	}

	[HarmonyPatch(typeof(RoundManager), "Awake")]
	[HarmonyPostfix]
	private static void RoundManagerAwakePatch(RoundManager __instance)
	{
		if (ScrapDensityMultiplier != 0f)
		{
			__instance.scrapAmountMultiplier += ScrapDensityMultiplier;
		}
	}

	public static void ShowTutorial()
	{
		if (ShowTutorialBool)
		{
			if ((Object)(object)EventsText != (Object)null)
			{
				((TMP_Text)EventsText).text = "<color=green><i><size=" + UIHeaderFontSize + ">Welcome to Savage Company!</i></color></size>\n<color=yellow><size=" + UIFontSize + ">- This UI will show you the current events on the planet when you land.\n- There are many factors that affect which events happen and how dangerous they are.\n- You can press the UI hotkey in the keybinds menu (default: [Y]) to hide this UI.\n- Thanks for playing my mod, and have fun!</color></size>";
				((Behaviour)EventsText).enabled = true;
				IsShowingTutorial = true;
				NeedToShowTutorial = false;
				IsEventsTextEnabled = false;
				UIAnimation.UIState = UIAnimation.AnimationState.FadingIn;
			}
			else
			{
				NeedToShowTutorial = true;
				UIAnimation.UIState = UIAnimation.AnimationState.None;
			}
		}
		else
		{
			UIAnimation.UIState = UIAnimation.AnimationState.None;
		}
		IsEventsTextEnabled = false;
		EventsTextText = "<color=green>Land on a moon to view the currently ongoing events!";
	}

	[HarmonyPatch(typeof(GameNetworkManager), "StartClient")]
	[HarmonyPostfix]
	private static void StartClientPatch()
	{
		ShowTutorial();
	}

	[HarmonyPatch(typeof(GameNetworkManager), "StartHost")]
	[HarmonyPostfix]
	private static void StartHostPatch()
	{
		ShowTutorial();
	}

	public static void SetCredits()
	{
		//IL_002a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0034: Expected O, but got Unknown
		if (InfiniteCredits)
		{
			if ((Object)(object)terminal == (Object)null)
			{
				terminal = (Terminal)Object.FindObjectOfType(typeof(Terminal));
			}
			if (terminal.groupCredits < 9999)
			{
				terminal.SyncGroupCreditsServerRpc(9999, terminal.numberOfItemsInDropship);
			}
		}
	}

	public static string ParseChatMessage(string message)
	{
		if (message.StartsWith("<color=#7069ff>NEWUITEXTIGNOREME "))
		{
			return message.Substring(0, message.Length - 8).Substring(33);
		}
		return message;
	}

	[HarmonyPatch(typeof(HUDManager), "AddChatMessage")]
	[HarmonyPostfix]
	private static void AddChatPatch()
	{
		foreach (string item in HUDManager.Instance.ChatMessageHistory)
		{
			if (item.StartsWith("<color=#7069ff>NEWUITEXTIGNOREME "))
			{
				EventsTextText = ParseChatMessage(item);
				NeedsUIUpdate = true;
			}
		}
	}

	[HarmonyPatch(typeof(CentipedeAI), "Update")]
	[HarmonyPostfix]
	private static void SnareFleaPatch(CentipedeAI __instance)
	{
		foreach (WorldEvent gameEvent in SavageCompanyBase.GameEvents)
		{
			if (gameEvent is StronkMonstersEvent)
			{
				((EnemyAI)__instance).agent.speed = 5f + (float)gameEvent.Severity / 5f;
				break;
			}
		}
	}

	[HarmonyPatch(typeof(SandSpiderAI), "Update")]
	[HarmonyPostfix]
	private static void SandSpiderPatch(SandSpiderAI __instance, ref float ___timeSincePlacingWebTrap, ref int ___maxWebTrapsToPlace)
	{
		foreach (WorldEvent gameEvent in SavageCompanyBase.GameEvents)
		{
			if (gameEvent is StronkMonstersEvent)
			{
				((EnemyAI)__instance).agent.speed = 5f + (float)gameEvent.Severity / 4f;
				__instance.spiderSpeed = 5f + (float)gameEvent.Severity / 4f;
				if (___maxWebTrapsToPlace < 10)
				{
					___maxWebTrapsToPlace = 10 * gameEvent.Severity;
				}
				if (___timeSincePlacingWebTrap < 3f)
				{
					___timeSincePlacingWebTrap = 3f;
				}
				break;
			}
		}
	}

	[HarmonyPatch(typeof(HoarderBugAI), "Update")]
	[HarmonyPostfix]
	private static void HoarderBugPatch(HoarderBugAI __instance, bool ___inChase)
	{
		foreach (WorldEvent gameEvent in SavageCompanyBase.GameEvents)
		{
			if (gameEvent is StronkMonstersEvent)
			{
				((EnemyAI)__instance).agent.speed = 6f + (float)(gameEvent.Severity * 2);
				if (___inChase)
				{
					((EnemyAI)__instance).agent.speed = 18f + (float)(gameEvent.Severity * 2);
				}
				break;
			}
		}
	}

	[HarmonyPatch(typeof(HoarderBugAI), "DoAIInterval")]
	[HarmonyPostfix]
	private static void HoarderBugAIPatch(HoarderBugAI __instance, ref bool ___waitingAtNest)
	{
		//IL_005c: Unknown result type (might be due to invalid IL or missing references)
		foreach (WorldEvent gameEvent in SavageCompanyBase.GameEvents)
		{
			if (gameEvent is StronkMonstersEvent)
			{
				if (((EnemyAI)__instance).currentBehaviourStateIndex == 0 && (Object)(object)__instance.targetItem == (Object)null && !__instance.searchForItems.inProgress && __instance.heldItem == null)
				{
					((EnemyAI)__instance).StartSearch(__instance.nestPosition, __instance.searchForItems);
				}
				break;
			}
		}
	}

	[HarmonyPatch(typeof(FlowermanAI), "Update")]
	[HarmonyPostfix]
	private static void FlowermanAIPatch(FlowermanAI __instance)
	{
		foreach (WorldEvent gameEvent in SavageCompanyBase.GameEvents)
		{
			if (gameEvent is StronkMonstersEvent)
			{
				if (((EnemyAI)__instance).currentBehaviourStateIndex == 0)
				{
					((EnemyAI)__instance).agent.speed = 6f + (float)(gameEvent.Severity / 2);
				}
				break;
			}
		}
	}

	[HarmonyPatch(typeof(CrawlerAI), "Update")]
	[HarmonyPostfix]
	private static void ThumperAIPatch(CrawlerAI __instance)
	{
		foreach (WorldEvent gameEvent in SavageCompanyBase.GameEvents)
		{
			if (gameEvent is StronkMonstersEvent)
			{
				if (((EnemyAI)__instance).currentBehaviourStateIndex == 0)
				{
					((EnemyAI)__instance).agent.speed = 7f + (float)gameEvent.Severity / 2f;
				}
				break;
			}
		}
	}

	[HarmonyPatch(typeof(BlobAI), "Update")]
	[HarmonyPostfix]
	private static void BlobAIPatch(BlobAI __instance, float ___angeredTimer)
	{
		foreach (WorldEvent gameEvent in SavageCompanyBase.GameEvents)
		{
			if (gameEvent is StronkMonstersEvent)
			{
				((EnemyAI)__instance).agent.speed = 0.6f + (float)gameEvent.Severity / 10f;
				if (___angeredTimer > 0f)
				{
					((EnemyAI)__instance).agent.speed = 0.6f + (float)gameEvent.Severity / 6f;
				}
				break;
			}
		}
	}

	[HarmonyPatch(typeof(DressGirlAI), "Update")]
	[HarmonyPostfix]
	private static void DressGirlAIPatch(DressGirlAI __instance)
	{
		foreach (WorldEvent gameEvent in SavageCompanyBase.GameEvents)
		{
			if (gameEvent is StronkMonstersEvent)
			{
				((EnemyAI)__instance).agent.speed = 6f + (float)gameEvent.Severity;
				break;
			}
		}
	}

	[HarmonyPatch(typeof(PufferAI), "Update")]
	[HarmonyPostfix]
	private static void PufferAIPatch(PufferAI __instance, ref float ___unclampedSpeed)
	{
		foreach (WorldEvent gameEvent in SavageCompanyBase.GameEvents)
		{
			if (gameEvent is StronkMonstersEvent)
			{
				___unclampedSpeed = 9f + (float)gameEvent.Severity;
				break;
			}
		}
	}

	[HarmonyPatch(typeof(NutcrackerEnemyAI), "Update")]
	[HarmonyPostfix]
	private static void NutcrackerAIPatch(PufferAI __instance)
	{
		foreach (WorldEvent gameEvent in SavageCompanyBase.GameEvents)
		{
			if (gameEvent is StronkMonstersEvent)
			{
				if (((EnemyAI)__instance).currentBehaviourStateIndex == 0)
				{
					((EnemyAI)__instance).agent.speed = 5.5f + (float)gameEvent.Severity / 2f;
				}
				else if (((EnemyAI)__instance).currentBehaviourStateIndex == 2)
				{
					((EnemyAI)__instance).agent.speed = 7f + (float)gameEvent.Severity / 2f;
				}
				break;
			}
		}
	}

	[HarmonyPatch(typeof(SpringManAI), "Update")]
	[HarmonyPostfix]
	private static void SpringManAIPatch(SpringManAI __instance, bool ___hasStopped)
	{
		//IL_004f: Unknown result type (might be due to invalid IL or missing references)
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		foreach (WorldEvent gameEvent in SavageCompanyBase.GameEvents)
		{
			if (gameEvent is StronkMonstersEvent)
			{
				if (___hasStopped && gameEvent.Severity > 3 && (Object)(object)((EnemyAI)__instance).targetPlayer != (Object)null && Vector3.Distance(((Component)__instance).transform.position, ((Component)((EnemyAI)__instance).targetPlayer).transform.position) > 3f)
				{
					((EnemyAI)__instance).agent.speed = 0.05f * (float)gameEvent.Severity;
				}
				break;
			}
		}
	}

	[HarmonyPatch(typeof(JesterAI), "SetJesterInitialValues")]
	[HarmonyPostfix]
	private static void JesterValuesPatch(JesterAI __instance)
	{
		foreach (WorldEvent gameEvent in SavageCompanyBase.GameEvents)
		{
			if (gameEvent is StronkMonstersEvent)
			{
				float num = Random.Range(gameEvent.Severity, gameEvent.Severity * 5);
				__instance.popUpTimer = Random.Range(35f - num, 40f - num);
				__instance.beginCrankingTimer = Random.Range(25f - num, 42f - num);
				break;
			}
		}
	}

	[HarmonyPatch(typeof(MaskedPlayerEnemy), "Update")]
	[HarmonyPostfix]
	private static void MaskedAIPatch(MaskedPlayerEnemy __instance, bool ___running, bool ___runningRandomly)
	{
		foreach (WorldEvent gameEvent in SavageCompanyBase.GameEvents)
		{
			if (gameEvent is StronkMonstersEvent)
			{
				if (___running || ___runningRandomly)
				{
					((EnemyAI)__instance).agent.speed = 8f + (float)gameEvent.Severity / 2f;
				}
				else
				{
					((EnemyAI)__instance).agent.speed = 4f + (float)gameEvent.Severity / 2f;
				}
				break;
			}
		}
	}

	[HarmonyPatch(typeof(MouthDogAI), "Update")]
	[HarmonyPostfix]
	private static void EyelessAIPatch(MouthDogAI __instance)
	{
		foreach (WorldEvent gameEvent in SavageCompanyBase.GameEvents)
		{
			if (gameEvent is StronkMonstersEvent)
			{
				if (((EnemyAI)__instance).currentBehaviourStateIndex == 0)
				{
					((EnemyAI)__instance).agent.speed = 3.5f + (float)gameEvent.Severity / 2f;
				}
				else if (((EnemyAI)__instance).currentBehaviourStateIndex == 1)
				{
					((EnemyAI)__instance).agent.speed = 4.5f + (float)gameEvent.Severity / 2f;
				}
				break;
			}
		}
	}

	[HarmonyPatch(typeof(Turret), "Update")]
	[HarmonyPostfix]
	private static void TurretStartPatch(Turret __instance, ref float ___turretInterval, ref float ___switchRotationTimer)
	{
		//IL_0043: Unknown result type (might be due to invalid IL or missing references)
		//IL_0049: Invalid comparison between Unknown and I4
		//IL_006c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0072: Invalid comparison between Unknown and I4
		foreach (WorldEvent gameEvent in SavageCompanyBase.GameEvents)
		{
			if (gameEvent is WeaponsOfDestructionEvent)
			{
				__instance.rotationSpeed = 28f + (float)gameEvent.Severity * 5.6f;
				if ((int)__instance.turretMode == 1)
				{
					___turretInterval += Time.deltaTime * ((float)gameEvent.Severity / 5f);
				}
				else if ((int)__instance.turretMode == 0)
				{
					___switchRotationTimer += Time.deltaTime * ((float)gameEvent.Severity / 5f);
				}
			}
		}
	}

	[HarmonyPatch(typeof(Landmine), "Start")]
	[HarmonyPostfix]
	private static void LandmineStartPatch(Landmine __instance)
	{
		TimeToExplode.Add(__instance, Random.Range(0f, 1080f));
	}

	[HarmonyPatch(typeof(Landmine), "Update")]
	[HarmonyPostfix]
	private static void LandmineUpdatePatch(Landmine __instance)
	{
		foreach (WorldEvent gameEvent in SavageCompanyBase.GameEvents)
		{
			if (!(gameEvent is WeaponsOfDestructionEvent))
			{
				continue;
			}
			if (__instance.mineAnimator.speed <= 1f && !__instance.hasExploded)
			{
				__instance.mineAnimator.speed = 1f / ((float)gameEvent.Severity + 1f);
				if (gameEvent.Severity >= 5)
				{
					__instance.mineAnimator.speed = 0f;
				}
				if (TimeToExplode.TryGetValue(__instance, out var value) && value < TimeOfDay.Instance.currentDayTime)
				{
					__instance.mineAnimator.speed = 2f;
				}
			}
			else if (__instance.mineAnimator.speed >= 2f && !__instance.hasExploded)
			{
				Animator mineAnimator = __instance.mineAnimator;
				mineAnimator.speed += Time.deltaTime * (float)gameEvent.Severity;
				__instance.mineAudio.pitch = __instance.mineAnimator.speed / 25f;
				__instance.mineAudio.volume = __instance.mineAnimator.speed / 5f;
				if (__instance.mineAnimator.speed >= 25f)
				{
					__instance.SetOffMineAnimation();
				}
			}
		}
	}
}
[BepInPlugin("Derpling.SavageCompany", "Savage Company", "1.1.3")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class SavageCompanyBase : BaseUnityPlugin
{
	private const string modGUID = "Derpling.SavageCompany";

	private const string modName = "Savage Company";

	private const string modVersion = "1.1.3";

	private readonly Harmony harmony = new Harmony("Derpling.SavageCompany");

	public static SavageCompanyBase Instance;

	public static ManualLogSource mls;

	internal static UIInputClass InputClass = new UIInputClass();

	private static ConfigEntry<int> DefaultHeatValue;

	private static ConfigEntry<int> HeatValueIncreaseMin;

	private static ConfigEntry<int> HeatValueIncreaseMax;

	private static ConfigEntry<int> HeatValueDecrease;

	private static ConfigEntry<int> MaxHeatValue;

	private static ConfigEntry<int> MinPoints;

	private static ConfigEntry<int> MaxPoints;

	private static ConfigEntry<bool> FunnyPlanets;

	private static ConfigEntry<int> TextBoxXOffset;

	private static ConfigEntry<int> TextBoxYOffset;

	private static ConfigEntry<bool> UIIsToggle;

	private static ConfigEntry<bool> PercentageText;

	private static ConfigEntry<int> UIHeaderFontSize;

	private static ConfigEntry<int> UIFontSize;

	private static ConfigEntry<bool> InfiniteCredits;

	private static ConfigEntry<int> StartingCredits;

	private static ConfigEntry<float> ScrapDensityMultiplier;

	private static ConfigEntry<bool> DisableUI;

	private static ConfigEntry<bool> ClearChat;

	private static ConfigEntry<bool> HeatMessages;

	private static ConfigEntry<bool> RandomPoints;

	private static ConfigEntry<string> UITextAlignment;

	private static ConfigEntry<bool> ShowTutorial;

	private static ConfigEntry<float> PointsMarginBeginning;

	private static ConfigEntry<float> PointsMarginIncreaseMulti;

	private static ConfigEntry<bool> MinesweeperEventEnabled;

	private static ConfigEntry<bool> HeavyWeaponryEventEnabled;

	private static ConfigEntry<bool> RUNEventEnabled;

	private static ConfigEntry<bool> ArachnophobiaEventEnabled;

	private static ConfigEntry<bool> BugMafiaEventEnabled;

	private static ConfigEntry<bool> LizardManiaEventEnabled;

	private static ConfigEntry<bool> BehindYouEventEnabled;

	private static ConfigEntry<bool> GullibleEventEnabled;

	private static ConfigEntry<bool> SlimeEventEnabled;

	private static ConfigEntry<bool> SchizoEventEnabled;

	private static ConfigEntry<bool> MaskedEventEnabled;

	private static ConfigEntry<bool> NutcrackerEventEnabled;

	private static ConfigEntry<bool> WeepingAngelEventEnabled;

	private static ConfigEntry<bool> JesterEventEnabled;

	private static ConfigEntry<bool> DangerSurfaceEventEnabled;

	private static ConfigEntry<bool> DangerBuildingEventEnabled;

	private static ConfigEntry<bool> DefenseTurretEventEnabled;

	private static ConfigEntry<bool> LANDMinesEventEnabled;

	private static ConfigEntry<bool> ArmageddonEventEnabled;

	private static ConfigEntry<bool> WeaponsDestructionEventEnabled;

	private static ConfigEntry<bool> StronkMonstersEventEnabled;

	private static ConfigEntry<int> MinesweeperEventCost;

	private static ConfigEntry<int> HeavyWeaponryEventCost;

	private static ConfigEntry<int> RUNEventCost;

	private static ConfigEntry<int> ArachnophobiaEventCost;

	private static ConfigEntry<int> BugMafiaEventCost;

	private static ConfigEntry<int> LizardManiaEventCost;

	private static ConfigEntry<int> BehindYouEventCost;

	private static ConfigEntry<int> GullibleEventCost;

	private static ConfigEntry<int> SlimeEventCost;

	private static ConfigEntry<int> SchizoEventCost;

	private static ConfigEntry<int> MaskedEventCost;

	private static ConfigEntry<int> NutcrackerEventCost;

	private static ConfigEntry<int> WeepingAngelEventCost;

	private static ConfigEntry<int> JesterEventCost;

	private static ConfigEntry<int> DangerSurfaceEventCost;

	private static ConfigEntry<int> DangerBuildingEventCost;

	private static ConfigEntry<int> DefenseTurretEventCost;

	private static ConfigEntry<int> LANDMinesEventCost;

	private static ConfigEntry<int> ArmageddonEventCost;

	private static ConfigEntry<int> WeaponsDestructionEventCost;

	private static ConfigEntry<int> StronkMonstersEventCost;

	private static ConfigEntry<int> MinesweeperEventMaxLvl;

	private static ConfigEntry<int> HeavyWeaponryEventMaxLvl;

	private static ConfigEntry<int> RUNEventMaxLvl;

	private static ConfigEntry<int> ArachnophobiaEventMaxLvl;

	private static ConfigEntry<int> BugMafiaEventMaxLvl;

	private static ConfigEntry<int> LizardManiaEventMaxLvl;

	private static ConfigEntry<int> BehindYouEventMaxLvl;

	private static ConfigEntry<int> GullibleEventMaxLvl;

	private static ConfigEntry<int> SlimeEventMaxLvl;

	private static ConfigEntry<int> SchizoEventMaxLvl;

	private static ConfigEntry<int> MaskedEventMaxLvl;

	private static ConfigEntry<int> NutcrackerEventMaxLvl;

	private static ConfigEntry<int> WeepingAngelEventMaxLvl;

	private static ConfigEntry<int> JesterEventMaxLvl;

	private static ConfigEntry<int> DangerSurfaceEventMaxLvl;

	private static ConfigEntry<int> DangerBuildingEventMaxLvl;

	private static ConfigEntry<int> DefenseTurretEventMaxLvl;

	private static ConfigEntry<int> LANDMinesEventMaxLvl;

	private static ConfigEntry<int> ArmageddonEventMaxLvl;

	private static ConfigEntry<int> WeaponsDestructionEventMaxLvl;

	private static ConfigEntry<int> StronkMonstersEventMaxLvl;

	private static ConfigEntry<string> MinesweeperEventName;

	private static ConfigEntry<string> HeavyWeaponryEventName;

	private static ConfigEntry<string> RUNEventName;

	private static ConfigEntry<string> ArachnophobiaEventName;

	private static ConfigEntry<string> BugMafiaEventName;

	private static ConfigEntry<string> LizardManiaEventName;

	private static ConfigEntry<string> BehindYouEventName;

	private static ConfigEntry<string> GullibleEventName;

	private static ConfigEntry<string> SlimeEventName;

	private static ConfigEntry<string> SchizoEventName;

	private static ConfigEntry<string> MaskedEventName;

	private static ConfigEntry<string> NutcrackerEventName;

	private static ConfigEntry<string> WeepingAngelEventName;

	private static ConfigEntry<string> JesterEventName;

	private static ConfigEntry<string> DangerSurfaceEventName;

	private static ConfigEntry<string> DangerBuildingEventName;

	private static ConfigEntry<string> DefenseTurretEventName;

	private static ConfigEntry<string> LANDMinesEventName;

	private static ConfigEntry<string> ArmageddonEventName;

	private static ConfigEntry<string> WeaponsDestructionEventName;

	private static ConfigEntry<string> StronkMonstersEventName;

	private static ConfigEntry<float> RUNEventSpawnDelay;

	private static ConfigEntry<float> ArachnophobiaEventSpawnDelay;

	private static ConfigEntry<float> BugMafiaEventSpawnDelay;

	private static ConfigEntry<float> LizardManiaEventSpawnDelay;

	private static ConfigEntry<float> BehindYouEventSpawnDelay;

	private static ConfigEntry<float> GullibleEventSpawnDelay;

	private static ConfigEntry<float> SlimeEventSpawnDelay;

	private static ConfigEntry<float> SchizoEventSpawnDelay;

	private static ConfigEntry<float> MaskedEventSpawnDelay;

	private static ConfigEntry<float> NutcrackerEventSpawnDelay;

	private static ConfigEntry<float> WeepingAngelEventSpawnDelay;

	private static ConfigEntry<float> JesterEventSpawnDelay;

	private static ConfigEntry<float> DangerSurfaceEventSpawnDelay;

	private static ConfigEntry<float> DangerBuildingEventSpawnDelay;

	private static ConfigEntry<int> RUNEventSpawnAmount;

	private static ConfigEntry<int> ArachnophobiaEventSpawnAmount;

	private static ConfigEntry<int> BugMafiaEventSpawnAmount;

	private static ConfigEntry<int> LizardManiaEventSpawnAmount;

	private static ConfigEntry<int> BehindYouEventSpawnAmount;

	private static ConfigEntry<int> GullibleEventSpawnAmount;

	private static ConfigEntry<int> SlimeEventSpawnAmount;

	private static ConfigEntry<int> SchizoEventSpawnAmount;

	private static ConfigEntry<int> MaskedEventSpawnAmount;

	private static ConfigEntry<int> NutcrackerEventSpawnAmount;

	private static ConfigEntry<int> WeepingAngelEventSpawnAmount;

	private static ConfigEntry<int> JesterEventSpawnAmount;

	private static ConfigEntry<int> DangerSurfaceEventSpawnAmount;

	private static ConfigEntry<int> DangerBuildingEventSpawnAmount;

	private static ConfigEntry<int> MinesweeperMinLandmines;

	private static ConfigEntry<int> MinesweeperMaxLandmines;

	private static ConfigEntry<int> HeavyWeaponryMinTurrets;

	private static ConfigEntry<int> HeavyWeaponryMaxTurrets;

	private static ConfigEntry<int> LANDMinesLandminesToSpawn;

	private static ConfigEntry<int> ArmageddonTurretsToSpawn;

	public static Dictionary<SelectableLevel, int> heatValues = new Dictionary<SelectableLevel, int>();

	public static List<WorldEvent> GameEvents = new List<WorldEvent>();

	public static List<SpawnableEnemyWithRarity> FoundEnemies = new List<SpawnableEnemyWithRarity>();

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

	public static SelectableLevel CurrentLevel;

	public static bool IsAtCompanyBuilding = false;

	private void Awake()
	{
		Instance = this;
		mls = Logger.CreateLogSource("Derpling.SavageCompany");
		InputClass.UIKey.performed += OnKeyPress;
		InputClass.UIKey.canceled += OnKeyUnpress;
		InputClass.UIUpKey.performed += UIUpKey_performed;
		InputClass.UIUpKey.canceled += UIUpKey_canceled;
		InputClass.UIDownKey.performed += UIDownKey_performed;
		InputClass.UIDownKey.canceled += UIDownKey_canceled;
		InputClass.UILeftKey.performed += UILeftKey_performed;
		InputClass.UILeftKey.canceled += UILeftKey_canceled;
		InputClass.UIRightKey.performed += UIRightKey_performed;
		InputClass.UIRightKey.canceled += UIRightKey_canceled;
		mls.LogInfo((object)"Savage Company is ready to tear you to shreds!");
		harmony.PatchAll(typeof(SavageCompanyBase));
		harmony.PatchAll(typeof(GamePatches));
		SetupConfig();
		LoadConfigValues();
	}

	private void UIRightKey_canceled(CallbackContext obj)
	{
		GamePatches.RightKeyHeld = false;
	}

	private void UIRightKey_performed(CallbackContext obj)
	{
		GamePatches.RightKeyHeld = true;
	}

	private void UILeftKey_canceled(CallbackContext obj)
	{
		GamePatches.LeftKeyHeld = false;
	}

	private void UILeftKey_performed(CallbackContext obj)
	{
		GamePatches.LeftKeyHeld = true;
	}

	private void UIDownKey_canceled(CallbackContext obj)
	{
		GamePatches.DownKeyHeld = false;
	}

	private void UIDownKey_performed(CallbackContext obj)
	{
		GamePatches.DownKeyHeld = true;
	}

	private void UIUpKey_canceled(CallbackContext obj)
	{
		GamePatches.UpKeyHeld = false;
	}

	private void UIUpKey_performed(CallbackContext obj)
	{
		GamePatches.UpKeyHeld = true;
	}

	private void OnKeyUnpress(CallbackContext HotkeyContext)
	{
		GamePatches.HasPressedKey = false;
	}

	private void OnKeyPress(CallbackContext HotkeyContext)
	{
		GamePatches.HasPressedKey = true;
	}

	private void LoadConfigValues()
	{
		GamePatches.DefaultHeatValue = DefaultHeatValue.Value;
		GamePatches.HeatValueIncreaseMin = HeatValueIncreaseMin.Value;
		GamePatches.HeatValueIncreaseMax = HeatValueIncreaseMax.Value;
		GamePatches.HeatValueDecrease = HeatValueDecrease.Value;
		GamePatches.MaxHeatValue = MaxHeatValue.Value;
		GamePatches.RandomPoints = RandomPoints.Value;
		GamePatches.PointsMarginBeginning = PointsMarginBeginning.Value;
		GamePatches.PointsMarginIncreaseMulti = PointsMarginIncreaseMulti.Value;
		GamePatches.MinPoints = MinPoints.Value;
		GamePatches.MaxPoints = MaxPoints.Value;
		GamePatches.FunnyPlanets = FunnyPlanets.Value;
		GamePatches.InfiniteCredits = InfiniteCredits.Value;
		GamePatches.StartingCredits = StartingCredits.Value;
		GamePatches.ScrapDensityMultiplier = ScrapDensityMultiplier.Value;
		GamePatches.TextBoxXOffset = TextBoxXOffset.Value;
		GamePatches.TextBoxYOffset = TextBoxYOffset.Value;
		GamePatches.UIIsToggle = UIIsToggle.Value;
		GamePatches.IsPercentageText = PercentageText.Value;
		GamePatches.UIHeaderFontSize = UIHeaderFontSize.Value;
		GamePatches.UIFontSize = UIFontSize.Value;
		GamePatches.DisableUI = DisableUI.Value;
		GamePatches.ClearChat = ClearChat.Value;
		GamePatches.HeatMessages = HeatMessages.Value;
		GamePatches.UITextAlignment = UITextAlignment.Value;
		GamePatches.ShowTutorialBool = ShowTutorial.Value;
		MinesweeperEvent.ConfigMinLandmines = MinesweeperMinLandmines.Value;
		MinesweeperEvent.ConfigMaxLandmines = MinesweeperMaxLandmines.Value;
		HeavyWeaponryEvent.ConfigMinTurrets = HeavyWeaponryMinTurrets.Value;
		HeavyWeaponryEvent.ConfigMaxTurrets = HeavyWeaponryMaxTurrets.Value;
		LANDMinesEvent.ConfigLandminesToSpawn = LANDMinesLandminesToSpawn.Value;
		GuardedPlanetEvent.ConfigTurretsToSpawn = ArmageddonTurretsToSpawn.Value;
		GamePatches.MinesweeperEventEnabled = MinesweeperEventEnabled.Value;
		GamePatches.HeavyWeaponryEventEnabled = HeavyWeaponryEventEnabled.Value;
		GamePatches.RUNEventEnabled = RUNEventEnabled.Value;
		GamePatches.ArachnophobiaEventEnabled = ArachnophobiaEventEnabled.Value;
		GamePatches.BugMafiaEventEnabled = BugMafiaEventEnabled.Value;
		GamePatches.LizardManiaEventEnabled = LizardManiaEventEnabled.Value;
		GamePatches.BehindYouEventEnabled = BehindYouEventEnabled.Value;
		GamePatches.GullibleEventEnabled = GullibleEventEnabled.Value;
		GamePatches.SlimeEventEnabled = SlimeEventEnabled.Value;
		GamePatches.SchizoEventEnabled = SchizoEventEnabled.Value;
		GamePatches.MaskedEventEnabled = MaskedEventEnabled.Value;
		GamePatches.NutcrackerEventEnabled = NutcrackerEventEnabled.Value;
		GamePatches.WeepingAngelEventEnabled = WeepingAngelEventEnabled.Value;
		GamePatches.JesterEventEnabled = JesterEventEnabled.Value;
		GamePatches.DangerSurfaceEventEnabled = DangerSurfaceEventEnabled.Value;
		GamePatches.DangerBuildingEventEnabled = DangerBuildingEventEnabled.Value;
		GamePatches.DefenseTurretEventEnabled = DefenseTurretEventEnabled.Value;
		GamePatches.LANDMinesEventEnabled = LANDMinesEventEnabled.Value;
		GamePatches.ArmageddonEventEnabled = ArmageddonEventEnabled.Value;
		GamePatches.WeaponsDestructionEventEnabled = WeaponsDestructionEventEnabled.Value;
		GamePatches.StronkMonstersEventEnabled = StronkMonstersEventEnabled.Value;
		MinesweeperEvent.ConfigCost = MinesweeperEventCost.Value;
		HeavyWeaponryEvent.ConfigCost = HeavyWeaponryEventCost.Value;
		ThumpThumpEvent.ConfigCost = RUNEventCost.Value;
		ArachnophobiaEvent.ConfigCost = ArachnophobiaEventCost.Value;
		BugMafiaEvent.ConfigCost = BugMafiaEventCost.Value;
		LizardManiaEvent.ConfigCost = LizardManiaEventCost.Value;
		FlowerMenEvent.ConfigCost = BehindYouEventCost.Value;
		GullibleEvent.ConfigCost = GullibleEventCost.Value;
		SlimeEvent.ConfigCost = SlimeEventCost.Value;
		SchizoEvent.ConfigCost = SchizoEventCost.Value;
		MaskedEvent.ConfigCost = MaskedEventCost.Value;
		NutcrackerEvent.ConfigCost = NutcrackerEventCost.Value;
		CoilEvent.ConfigCost = WeepingAngelEventCost.Value;
		JesterEvent.ConfigCost = JesterEventCost.Value;
		DangerSurfaceEvent.ConfigCost = DangerSurfaceEventCost.Value;
		DangerBuildingEvent.ConfigCost = DangerBuildingEventCost.Value;
		TurretDefenseEvent.ConfigCost = DefenseTurretEventCost.Value;
		LANDMinesEvent.ConfigCost = LANDMinesEventCost.Value;
		GuardedPlanetEvent.ConfigCost = ArmageddonEventCost.Value;
		WeaponsOfDestructionEvent.ConfigCost = WeaponsDestructionEventCost.Value;
		StronkMonstersEvent.ConfigCost = StronkMonstersEventCost.Value;
		MinesweeperEvent.ConfigMaxLvls = MinesweeperEventMaxLvl.Value;
		HeavyWeaponryEvent.ConfigMaxLvls = HeavyWeaponryEventMaxLvl.Value;
		ThumpThumpEvent.ConfigMaxLvls = RUNEventMaxLvl.Value;
		ArachnophobiaEvent.ConfigMaxLvls = ArachnophobiaEventMaxLvl.Value;
		BugMafiaEvent.ConfigMaxLvls = BugMafiaEventMaxLvl.Value;
		LizardManiaEvent.ConfigMaxLvls = LizardManiaEventMaxLvl.Value;
		FlowerMenEvent.ConfigMaxLvls = BehindYouEventMaxLvl.Value;
		GullibleEvent.ConfigMaxLvls = GullibleEventMaxLvl.Value;
		SlimeEvent.ConfigMaxLvls = SlimeEventMaxLvl.Value;
		SchizoEvent.ConfigMaxLvls = SchizoEventMaxLvl.Value;
		MaskedEvent.ConfigMaxLvls = MaskedEventMaxLvl.Value;
		NutcrackerEvent.ConfigMaxLvls = NutcrackerEventMaxLvl.Value;
		CoilEvent.ConfigMaxLvls = WeepingAngelEventMaxLvl.Value;
		JesterEvent.ConfigMaxLvls = JesterEventMaxLvl.Value;
		DangerSurfaceEvent.ConfigMaxLvls = DangerSurfaceEventMaxLvl.Value;
		DangerBuildingEvent.ConfigMaxLvls = DangerBuildingEventMaxLvl.Value;
		TurretDefenseEvent.ConfigMaxLvls = DefenseTurretEventMaxLvl.Value;
		LANDMinesEvent.ConfigMaxLvls = LANDMinesEventMaxLvl.Value;
		GuardedPlanetEvent.ConfigMaxLvls = ArmageddonEventMaxLvl.Value;
		WeaponsOfDestructionEvent.ConfigMaxLvls = WeaponsDestructionEventMaxLvl.Value;
		StronkMonstersEvent.ConfigMaxLvls = StronkMonstersEventMaxLvl.Value;
		MinesweeperEvent.ConfigEventName = MinesweeperEventName.Value;
		HeavyWeaponryEvent.ConfigEventName = HeavyWeaponryEventName.Value;
		ThumpThumpEvent.ConfigEventName = RUNEventName.Value;
		ArachnophobiaEvent.ConfigEventName = ArachnophobiaEventName.Value;
		BugMafiaEvent.ConfigEventName = BugMafiaEventName.Value;
		LizardManiaEvent.ConfigEventName = LizardManiaEventName.Value;
		FlowerMenEvent.ConfigEventName = BehindYouEventName.Value;
		GullibleEvent.ConfigEventName = GullibleEventName.Value;
		SlimeEvent.ConfigEventName = SlimeEventName.Value;
		SchizoEvent.ConfigEventName = SchizoEventName.Value;
		MaskedEvent.ConfigEventName = MaskedEventName.Value;
		NutcrackerEvent.ConfigEventName = NutcrackerEventName.Value;
		CoilEvent.ConfigEventName = WeepingAngelEventName.Value;
		JesterEvent.ConfigEventName = JesterEventName.Value;
		DangerSurfaceEvent.ConfigEventName = DangerSurfaceEventName.Value;
		DangerBuildingEvent.ConfigEventName = DangerBuildingEventName.Value;
		TurretDefenseEvent.ConfigEventName = DefenseTurretEventName.Value;
		LANDMinesEvent.ConfigEventName = LANDMinesEventName.Value;
		GuardedPlanetEvent.ConfigEventName = ArmageddonEventName.Value;
		WeaponsOfDestructionEvent.ConfigEventName = WeaponsDestructionEventName.Value;
		StronkMonstersEvent.ConfigEventName = StronkMonstersEventName.Value;
		ThumpThumpEvent.ConfigSpawnDelay = RUNEventSpawnDelay.Value;
		ArachnophobiaEvent.ConfigSpawnDelay = ArachnophobiaEventSpawnDelay.Value;
		BugMafiaEvent.ConfigSpawnDelay = BugMafiaEventSpawnDelay.Value;
		LizardManiaEvent.ConfigSpawnDelay = LizardManiaEventSpawnDelay.Value;
		FlowerMenEvent.ConfigSpawnDelay = BehindYouEventSpawnDelay.Value;
		GullibleEvent.ConfigSpawnDelay = GullibleEventSpawnDelay.Value;
		SlimeEvent.ConfigSpawnDelay = SlimeEventSpawnDelay.Value;
		SchizoEvent.ConfigSpawnDelay = SchizoEventSpawnDelay.Value;
		MaskedEvent.ConfigSpawnDelay = MaskedEventSpawnDelay.Value;
		NutcrackerEvent.ConfigSpawnDelay = NutcrackerEventSpawnDelay.Value;
		CoilEvent.ConfigSpawnDelay = WeepingAngelEventSpawnDelay.Value;
		JesterEvent.ConfigSpawnDelay = JesterEventSpawnDelay.Value;
		DangerSurfaceEvent.ConfigSpawnDelay = DangerSurfaceEventSpawnDelay.Value;
		DangerBuildingEvent.ConfigSpawnDelay = DangerBuildingE