Decompiled source of BrutalPalinka Modpack v1.0.2

BepInEx/plugins/BrutalCompanyPlus.dll

Decompiled 2 years ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
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 BrutalCompanyPlus.BCP;
using BrutalCompanyPlus.HarmPatches;
using GameNetcodeStuff;
using HarmonyLib;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.AI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("ExampleAssembly")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Biney")]
[assembly: AssemblyProduct("ExampleAssembly")]
[assembly: AssemblyCopyright("Copyright © Biney")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("251a7ff8-4d39-4f8b-9838-61124bf62f99")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace BrutalCompanyPlus
{
	[BepInPlugin("BrutalCompanyPlus", "BrutalCompanyPlus", "3.5.1")]
	public class Plugin : BaseUnityPlugin
	{
		public static Dictionary<EventEnum, ConfigEntry<int>> eventWeightEntries = new Dictionary<EventEnum, ConfigEntry<int>>();

		private bool brutalPlusInitialized;

		public static List<string> correctEnemyNames = new List<string>
		{
			"Centipede", "Bunker Spider", "Hoarding bug", "Flowerman", "Crawler", "Blob", "Girl", "Puffer", "Nutcracker", "Spring",
			"Jester", "Masked", "LassoMan"
		};

		private string configFilePath = Path.Combine(Paths.ConfigPath, "BrutalCompanyPlus.cfg");

		public static ConfigEntry<string> ExperimentationLevelScrap { get; private set; }

		public static ConfigEntry<string> AssuranceLevelScrap { get; private set; }

		public static ConfigEntry<string> VowLevelScrap { get; private set; }

		public static ConfigEntry<string> MarchLevelScrap { get; private set; }

		public static ConfigEntry<string> RendLevelScrap { get; private set; }

		public static ConfigEntry<string> DineLevelScrap { get; private set; }

		public static ConfigEntry<string> OffenseLevelScrap { get; private set; }

		public static ConfigEntry<string> TitanLevelScrap { get; private set; }

		public static ConfigEntry<string> CustomLevelScrap { get; private set; }

		public static ConfigEntry<bool> VanillaRaritySettings { get; private set; }

		public static ConfigEntry<float> FactoryStartOfDaySpawnChance { get; private set; }

		public static ConfigEntry<float> FactoryMidDaySpawnChance { get; private set; }

		public static ConfigEntry<float> FactoryEndOfDaySpawnChance { get; private set; }

		public static ConfigEntry<float> OutsideStartOfDaySpawnChance { get; private set; }

		public static ConfigEntry<float> OutsideMidDaySpawnChance { get; private set; }

		public static ConfigEntry<float> OutsideEndOfDaySpawnChance { get; private set; }

		public static ConfigEntry<float> MoonHeatDecreaseRate { get; private set; }

		public static ConfigEntry<float> MoonHeatIncreaseRate { get; private set; }

		public static ConfigEntry<bool> EnableTurretModifications { get; private set; }

		public static ConfigEntry<bool> EnableLandmineModifications { get; private set; }

		public static ConfigEntry<float> TurretSpawnRate { get; private set; }

		public static ConfigEntry<float> LandmineSpawnRate { get; private set; }

		public static ConfigEntry<string> ExperimentationLevelRarities { get; private set; }

		public static ConfigEntry<string> AssuranceLevelRarities { get; private set; }

		public static ConfigEntry<string> VowLevelRarities { get; private set; }

		public static ConfigEntry<string> MarchLevelRarities { get; private set; }

		public static ConfigEntry<string> RendLevelRarities { get; private set; }

		public static ConfigEntry<string> DineLevelRarities { get; private set; }

		public static ConfigEntry<string> OffenseLevelRarities { get; private set; }

		public static ConfigEntry<string> TitanLevelRarities { get; private set; }

		public static ConfigEntry<bool> EnableFreeMoney { get; private set; }

		public static ConfigEntry<int> FreeMoneyValue { get; private set; }

		public static ConfigEntry<bool> EnableAllEnemy { get; private set; }

		public static ConfigEntry<int> DeadlineDaysAmount { get; private set; }

		public static ConfigEntry<int> StartingCredits { get; private set; }

		public static ConfigEntry<int> StartingQuota { get; private set; }

		public static ConfigEntry<float> BaseIncrease { get; private set; }

		public static ConfigEntry<int> MinScrap { get; private set; }

		public static ConfigEntry<int> MaxScrap { get; private set; }

		public static ConfigEntry<int> MinTotalScrapValue { get; private set; }

		public static ConfigEntry<int> MaxTotalScrapValue { get; private set; }

		private void Awake()
		{
			InitializeVariables();
			SetupPatches();
			InitializeBCP_ConfigSettings();
			InitializeDefaultEnemyRarities();
			UpdateConfigurations();
			RemoveConfigSection(configFilePath, "EventEnabledConfig");
			RemoveConfigSection(configFilePath, "EnemySpawnSettings.Factory");
			RemoveConfigSection(configFilePath, "EnemySpawnSettings.Outside");
			RemoveConfigLines(configFilePath, "Chaos", "BadPlanet");
		}

		private void Start()
		{
			if (!brutalPlusInitialized)
			{
				CreateBrutalPlusGameObject();
				brutalPlusInitialized = true;
			}
		}

		private void OnDestroy()
		{
			if (!brutalPlusInitialized)
			{
				CreateBrutalPlusGameObject();
				brutalPlusInitialized = true;
			}
		}

		public static void UpdateConfigurations()
		{
			foreach (ConfigEntry<string> item in new List<ConfigEntry<string>> { ExperimentationLevelRarities, AssuranceLevelRarities, VowLevelRarities, MarchLevelRarities, RendLevelRarities, DineLevelRarities, OffenseLevelRarities, TitanLevelRarities })
			{
				Dictionary<string, string> dictionary = ParseConfigRarities(item.Value);
				List<string> list = new List<string>();
				foreach (string correctEnemyName in correctEnemyNames)
				{
					string value;
					string text = (dictionary.TryGetValue(correctEnemyName, out value) ? value : "-1");
					list.Add(correctEnemyName + ":" + text);
				}
				string text2 = string.Join(",", list);
				if (item.Value != text2)
				{
					item.Value = text2;
					BcpLogger.Log("Updated configuration for " + ((ConfigEntryBase)item).Definition.Section + ", " + ((ConfigEntryBase)item).Definition.Key + ": " + text2);
				}
			}
		}

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

		public void RemoveConfigLines(string filePath, params string[] variableNames)
		{
			try
			{
				List<string> list = File.ReadAllLines(filePath).ToList();
				List<string> list2 = new List<string>();
				foreach (string line in list)
				{
					if (!variableNames.Any((string variableName) => line.Trim().StartsWith(variableName + " =")))
					{
						list2.Add(line);
					}
				}
				File.WriteAllLines(filePath, list2);
			}
			catch (Exception ex)
			{
				BcpLogger.Log("Error occurred: " + ex.Message);
			}
		}

		public void RemoveConfigSection(string filePath, string sectionName)
		{
			try
			{
				List<string> list = File.ReadAllLines(filePath).ToList();
				List<string> list2 = new List<string>();
				bool flag = false;
				foreach (string item in list)
				{
					if (item.Trim().Equals("[" + sectionName + "]"))
					{
						flag = true;
						continue;
					}
					if (flag && item.StartsWith("["))
					{
						flag = false;
					}
					if (!flag)
					{
						list2.Add(item);
					}
				}
				File.WriteAllLines(filePath, list2);
			}
			catch (Exception ex)
			{
				BcpLogger.Log("Error occurred: " + ex.Message);
			}
		}

		public static void InitializeDefaultEnemyRarities()
		{
			Dictionary<string, int> value = new Dictionary<string, int>
			{
				{ "Centipede", 50 },
				{ "Bunker Spider", 75 },
				{ "Hoarding bug", 80 },
				{ "Flowerman", 30 },
				{ "Crawler", 15 },
				{ "Blob", 25 },
				{ "Girl", 2 },
				{ "Puffer", 10 },
				{ "Nutcracker", 15 },
				{ "Spring", 5 },
				{ "Jester", 1 },
				{ "Masked", 1 },
				{ "LassoMan", 1 }
			};
			Variables.DefaultEnemyRarities["ExperimentationLevel"] = value;
			Dictionary<string, int> value2 = new Dictionary<string, int>
			{
				{ "Centipede", 50 },
				{ "Bunker Spider", 40 },
				{ "Hoarding bug", 50 },
				{ "Flowerman", 30 },
				{ "Crawler", 15 },
				{ "Blob", 25 },
				{ "Girl", 2 },
				{ "Puffer", 40 },
				{ "Nutcracker", 15 },
				{ "Spring", 25 },
				{ "Jester", 3 },
				{ "Masked", 3 },
				{ "LassoMan", 1 }
			};
			Variables.DefaultEnemyRarities["AssuranceLevel"] = value2;
			Dictionary<string, int> value3 = new Dictionary<string, int>
			{
				{ "Centipede", 50 },
				{ "Bunker Spider", 40 },
				{ "Hoarding bug", 50 },
				{ "Flowerman", 30 },
				{ "Crawler", 20 },
				{ "Blob", 25 },
				{ "Girl", 5 },
				{ "Puffer", 40 },
				{ "Nutcracker", 20 },
				{ "Spring", 40 },
				{ "Jester", 15 },
				{ "Masked", 10 },
				{ "LassoMan", 0 }
			};
			Variables.DefaultEnemyRarities["VowLevel"] = value3;
			Dictionary<string, int> value4 = new Dictionary<string, int>
			{
				{ "Centipede", 50 },
				{ "Bunker Spider", 40 },
				{ "Hoarding bug", 50 },
				{ "Flowerman", 30 },
				{ "Crawler", 20 },
				{ "Blob", 25 },
				{ "Girl", 5 },
				{ "Puffer", 40 },
				{ "Nutcracker", 20 },
				{ "Spring", 40 },
				{ "Jester", 15 },
				{ "Masked", 10 },
				{ "LassoMan", 0 }
			};
			Variables.DefaultEnemyRarities["OffenseLevel"] = value4;
			Dictionary<string, int> value5 = new Dictionary<string, int>
			{
				{ "Centipede", 50 },
				{ "Bunker Spider", 40 },
				{ "Hoarding bug", 50 },
				{ "Flowerman", 30 },
				{ "Crawler", 20 },
				{ "Blob", 25 },
				{ "Girl", 10 },
				{ "Puffer", 40 },
				{ "Nutcracker", 20 },
				{ "Spring", 40 },
				{ "Jester", 15 },
				{ "Masked", 10 },
				{ "LassoMan", 0 }
			};
			Variables.DefaultEnemyRarities["MarchLevel"] = value5;
			Dictionary<string, int> value6 = new Dictionary<string, int>
			{
				{ "Centipede", 35 },
				{ "Bunker Spider", 25 },
				{ "Hoarding bug", 30 },
				{ "Flowerman", 56 },
				{ "Crawler", 50 },
				{ "Blob", 40 },
				{ "Girl", 25 },
				{ "Puffer", 40 },
				{ "Nutcracker", 30 },
				{ "Spring", 58 },
				{ "Jester", 40 },
				{ "Masked", 10 },
				{ "LassoMan", 2 }
			};
			Variables.DefaultEnemyRarities["RendLevel"] = value6;
			Dictionary<string, int> value7 = new Dictionary<string, int>
			{
				{ "Centipede", 35 },
				{ "Bunker Spider", 25 },
				{ "Hoarding bug", 30 },
				{ "Flowerman", 56 },
				{ "Crawler", 50 },
				{ "Blob", 40 },
				{ "Girl", 25 },
				{ "Puffer", 40 },
				{ "Nutcracker", 30 },
				{ "Spring", 58 },
				{ "Jester", 40 },
				{ "Masked", 10 },
				{ "LassoMan", 2 }
			};
			Variables.DefaultEnemyRarities["DineLevel"] = value7;
			Dictionary<string, int> value8 = new Dictionary<string, int>
			{
				{ "Centipede", 35 },
				{ "Bunker Spider", 25 },
				{ "Hoarding bug", 30 },
				{ "Flowerman", 56 },
				{ "Crawler", 60 },
				{ "Blob", 40 },
				{ "Girl", 25 },
				{ "Puffer", 40 },
				{ "Nutcracker", 30 },
				{ "Spring", 58 },
				{ "Jester", 40 },
				{ "Masked", 10 },
				{ "LassoMan", 2 }
			};
			Variables.DefaultEnemyRarities["TitanLevel"] = value8;
		}

		public void InitializeBCP_ConfigSettings()
		{
			ExperimentationLevelScrap = ((BaseUnityPlugin)this).Config.Bind<string>("CustomScrapSettings", "ExperimentationLevelScrap", "6,25,400,1500", "Define min/max scrap pieces and min/max total scrap value for Experimentation Level ( -1 = Vanilla Value )");
			AssuranceLevelScrap = ((BaseUnityPlugin)this).Config.Bind<string>("CustomScrapSettings", "AssuranceLevelScrap", "10,25,600,2500", "Define min/max scrap pieces and min/max total scrap value for Assurance Level ( -1 = Vanilla Value )");
			VowLevelScrap = ((BaseUnityPlugin)this).Config.Bind<string>("CustomScrapSettings", "VowLevelScrap", "12,35,600,2500", "Define min/max scrap pieces and min/max total scrap value for Vow Level ( -1 = Vanilla Value )");
			OffenseLevelScrap = ((BaseUnityPlugin)this).Config.Bind<string>("CustomScrapSettings", "OffenseLevelScrap", "15,35,800,3500", "Define min/max scrap pieces and min/max total scrap value for Offense Level ( -1 = Vanilla Value )");
			MarchLevelScrap = ((BaseUnityPlugin)this).Config.Bind<string>("CustomScrapSettings", "MarchLevelScrap", "15,35,800,3500", "Define min/max scrap pieces and min/max total scrap value for March Level ( -1 = Vanilla Value )");
			RendLevelScrap = ((BaseUnityPlugin)this).Config.Bind<string>("CustomScrapSettings", "RendLevelScrap", "20,60,1500,5000", "Define min/max scrap pieces and min/max total scrap value for Rend Level ( -1 = Vanilla Value )");
			DineLevelScrap = ((BaseUnityPlugin)this).Config.Bind<string>("CustomScrapSettings", "DineScrap", "20,60,1500,5000", "Define min/max scrap pieces and min/max total scrap value for Dine Level ( -1 = Vanilla Value )");
			TitanLevelScrap = ((BaseUnityPlugin)this).Config.Bind<string>("CustomScrapSettings", "TitanLevelScrap", "20,60,2000,6000", "Define min/max scrap pieces and min/max total scrap value for Titan Level ( -1 = Vanilla Value )");
			CustomLevelScrap = ((BaseUnityPlugin)this).Config.Bind<string>("CustomScrapSettings", "CustomLevelScrap", "-1,-1,-1,-1", "Define min/max scrap pieces and min/max total scrap value for Any Custom Levels ( -1 = Vanilla Value )");
			MoonHeatDecreaseRate = ((BaseUnityPlugin)this).Config.Bind<float>("MoonHeatSettings", "MoonHeatDecreaseRate", 10f, "Amount by which moon heat decreases when not visiting the planet");
			MoonHeatIncreaseRate = ((BaseUnityPlugin)this).Config.Bind<float>("MoonHeatSettings", "MoonHeatIncreaseRate", 20f, "Amount by which moon heat increases when landing back on the same planet");
			EnableTurretModifications = ((BaseUnityPlugin)this).Config.Bind<bool>("MapObjectModificationSettings", "EnableTurretModifications", true, "Enable modifications to turret spawn rates on every moon, False would default to game logic");
			TurretSpawnRate = ((BaseUnityPlugin)this).Config.Bind<float>("MapObjectModificationSettings", "TurretSpawnRate", 8f, "Default spawn amount for turrets on every moon");
			EnableLandmineModifications = ((BaseUnityPlugin)this).Config.Bind<bool>("MapObjectModificationSettings", "EnableLandmineModifications", true, "Enable modifications to landmine spawn rates on every moon, False would default to game logic");
			LandmineSpawnRate = ((BaseUnityPlugin)this).Config.Bind<float>("MapObjectModificationSettings", "LandmineSpawnRate", 30f, "Default spawn amount for landmines on every moon");
			VanillaRaritySettings = ((BaseUnityPlugin)this).Config.Bind<bool>("CustomLevelRarities", "VanillaRaritySettings", false, "If TRUE this will DISABLE overwriting Rarity Values for Factory Enemies");
			ExperimentationLevelRarities = ((BaseUnityPlugin)this).Config.Bind<string>("CustomLevelRarities", "Experimentation", "Centipede:-1,Bunker Spider:-1,Hoarding bug:-1,Flowerman:-1,Crawler:-1,Blob:-1,Girl:-1,Puffer:-1,Nutcracker:-1,Spring:-1,Jester:-1,Masked:-1,LassoMan:-1", "Define custom enemy rarities for Experimentation (0 = no spawn, 100 = max chance, -1 = default Brutals rarity, The spawn rate will also be impacted depnding on the Chance rate)");
			AssuranceLevelRarities = ((BaseUnityPlugin)this).Config.Bind<string>("CustomLevelRarities", "Assurance", "Centipede:-1,Bunker Spider:-1,Hoarding bug:-1,Flowerman:-1,Crawler:-1,Blob:-1,Girl:-1,Puffer:-1,Nutcracker:-1,Spring:-1,Jester:-1,Masked:-1,LassoMan:-1", "Define custom enemy rarities for Assurance (0 = no spawn, 100 = max chance, -1 = default Brutals rarity, The spawn rate will also be impacted depnding on the Chance rate)");
			VowLevelRarities = ((BaseUnityPlugin)this).Config.Bind<string>("CustomLevelRarities", "Vow", "Centipede:-1,Bunker Spider:-1,Hoarding bug:-1,Flowerman:-1,Crawler:-1,Blob:-1,Girl:-1,Puffer:-1,Nutcracker:-1,Spring:-1,Jester:-1,Masked:-1,LassoMan:-1", "Define custom enemy rarities for Vow (0 = no spawn, 100 = max chance, -1 = default Brutals rarity, The spawn rate will also be impacted depnding on the Chance rate)");
			MarchLevelRarities = ((BaseUnityPlugin)this).Config.Bind<string>("CustomLevelRarities", "March", "Centipede:-1,Bunker Spider:-1,Hoarding bug:-1,Flowerman:-1,Crawler:-1,Blob:-1,Girl:-1,Puffer:-1,Nutcracker:-1,Spring:-1,Jester:-1,Masked:-1,LassoMan:-1", "Define custom enemy rarities for March (0 = no spawn, 100 = max chance, -1 = default Brutals rarity, The spawn rate will also be impacted depnding on the Chance rate)");
			RendLevelRarities = ((BaseUnityPlugin)this).Config.Bind<string>("CustomLevelRarities", "Rend", "Centipede:-1,Bunker Spider:-1,Hoarding bug:-1,Flowerman:-1,Crawler:-1,Blob:-1,Girl:-1,Puffer:-1,Nutcracker:-1,Spring:-1,Jester:-1,Masked:-1,LassoMan:-1", "Define custom enemy rarities for Rend (0 = no spawn, 100 = max chance, -1 = default Brutals rarity, The spawn rate will also be impacted depnding on the Chance rate)");
			DineLevelRarities = ((BaseUnityPlugin)this).Config.Bind<string>("CustomLevelRarities", "Dine", "Centipede:-1,Bunker Spider:-1,Hoarding bug:-1,Flowerman:-1,Crawler:-1,Blob:-1,Girl:-1,Puffer:-1,Nutcracker:-1,Spring:-1,Jester:-1,Masked:-1,LassoMan:-1", "Define custom enemy rarities for Dine (0 = no spawn, 100 = max chance, -1 = default Brutals rarity, The spawn rate will also be impacted depnding on the Chance rate)");
			OffenseLevelRarities = ((BaseUnityPlugin)this).Config.Bind<string>("CustomLevelRarities", "Offense", "Centipede:-1,Bunker Spider:-1,Hoarding bug:-1,Flowerman:-1,Crawler:-1,Blob:-1,Girl:-1,Puffer:-1,Nutcracker:-1,Spring:-1,Jester:-1,Masked:-1,LassoMan:-1", "Define custom enemy rarities for Offense (0 = no spawn, 100 = max chance, -1 = default Brutals rarity, The spawn rate will also be impacted depnding on the Chance rate)");
			TitanLevelRarities = ((BaseUnityPlugin)this).Config.Bind<string>("CustomLevelRarities", "Titan", "Centipede:-1,Bunker Spider:-1,Hoarding bug:-1,Flowerman:-1,Crawler:-1,Blob:-1,Girl:-1,Puffer:-1,Nutcracker:-1,Spring:-1,Jester:-1,Masked:-1,LassoMan:-1", "Define custom enemy rarities for Titan (0 = no spawn, 100 = max chance, -1 = default Brutals rarity, The spawn rate will also be impacted depnding on the Chance rate)");
			EnableFreeMoney = ((BaseUnityPlugin)this).Config.Bind<bool>("EventOptions", "EnableFreeMoney", true, "This will give free money everytime survive and escape the planet");
			FreeMoneyValue = ((BaseUnityPlugin)this).Config.Bind<int>("EventOptions", "FreeMoneyValue", 150, "This will control the amount of money you get when EnableFreeMoney is true");
			EnableAllEnemy = ((BaseUnityPlugin)this).Config.Bind<bool>("EnemySettings", "EnableAllEnemy", true, "This will add every vanilla enemy type to each moon as a spawn chance");
			DeadlineDaysAmount = ((BaseUnityPlugin)this).Config.Bind<int>("QuotaSettings", "DeadlineDaysAmount", 4, "Days available before deadline");
			StartingCredits = ((BaseUnityPlugin)this).Config.Bind<int>("QuotaSettings", "StartingCredits", 200, "Credits at the start of a new session");
			StartingQuota = ((BaseUnityPlugin)this).Config.Bind<int>("QuotaSettings", "StartingQuota", 400, "Starting quota amount in a new session");
			BaseIncrease = ((BaseUnityPlugin)this).Config.Bind<float>("QuotaSettings", "BaseIncrease", 275f, "Quota increase after meeting the previous quota");
			MinScrap = ((BaseUnityPlugin)this).Config.Bind<int>("ScrapSettings", "MinScrap", 10, "Minimum scraps that can spawn on each moon");
			MaxScrap = ((BaseUnityPlugin)this).Config.Bind<int>("ScrapSettings", "MaxScrap", 40, "Maximum scraps that can spawn on each moon");
			MinTotalScrapValue = ((BaseUnityPlugin)this).Config.Bind<int>("ScrapSettings", "MinTotalScrapValue", 600, "Minimum total scrap value on the moon");
			MaxTotalScrapValue = ((BaseUnityPlugin)this).Config.Bind<int>("ScrapSettings", "MaxTotalScrapValue", 5000, "Maximum total scrap value on the moon");
			eventWeightEntries[EventEnum.None] = ((BaseUnityPlugin)this).Config.Bind<int>("EventChanceConfig", "None", 100, "[Nothing Happened Today] Nothing special will happen (Set Chance between 0 - 100)");
			eventWeightEntries[EventEnum.Turret] = ((BaseUnityPlugin)this).Config.Bind<int>("EventChanceConfig", "Turret", 100, "[Turret Terror] This will spawn turrets all over the place inside the factory (Set Chance between 0 - 100)");
			eventWeightEntries[EventEnum.Delivery] = ((BaseUnityPlugin)this).Config.Bind<int>("EventChanceConfig", "Delivery", 100, "[ICE SCREAM] This will order between 3 - 9 random items from the shop (Set Chance between 0 - 100)");
			eventWeightEntries[EventEnum.BlobEvolution] = ((BaseUnityPlugin)this).Config.Bind<int>("EventChanceConfig", "BlobEvolution", 100, "[They have EVOLVED] This will spawn Blobs inside and 1 outside and they can open doors and move much faster (Set Chance between 0 - 100)");
			eventWeightEntries[EventEnum.Guards] = ((BaseUnityPlugin)this).Config.Bind<int>("EventChanceConfig", "Guards", 100, "[They gaurd this place] this will spawn nutcrackers outside (Set Chance between 0 -100)");
			eventWeightEntries[EventEnum.SurfaceExplosion] = ((BaseUnityPlugin)this).Config.Bind<int>("EventChanceConfig", "SurfaceExplosion", 100, "[The Surface is explosive] Mines wills spawn at the feet of players not in the ship or factory, they also have a delayed fuse (Set Chance between 0 - 100)");
			eventWeightEntries[EventEnum.FaceHuggers] = ((BaseUnityPlugin)this).Config.Bind<int>("EventChanceConfig", "FaceHuggers", 100, "[Bring a shovel] This will spawn MANY Centipedes into the factory (Set Chance between 0 - 100)");
			eventWeightEntries[EventEnum.TheRumbling] = ((BaseUnityPlugin)this).Config.Bind<int>("EventChanceConfig", "TheRumbling", 100, "[The Rumbling] This will spawn MANY Forest Giants when the ship has fully landed (Set Chance between 0 - 100)");
			eventWeightEntries[EventEnum.TheyWant2Play] = ((BaseUnityPlugin)this).Config.Bind<int>("EventChanceConfig", "TheyWant2Play", 100, "[The just want to play] This will spawn several Ghost girls into the level (Set Chance between 0 - 100)");
			eventWeightEntries[EventEnum.BeastInside] = ((BaseUnityPlugin)this).Config.Bind<int>("EventChanceConfig", "BeastInside", 100, "[The Beasts Inside] This will spawn Eyeless Dogs into the Factory, spawn rate changes depending on moon (Set Chance between 0 - 100)");
			eventWeightEntries[EventEnum.ShadowRealm] = ((BaseUnityPlugin)this).Config.Bind<int>("EventChanceConfig", "ShadowRealm", 100, "[The shadows are roaming] This will spawn several bracken outside along with a chance of Fog (Set Chance between 0 - 100)");
			eventWeightEntries[EventEnum.Unfair] = ((BaseUnityPlugin)this).Config.Bind<int>("EventChanceConfig", "Unfair", 100, "[UNFAIR COMPANY] This will spawn several outside enemies and inside enemies at a significant rate (Set Chance between 0 - 100)");
			eventWeightEntries[EventEnum.OutsideBox] = ((BaseUnityPlugin)this).Config.Bind<int>("EventChanceConfig", "OutsideBox", 100, "[Outside the box] This will spawn Jesters Outside (Set Chance between 0 - 100)");
			eventWeightEntries[EventEnum.InstaJester] = ((BaseUnityPlugin)this).Config.Bind<int>("EventChanceConfig", "InstaJester", 100, "[Pop goes the... HOLY FUC-] This will spawn several jesters that have a short crank timer between 0 - 10 seconds instead of 30 - 45 seconds (Set Chance between 0 - 100)");
			eventWeightEntries[EventEnum.InsideOut] = ((BaseUnityPlugin)this).Config.Bind<int>("EventChanceConfig", "InsideOut", 100, "[Spring Escape] This will spawn Coil heads outside, they will instantly roam around the ship (Set Chance between 0 - 100)");
			eventWeightEntries[EventEnum.Landmine] = ((BaseUnityPlugin)this).Config.Bind<int>("EventChanceConfig", "Landmine", 100, "[Minescape Terror] This will spawn MANY landmines inside the factory (Set Chance between 0 - 100)");
			eventWeightEntries[EventEnum.Sacrifice] = ((BaseUnityPlugin)this).Config.Bind<int>("EventChanceConfig", "Sacrifice", 100, "[The Hunger Games?] This will rotate through players at a given rate, when the selected player steps inside the factory.. They get choosen for death. (Set Chance between 0 - 100)");
			eventWeightEntries[EventEnum.ShipTurret] = ((BaseUnityPlugin)this).Config.Bind<int>("EventChanceConfig", "ShipTurret", 100, "[When did we get this installed?!?] This will spawn a turret inside the ship facing the controls (Set Chance between 0 - 100)");
			eventWeightEntries[EventEnum.HoardTown] = ((BaseUnityPlugin)this).Config.Bind<int>("EventChanceConfig", "HoardTown", 100, "[Hoarder Town] This will spawn MANY Hoarder Bugs inside the factory and outside (Set Chance between 0 - 100)");
			eventWeightEntries[EventEnum.TheyAreShy] = ((BaseUnityPlugin)this).Config.Bind<int>("EventChanceConfig", "TheyAreShy", 100, "[Don't look... away!] This spawn several Spring Heads and Brackens inside & outside the factory (Set Chance between 0 - 100)");
			eventWeightEntries[EventEnum.ResetHeat] = ((BaseUnityPlugin)this).Config.Bind<int>("EventChanceConfig", "ResetHeat", 100, "[All Moons Heat Reset] This will reset the moon heat for all moons (Set Chance between 0 - 100)");
		}

		private void InitializeVariables()
		{
			Variables.mls = Logger.CreateLogSource("BrutalCompanyPlus");
			Variables.mls.LogWarning((object)"Loaded Brutal Company Plus and applying patches.");
			Variables.mls = ((BaseUnityPlugin)this).Logger;
			Variables.levelHeatVal = new Dictionary<SelectableLevel, float>();
			Variables.enemyRaritys = new Dictionary<SpawnableEnemyWithRarity, int>();
			Variables.levelEnemySpawns = new Dictionary<SelectableLevel, List<SpawnableEnemyWithRarity>>();
			Variables.enemyPropCurves = new Dictionary<SpawnableEnemyWithRarity, AnimationCurve>();
		}

		private void SetupPatches()
		{
			Variables._harmony.PatchAll(typeof(LevelEventsPatches));
			Variables._harmony.PatchAll(typeof(QuotaPatches));
			Variables._harmony.PatchAll(typeof(EnemyAIPatches));
		}

		private void CreateBrutalPlusGameObject()
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Expected O, but got Unknown
			try
			{
				Variables.mls.LogInfo((object)"Attempting to Initialize BrutalPlus");
				GameObject val = new GameObject("BrutalPlus");
				val.SetActive(true);
				((Behaviour)val.AddComponent<BrutalPlus>()).enabled = true;
				Object.DontDestroyOnLoad((Object)val);
				Variables.loaded = true;
			}
			catch (Exception ex)
			{
				Variables.mls.LogInfo((object)("Exception in CreateBrutalPlusGameObject: " + ex.Message));
				BcpLogger.Log("Exception in CreateBrutalPlusGameObject: " + ex.Message);
			}
		}

		public static void CleanupAndResetAI()
		{
			Functions.CleanUpAllVariables();
			BrutalPlus.CleanupAllSpawns();
		}

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

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

		public static EventEnum SelectRandomEvent()
		{
			var list = (from kvp in eventWeightEntries
				where kvp.Value.Value > 0
				select new
				{
					Event = kvp.Key,
					Weight = kvp.Value.Value
				}).ToList();
			if (list.Count == 0)
			{
				return EventEnum.None;
			}
			int num = list.Sum(e => e.Weight);
			int num2 = Random.Range(0, num);
			int num3 = 0;
			foreach (var item in list)
			{
				num3 += item.Weight;
				if (num2 < num3)
				{
					Variables.lastEvent = item.Event;
					return item.Event;
				}
			}
			return EventEnum.None;
		}

		public static void ApplyCustomLevelEnemyRarities(List<SpawnableEnemyWithRarity> enemies, string levelName)
		{
			if (VanillaRaritySettings.Value)
			{
				return;
			}
			try
			{
				BcpLogger.Log("Applying custom rarities for level: " + levelName);
				ConfigEntry<string> configForLevel = GetConfigForLevel(levelName);
				BcpLogger.Log("Config for level " + levelName + ": " + configForLevel?.Value);
				if (configForLevel == null || string.IsNullOrWhiteSpace(configForLevel.Value))
				{
					BcpLogger.Log("No custom config found or config is empty for level " + levelName + ". Using default rarities.");
					return;
				}
				Dictionary<string, int> dictionary = (from r in configForLevel.Value.Split(new char[1] { ',' })
					select r.Split(new char[1] { ':' }) into r
					where r.Length == 2
					select r).ToDictionary((string[] r) => r[0].Trim(), (string[] r) => int.Parse(r[1]));
				if (!Variables.DefaultEnemyRarities.TryGetValue(levelName, out var value))
				{
					BcpLogger.Log("No default rarities found for level " + levelName);
					return;
				}
				foreach (SpawnableEnemyWithRarity enemy in enemies)
				{
					int value4;
					if (dictionary.TryGetValue(enemy.enemyType.enemyName, out var value2))
					{
						int value3;
						if (value2 != -1)
						{
							BcpLogger.Log($"Setting custom rarity for {enemy.enemyType.enemyName} to {value2}");
							enemy.rarity = value2;
						}
						else if (value.TryGetValue(enemy.enemyType.enemyName, out value3))
						{
							BcpLogger.Log($"Using default rarity for {enemy.enemyType.enemyName}: {value3}");
							enemy.rarity = value3;
						}
					}
					else if (value.TryGetValue(enemy.enemyType.enemyName, out value4))
					{
						BcpLogger.Log($"No custom rarity for {enemy.enemyType.enemyName}. Using default rarity: {value4}");
						enemy.rarity = value4;
					}
					else
					{
						BcpLogger.Log("No rarity information found for " + enemy.enemyType.enemyName + ". Skipping.");
					}
				}
			}
			catch (Exception ex)
			{
				BcpLogger.Log("Exception in ApplyCustomLevelEnemyRarities: " + ex.ToString());
			}
		}

		private static ConfigEntry<string> GetConfigForLevel(string levelName)
		{
			return (ConfigEntry<string>)(levelName switch
			{
				"ExperimentationLevel" => ExperimentationLevelRarities, 
				"AssuranceLevel" => AssuranceLevelRarities, 
				"VowLevel" => VowLevelRarities, 
				"MarchLevel" => MarchLevelRarities, 
				"RendLevel" => RendLevelRarities, 
				"DineLevel" => DineLevelRarities, 
				"OffenseLevel" => OffenseLevelRarities, 
				"TitanLevel" => TitanLevelRarities, 
				_ => null, 
			});
		}

		public static void UpdateLevelEnemies(SelectableLevel newLevel, float MoonHeat)
		{
			if (Variables.levelEnemySpawns.TryGetValue(newLevel, out var value))
			{
				ApplyCustomLevelEnemyRarities(value, ((Object)newLevel).name);
				newLevel.Enemies = value;
			}
		}

		public static void InitializeLevelHeatValues(SelectableLevel newLevel)
		{
			if (!Variables.levelHeatVal.ContainsKey(newLevel))
			{
				Variables.levelHeatVal.Add(newLevel, 0f);
			}
			if (Variables.levelEnemySpawns.ContainsKey(newLevel))
			{
				return;
			}
			List<SpawnableEnemyWithRarity> list = new List<SpawnableEnemyWithRarity>();
			foreach (SpawnableEnemyWithRarity enemy in newLevel.Enemies)
			{
				list.Add(enemy);
			}
			Variables.levelEnemySpawns.Add(newLevel, list);
		}

		public static void AdjustHeatValuesForAllLevels(EventEnum eventEnum, SelectableLevel newLevel)
		{
			foreach (SelectableLevel item in Variables.levelHeatVal.Keys.ToList())
			{
				if ((Object)(object)newLevel != (Object)(object)item)
				{
					Variables.levelHeatVal.TryGetValue(item, out var value);
					Variables.levelHeatVal[item] = Mathf.Clamp(value - MoonHeatDecreaseRate.Value, 0f, 100f);
				}
				if (eventEnum == EventEnum.ResetHeat)
				{
					Variables.levelHeatVal[item] = 0f;
				}
			}
		}

		public static float DisplayHeatMessages(SelectableLevel newLevel)
		{
			Variables.levelHeatVal.TryGetValue(newLevel, out var value);
			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", -1);
			HUDManager.Instance.AddTextToChatOnServer("<color=orange>MOON IS AT " + value + "% HEAT</color>", -1);
			if (value >= 20f && value < 40f)
			{
				HUDManager.Instance.AddTextToChatOnServer("<size=11><color=blue>Moonheat is rising and caused it to rain. <color=white>\nVisit other moons to decrease your moon heat!</color></size>", -1);
			}
			if (value >= 40f && value < 60f)
			{
				HUDManager.Instance.AddTextToChatOnServer("<size=11><color=purple>Moonheat is rising causing a layer of fog. <color=white>\nVisit other moons to decrease your moon heat!</color></size>", -1);
			}
			if (value >= 60f && value < 80f)
			{
				HUDManager.Instance.AddTextToChatOnServer("<size=11><color=yellow>Moonheat is HOT, flooding the moon to cool it off. <color=white>\nVisit other moons to decrease your moon heat!</color></size>", -1);
			}
			if (value >= 80f && value < 100f)
			{
				HUDManager.Instance.AddTextToChatOnServer("<size=11><color=orange>Extremely high moonheat detected causing dangerous weather. <color=white>\nVisit other moons to decrease your moon heat!</color></size>", -1);
			}
			if (value >= 100f)
			{
				HUDManager.Instance.AddTextToChatOnServer("<size=11><color=red>The Moon is overheated and now hostile creatures roam it. <color=white>\nVisit other moons to decrease your moon heat!</color></size>", -1);
			}
			return value;
		}

		public static void HandleEventSpecificAdjustments(EventEnum eventEnum, SelectableLevel newLevel)
		{
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			if (newLevel.sceneName == "CompanyBuilding")
			{
				HUDManager.Instance.AddTextToChatOnServer("<color=green>Welcome to the Company Buidling!</color>", -1);
				return;
			}
			switch (eventEnum)
			{
			case EventEnum.None:
				HUDManager.Instance.AddTextToChatOnServer("<color=yellow>EVENT<color=white>:</color></color>\n<color=green>Nothing Happened Today!</color>", -1);
				break;
			case EventEnum.Turret:
				HUDManager.Instance.AddTextToChatOnServer("<color=yellow>EVENT<color=white>:</color></color>\n<color=red>Turret Terror</color>", -1);
				break;
			case EventEnum.Landmine:
				HUDManager.Instance.AddTextToChatOnServer("<color=yellow>EVENT<color=white>:</color></color>\n<color=red>Minescape Terror</color>", -1);
				break;
			case EventEnum.InsideOut:
				HUDManager.Instance.AddTextToChatOnServer("<color=yellow>EVENT<color=white>:</color></color>\n<color=red>Spring Escape!</color>", -1);
				Variables.SpawnInsideOut = true;
				break;
			case EventEnum.HoardTown:
				HUDManager.Instance.AddTextToChatOnServer("<color=yellow>EVENT<color=white>:</color></color>\n<color=red>Hoarder Town</color>", -1);
				Variables.presetEnemiesToSpawn.Add(new Variables.EnemySpawnInfo(typeof(HoarderBugAI), 8, SpawnLocation.Vent, forceinside: false, forceoutside: false));
				Variables.presetEnemiesToSpawn.Add(new Variables.EnemySpawnInfo(typeof(HoarderBugAI), 8, SpawnLocation.Outside, forceinside: false, forceoutside: true));
				break;
			case EventEnum.ShadowRealm:
			{
				string text = "";
				if (Random.Range(0, 1) == 1)
				{
					newLevel.currentWeather = (LevelWeatherType)3;
					text = "in the mist!";
				}
				HUDManager.Instance.AddTextToChatOnServer("<color=yellow>EVENT<color=white>:</color></color>\n<color=red>The shadows are roaming " + text + "</color>", -1);
				Variables.presetEnemiesToSpawn.Add(new Variables.EnemySpawnInfo(typeof(FlowermanAI), 6, SpawnLocation.Outside, forceinside: false, forceoutside: true));
				break;
			}
			case EventEnum.BeastInside:
				HUDManager.Instance.AddTextToChatOnServer("<color=yellow>EVENT<color=white>:</color></color>\n<color=red>The Beasts Inside!</color>", -1);
				Functions.TheBeastsInside();
				break;
			case EventEnum.TheRumbling:
				HUDManager.Instance.AddTextToChatOnServer("<color=yellow>EVENT<color=white>:</color></color>\n<color=red>The Rumbling!</color>", -1);
				Functions.TheRumbling();
				Variables.TheRumbling = true;
				break;
			case EventEnum.Sacrifice:
				HUDManager.Instance.AddTextToChatOnServer("<color=yellow>EVENT<color=white>:</color></color>\n<color=red>The Hunger Games?</color>", -1);
				Variables.Tribute = true;
				break;
			case EventEnum.OutsideBox:
				HUDManager.Instance.AddTextToChatOnServer("<color=yellow>EVENT<color=white>:</color></color>\n<color=red>Outside the box!</color>", -1);
				Functions.FindEnemyPrefabByType(typeof(JesterAI), newLevel.Enemies, newLevel);
				Variables.presetEnemiesToSpawn.Add(new Variables.EnemySpawnInfo(typeof(JesterAI), 2, SpawnLocation.Outside, forceinside: false, forceoutside: true));
				break;
			case EventEnum.Guards:
				HUDManager.Instance.AddTextToChatOnServer("<color=yellow>EVENT<color=white>:</color></color>\n<color=red>They gaurd this place!</color>", -1);
				Functions.FindEnemyPrefabByType(typeof(NutcrackerEnemyAI), newLevel.Enemies, newLevel);
				Variables.presetEnemiesToSpawn.Add(new Variables.EnemySpawnInfo(typeof(NutcrackerEnemyAI), 4, SpawnLocation.Outside, forceinside: false, forceoutside: true));
				break;
			case EventEnum.Unfair:
				HUDManager.Instance.AddTextToChatOnServer("<color=yellow>EVENT<color=white>:</color></color>\n<color=red>UNFAIR COMPANY</color>", -1);
				break;
			case EventEnum.FaceHuggers:
				HUDManager.Instance.AddTextToChatOnServer("<color=yellow>EVENT<color=white>:</color></color>\n<color=red>Bring a Shovel!!</color>", -1);
				Variables.WaitUntilPlayerInside = true;
				Variables.presetEnemiesToSpawn.Add(new Variables.EnemySpawnInfo(typeof(CentipedeAI), 15, SpawnLocation.Vent, forceinside: false, forceoutside: false));
				break;
			case EventEnum.BlobEvolution:
				HUDManager.Instance.AddTextToChatOnServer("<color=yellow>EVENT<color=white>:</color></color>\n<color=red>They are EVOLVING?!?</color>", -1);
				Variables.presetEnemiesToSpawn.Add(new Variables.EnemySpawnInfo(typeof(BlobAI), 3, SpawnLocation.Vent, forceinside: false, forceoutside: false));
				Variables.presetEnemiesToSpawn.Add(new Variables.EnemySpawnInfo(typeof(BlobAI), 1, SpawnLocation.Outside, forceinside: false, forceoutside: true));
				Variables.BlobsHaveEvolved = true;
				break;
			case EventEnum.Delivery:
			{
				HUDManager.Instance.AddTextToChatOnServer("<color=yellow>EVENT<color=white>:</color></color>\n<color=green>ICE SCREAM!!!</color>", -1);
				int num = Random.Range(2, 9);
				for (int i = 0; i < num; i++)
				{
					int item = Random.Range(0, 12);
					Object.FindObjectOfType<Terminal>().orderedItemsFromTerminal.Add(item);
				}
				break;
			}
			case EventEnum.InstaJester:
				HUDManager.Instance.AddTextToChatOnServer("<color=yellow>EVENT<color=white>:</color></color>\n<color=red>Pop goes the.. HOLY FUC- </color>", -1);
				Functions.FindEnemyPrefabByType(typeof(JesterAI), newLevel.Enemies, newLevel);
				Variables.presetEnemiesToSpawn.Add(new Variables.EnemySpawnInfo(typeof(JesterAI), 2, SpawnLocation.Vent, forceinside: false, forceoutside: false));
				Variables.InstaJester = true;
				break;
			case EventEnum.TheyAreShy:
				HUDManager.Instance.AddTextToChatOnServer("<color=yellow>EVENT<color=white>:</color></color>\n<color=red>Don't look... away?</color>", -1);
				Functions.FindEnemyPrefabByType(typeof(FlowermanAI), newLevel.Enemies, newLevel);
				Functions.FindEnemyPrefabByType(typeof(SpringManAI), newLevel.Enemies, newLevel);
				Variables.presetEnemiesToSpawn.Add(new Variables.EnemySpawnInfo(typeof(SpringManAI), 3, SpawnLocation.Vent, forceinside: false, forceoutside: false));
				Variables.presetEnemiesToSpawn.Add(new Variables.EnemySpawnInfo(typeof(FlowermanAI), 3, SpawnLocation.Vent, forceinside: false, forceoutside: false));
				Variables.presetEnemiesToSpawn.Add(new Variables.EnemySpawnInfo(typeof(FlowermanAI), 3, SpawnLocation.Outside, forceinside: false, forceoutside: true));
				Variables.presetEnemiesToSpawn.Add(new Variables.EnemySpawnInfo(typeof(SpringManAI), 2, SpawnLocation.Outside, forceinside: false, forceoutside: true));
				break;
			case EventEnum.TheyWant2Play:
				HUDManager.Instance.AddTextToChatOnServer("<color=yellow>EVENT<color=white>:</color></color>\n<color=red>They just wants to play!!</color>", -1);
				Functions.FindEnemyPrefabByType(typeof(DressGirlAI), newLevel.Enemies, newLevel);
				Variables.presetEnemiesToSpawn.Add(new Variables.EnemySpawnInfo(typeof(DressGirlAI), 5, SpawnLocation.Vent, forceinside: false, forceoutside: false));
				break;
			case EventEnum.SurfaceExplosion:
				HUDManager.Instance.AddTextToChatOnServer("<color=yellow>EVENT<color=white>:</color></color>\n<color=red>The surface is explosive</color>", -1);
				Variables.slSpawnTimer = -10f;
				Variables.surpriseLandmines += 120;
				break;
			case EventEnum.ResetHeat:
				HUDManager.Instance.AddTextToChatOnServer("<color=yellow>EVENT<color=white>:</color></color>\n<color=green>All Moons Heat Reset</color>", -1);
				break;
			case EventEnum.ShipTurret:
				HUDManager.Instance.AddTextToChatOnServer("<color=yellow>EVENT<color=white>:</color></color>\n<color=red>When did we get this installed?!?</color>", -1);
				Variables.shouldSpawnTurret = true;
				break;
			default:
				HUDManager.Instance.AddTextToChatOnServer("<color=yellow>EVENT<color=white>:</color></color>\n<color=green>Nothing happened today!</color>", -1);
				break;
			}
		}

		public static void StoreOriginalEnemyList(SelectableLevel level)
		{
			if (!Variables.originalEnemyLists.ContainsKey(level))
			{
				Variables.originalEnemyLists[level] = new List<SpawnableEnemyWithRarity>(level.Enemies);
			}
		}

		public static void ModifyCurrentLevelEnemies(SelectableLevel currentLevel, params Type[] keepEnemyTypes)
		{
			foreach (Type item in Variables.defaultRemovableEnemyTypes.Keys.ToList())
			{
				Variables.defaultRemovableEnemyTypes[item] = false;
			}
			foreach (Type key in keepEnemyTypes)
			{
				if (Variables.defaultRemovableEnemyTypes.ContainsKey(key))
				{
					Variables.defaultRemovableEnemyTypes[key] = true;
				}
				else
				{
					Variables.defaultRemovableEnemyTypes.Add(key, value: true);
				}
			}
			currentLevel.Enemies.RemoveAll((SpawnableEnemyWithRarity enemy) => Variables.defaultRemovableEnemyTypes.TryGetValue(((object)enemy.enemyType).GetType(), out var value) && !value);
		}

		public static void RestoreOriginalEnemyList(SelectableLevel level)
		{
			if (Variables.originalEnemyLists.ContainsKey(level))
			{
				level.Enemies = Variables.originalEnemyLists[level];
				Variables.originalEnemyLists.Remove(level);
			}
		}

		public static void UpdateMapObjects(SelectableLevel newLevel, EventEnum eventEnum)
		{
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Expected O, but got Unknown
			//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_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Expected O, but got Unknown
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Expected O, but got Unknown
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_0182: Expected O, but got Unknown
			SpawnableMapObject[] spawnableMapObjects = newLevel.spawnableMapObjects;
			foreach (SpawnableMapObject val in spawnableMapObjects)
			{
				if ((Object)(object)val.prefabToSpawn.GetComponentInChildren<Turret>() != (Object)null)
				{
					Variables.turret = val.prefabToSpawn;
					if (eventEnum == EventEnum.Turret)
					{
						val.numberToSpawn = new AnimationCurve((Keyframe[])(object)new Keyframe[2]
						{
							new Keyframe(0f, 200f),
							new Keyframe(1f, 25f)
						});
					}
					else if (EnableTurretModifications.Value)
					{
						val.numberToSpawn = new AnimationCurve((Keyframe[])(object)new Keyframe[2]
						{
							new Keyframe(0f, 0f),
							new Keyframe(1f, TurretSpawnRate.Value)
						});
					}
				}
				else if ((Object)(object)val.prefabToSpawn.GetComponentInChildren<Landmine>() != (Object)null)
				{
					Variables.landmine = val.prefabToSpawn;
					if (eventEnum == EventEnum.Landmine)
					{
						val.numberToSpawn = new AnimationCurve((Keyframe[])(object)new Keyframe[2]
						{
							new Keyframe(0f, 300f),
							new Keyframe(1f, 170f)
						});
					}
					else if (EnableLandmineModifications.Value)
					{
						val.numberToSpawn = new AnimationCurve((Keyframe[])(object)new Keyframe[2]
						{
							new Keyframe(0f, 0f),
							new Keyframe(1f, LandmineSpawnRate.Value)
						});
					}
				}
				Variables.mls.LogInfo((object)((object)val.prefabToSpawn).ToString());
			}
		}

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

		public static void UpdateLevelProperties(SelectableLevel newLevel)
		{
			if (!Variables.levelsModified.Contains(newLevel))
			{
				Variables.levelsModified.Add(newLevel);
				string[] array = GetConfigForScrapSettings(((Object)newLevel).name)?.Value.Split(new char[1] { ',' });
				if (array != null && array.Length == 4)
				{
					newLevel.minScrap = ((array[0] != "-1") ? int.Parse(array[0]) : newLevel.minScrap);
					newLevel.maxScrap = ((array[1] != "-1") ? int.Parse(array[1]) : newLevel.maxScrap);
					newLevel.minTotalScrapValue = ((array[2] != "-1") ? int.Parse(array[2]) : newLevel.minTotalScrapValue);
					newLevel.maxTotalScrapValue = ((array[3] != "-1") ? int.Parse(array[3]) : newLevel.maxTotalScrapValue);
				}
				newLevel.maxEnemyPowerCount += 150;
				newLevel.maxOutsideEnemyPowerCount += 10;
				newLevel.maxDaytimeEnemyPowerCount += 150;
			}
		}

		private static ConfigEntry<string> GetConfigForScrapSettings(string levelName)
		{
			return (ConfigEntry<string>)(levelName switch
			{
				"ExperimentationLevel" => ExperimentationLevelScrap, 
				"AssuranceLevel" => AssuranceLevelScrap, 
				"VowLevel" => VowLevelScrap, 
				"MarchLevel" => MarchLevelScrap, 
				"RendLevel" => RendLevelScrap, 
				"DineLevel" => DineLevelScrap, 
				"OffenseLevel" => OffenseLevelScrap, 
				"TitanLevel" => TitanLevelScrap, 
				_ => CustomLevelScrap, 
			});
		}

		public static void ModifyEnemySpawnChances(SelectableLevel newLevel, EventEnum eventEnum, float MoonHeat)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Expected O, but got Unknown
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Expected O, but got Unknown
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Expected O, but got Unknown
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Expected O, but got Unknown
			newLevel.enemySpawnChanceThroughoutDay = new AnimationCurve((Keyframe[])(object)new Keyframe[3]
			{
				new Keyframe(0f, 0.1f),
				new Keyframe(0.5f, 10f),
				new Keyframe(1f, 70f)
			});
			newLevel.outsideEnemySpawnChanceThroughDay = new AnimationCurve((Keyframe[])(object)new Keyframe[3]
			{
				new Keyframe(0f, -30f),
				new Keyframe(20f, -20f),
				new Keyframe(21f, 10f)
			});
			if (eventEnum == EventEnum.Unfair)
			{
				newLevel.outsideEnemySpawnChanceThroughDay = new AnimationCurve((Keyframe[])(object)new Keyframe[2]
				{
					new Keyframe(0f, 999f),
					new Keyframe(21f, 999f)
				});
				newLevel.enemySpawnChanceThroughoutDay = new AnimationCurve((Keyframe[])(object)new Keyframe[2]
				{
					new Keyframe(0f, 500f),
					new Keyframe(0.5f, 500f)
				});
			}
		}
	}
}
namespace BrutalCompanyPlus.HarmPatches
{
	public static class EnemyAIPatches
	{
		public static bool HoldState;

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

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

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

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

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

		[HarmonyPatch(typeof(EnemyAI), "StartSearch")]
		[HarmonyPrefix]
		public static bool InsideOutStartSearchModification(EnemyAI __instance, ref Vector3 startOfSearch, AISearchRoutine newSearch)
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			if (Variables.InsideOutOwnership && ((NetworkBehaviour)RoundManager.Instance).IsHost && Variables.SpawnedInsideOutID.Contains(((Object)__instance).GetInstanceID()))
			{
				Vector3 position = StartOfRound.Instance.playerSpawnPositions[0].position;
				startOfSearch = Functions.GetNearbyLocation(position);
				Variables.mls.LogError((object)"Changed Search Start Location of Enemy insideOut");
				return true;
			}
			return true;
		}

		[HarmonyPatch(typeof(JesterAI), "Update")]
		[HarmonyPostfix]
		public static void InstaJesterModifications(JesterAI __instance)
		{
			if (Variables.InstaJester && ((NetworkBehaviour)RoundManager.Instance).IsHost)
			{
				if (((NetworkBehaviour)__instance).OwnerClientId != GameNetworkManager.Instance.localPlayerController.actualClientId && ((EnemyAI)__instance).currentBehaviourStateIndex < 2)
				{
					((EnemyAI)__instance).ChangeOwnershipOfEnemy(GameNetworkManager.Instance.localPlayerController.actualClientId);
				}
				else if (((EnemyAI)__instance).currentBehaviourStateIndex == 1 && __instance.popUpTimer > 10f)
				{
					__instance.popUpTimer = Random.Range(0f, 10f);
				}
			}
		}

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

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

		[HarmonyPatch(typeof(MouthDogAI), "OnCollideWithPlayer")]
		[HarmonyPrefix]
		public static bool MouthDogAIOnCollideWithPlayerPatch(MouthDogAI __instance, ref Collider other, bool ___inKillAnimation, Collider ___debugCollider, bool ___inLunge, Ray ___ray, RaycastHit ___rayHit, RoundManager ___roundManager)
		{
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//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_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: Unknown result type (might be due to invalid IL or missing references)
			//IL_018b: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			if (Variables.DogForceOwnership && ((NetworkBehaviour)RoundManager.Instance).IsHost)
			{
				PlayerControllerB component = ((Component)other).gameObject.GetComponent<PlayerControllerB>();
				if ((Object)(object)component != (Object)null && !component.isPlayerDead && component.isPlayerControlled && !___inKillAnimation)
				{
					Vector3 val = Vector3.Normalize((((Component)__instance).transform.position + Vector3.up - ((Component)component.gameplayCamera).transform.position) * 100f);
					RaycastHit val2 = default(RaycastHit);
					if (Physics.Linecast(((Component)__instance).transform.position + Vector3.up + val * 0.5f, ((Component)component.gameplayCamera).transform.position, ref val2, StartOfRound.Instance.collidersAndRoomMask, (QueryTriggerInteraction)1))
					{
						if ((Object)(object)((RaycastHit)(ref val2)).collider == (Object)(object)___debugCollider)
						{
							return false;
						}
						___debugCollider = ((RaycastHit)(ref val2)).collider;
						return false;
					}
					if (((EnemyAI)__instance).currentBehaviourStateIndex == 3)
					{
						component.inAnimationWithEnemy = (EnemyAI)(object)__instance;
						__instance.KillPlayerServerRpc((int)component.playerClientId);
						return false;
					}
					if (((EnemyAI)__instance).currentBehaviourStateIndex == 0 || ((EnemyAI)__instance).currentBehaviourStateIndex == 1)
					{
						((EnemyAI)__instance).SwitchToBehaviourState(2);
						((EnemyAI)__instance).SetDestinationToPosition(((Component)component).transform.position, false);
						return false;
					}
					if (((EnemyAI)__instance).currentBehaviourStateIndex == 2 && !___inLunge)
					{
						((Component)__instance).transform.LookAt(((Component)other).transform.position);
						((Component)__instance).transform.localEulerAngles = new Vector3(0f, ((Component)__instance).transform.eulerAngles.y, 0f);
						___inLunge = true;
						Functions.EnterLunge(__instance, ___ray, ___rayHit, ___roundManager);
						return false;
					}
				}
			}
			return true;
		}

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

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

		[HarmonyPatch(typeof(BlobAI), "OnCollideWithPlayer")]
		[HarmonyPostfix]
		public static void BlobAIOnCollideWithPlayerPatch(BlobAI __instance, ref Collider other)
		{
			//IL_00b4: 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)
			PlayerControllerB component = ((Component)other).gameObject.GetComponent<PlayerControllerB>();
			if (!((Object)(object)component != (Object)null) || component.isPlayerDead || !component.isPlayerControlled)
			{
				return;
			}
			Type typeFromHandle = typeof(BlobAI);
			FieldInfo field = typeFromHandle.GetField("timeSinceHittingLocalPlayer", BindingFlags.Instance | BindingFlags.NonPublic);
			FieldInfo field2 = typeFromHandle.GetField("tamedTimer", BindingFlags.Instance | BindingFlags.NonPublic);
			FieldInfo field3 = typeFromHandle.GetField("angeredTimer", BindingFlags.Instance | BindingFlags.NonPublic);
			if (!((float)field.GetValue(__instance) < 0.25f) && (!((float)field2.GetValue(__instance) > 0f) || !((float)field3.GetValue(__instance) < 0f)))
			{
				field.SetValue(__instance, 0);
				component.DamagePlayer(35, true, true, (CauseOfDeath)0, 0, false, default(Vector3));
				if (component.isPlayerDead)
				{
					__instance.SlimeKillPlayerEffectServerRpc((int)component.playerClientId);
				}
			}
		}

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

		public static bool test2;

		public static bool test3;

		[HarmonyPatch(typeof(RoundManager), "LoadNewLevel")]
		[HarmonyPrefix]
		private static bool ModifyLevel(ref SelectableLevel newLevel)
		{
			if (!((NetworkBehaviour)RoundManager.Instance).IsHost)
			{
				return true;
			}
			Plugin.CleanupAndResetAI();
			Plugin.UpdateAIInNewLevel(newLevel);
			Plugin.AddMissingAIToNewLevel(newLevel);
			Variables.CurrentLevel = newLevel;
			EventEnum eventEnum = Plugin.SelectRandomEvent();
			Plugin.InitializeLevelHeatValues(newLevel);
			Plugin.AdjustHeatValuesForAllLevels(eventEnum, newLevel);
			Variables.CurrentLevelHeatValue = Plugin.DisplayHeatMessages(newLevel);
			Plugin.ApplyCustomLevelEnemyRarities(newLevel.Enemies, ((Object)newLevel).name);
			Plugin.HandleEventSpecificAdjustments(eventEnum, newLevel);
			Plugin.UpdateMapObjects(newLevel, eventEnum);
			Plugin.LogEnemyInformation(newLevel);
			Plugin.UpdateLevelProperties(newLevel);
			Plugin.ModifyEnemySpawnChances(newLevel, eventEnum, Variables.CurrentLevelHeatValue);
			Variables.levelHeatVal.TryGetValue(newLevel, out var value);
			Variables.levelHeatVal[newLevel] = Mathf.Clamp(value + Plugin.MoonHeatIncreaseRate.Value, 0f, 100f);
			return true;
		}
	}
	public static class QuotaPatches
	{
		[HarmonyPatch(typeof(TimeOfDay), "Awake")]
		[HarmonyPostfix]
		private static void ModifyTimeOfDay(TimeOfDay __instance)
		{
			Variables.mls.LogWarning((object)"Modifying the Starting Quota Values based on Config");
			__instance.quotaVariables.deadlineDaysAmount = Plugin.DeadlineDaysAmount.Value;
			__instance.quotaVariables.startingCredits = Plugin.StartingCredits.Value;
			__instance.quotaVariables.startingQuota = Plugin.StartingQuota.Value;
			__instance.quotaVariables.baseIncrease = Plugin.BaseIncrease.Value;
		}

		[HarmonyPatch(typeof(GameNetworkManager), "ResetSavedGameValues")]
		[HarmonyPostfix]
		public static void ResetMoonHeatOnFire(GameNetworkManager __instance)
		{
			foreach (SelectableLevel item in Variables.levelHeatVal.Keys.ToList())
			{
				if (Variables.levelHeatVal.Count != 0)
				{
					Variables.levelHeatVal[item] = 0f;
				}
			}
		}

		[HarmonyPatch(typeof(DeleteFileButton), "DeleteFile")]
		[HarmonyPostfix]
		public static void ResetMoonHeatOnDeleteFile(DeleteFileButton __instance)
		{
			foreach (SelectableLevel item in Variables.levelHeatVal.Keys.ToList())
			{
				if (Variables.levelHeatVal.Count != 0)
				{
					Variables.levelHeatVal[item] = 0f;
				}
			}
		}
	}
}
namespace BrutalCompanyPlus.BCP
{
	public class BcpLogger
	{
		private static string logFilePath;

		private const long MaxFileSize = 524288000L;

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

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

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

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

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

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

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

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

		public static void TheBeastsInside()
		{
			string sceneName = Variables.CurrentLevel.sceneName;
			int num = 0;
			Variables.DogForceOwnership = true;
			switch (sceneName)
			{
			case "Titan":
				num = 6;
				break;
			case "Rend":
			case "Dine":
				num = 4;
				break;
			case "March":
			case "Offense":
				num = 3;
				break;
			default:
				num = 2;
				break;
			}
			Variables.presetEnemiesToSpawn.Add(new Variables.EnemySpawnInfo(typeof(MouthDogAI), num, SpawnLocation.Vent, forceinside: true, forceoutside: false));
		}

		public static void TheRumbling()
		{
			string sceneName = Variables.CurrentLevel.sceneName;
			int num = 0;
			switch (sceneName)
			{
			case "March":
			case "Titan":
			case "Offense":
			case "Vow":
				num = 8;
				break;
			case "Dine":
			case "Rend":
				num = 10;
				break;
			case "Experimentation":
				num = 6;
				break;
			default:
				num = 8;
				break;
			}
			Variables.presetEnemiesToSpawn.Add(new Variables.EnemySpawnInfo(typeof(ForestGiantAI), num, SpawnLocation.Outside, forceinside: false, forceoutside: false));
		}

		public static void InsideOutEnemies()
		{
			Variables.InsideOutOwnership = true;
			for (int i = 0; i < 4; i++)
			{
				EnemyAI val = SpawnEnemyOutside(typeof(SpringManAI), ForceOutside: true);
				Variables.SpawnedInsideOutID.Add(((Object)val).GetInstanceID());
			}
		}

		public static void SetLightningStrikeInterval()
		{
			Variables.lightningStrikeInterval = Random.Range(0f, 10f);
		}

		public static void LightningStrikeRandom()
		{
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			if (Variables.Smite_outsideNodes == null || Variables.Smite_outsideNodes.Length == 0)
			{
				Variables.mls.LogError((object)"Smite_outsideNodes is null or empty.");
				InitializeSmiteOutsideNodes();
				if (Variables.Smite_outsideNodes == null || Variables.Smite_outsideNodes.Length == 0)
				{
					return;
				}
			}
			try
			{
				Vector3 val;
				if (Variables.Smite_seed.Next(0, 100) < 60 && (Variables.randomThunderTime - Variables.timeAtLastStrike) * (float)TimeOfDay.Instance.currentWeatherVariable < 3f)
				{
					val = Variables.lastRandomStrikePosition;
				}
				else
				{
					int num = Variables.Smite_seed.Next(0, Variables.Smite_outsideNodes.Length);
					val = Variables.Smite_outsideNodes[num].transform.position;
					val = (Variables.lastRandomStrikePosition = RoundManager.Instance.GetRandomNavMeshPositionInBoxPredictable(val, 15f, Variables.Smite_navHit, Variables.Smite_seed, -1));
				}
				if (StartOfRound.Instance.shipHasLanded)
				{
					RoundManager.Instance.LightningStrikeServerRpc(val);
				}
			}
			catch (Exception ex)
			{
				Variables.mls.LogError((object)("Error in LightningStrikeRandom: " + ex.Message + "\nStack Trace: " + ex.StackTrace));
				BcpLogger.Log("Error in LightningStrikeRandom: " + ex.Message + "\nStack Trace: " + ex.StackTrace);
			}
		}

		public static void InitializeSmiteOutsideNodes()
		{
			Variables.Smite_outsideNodes = GameObject.FindGameObjectsWithTag("OutsideAINode");
			if (Variables.Smite_outsideNodes != null && Variables.Smite_outsideNodes.Length != 0)
			{
				Variables.mls.LogInfo((object)$"Found {Variables.Smite_outsideNodes.Length} OutsideAINode objects.");
			}
			else
			{
				Variables.mls.LogError((object)"No OutsideAINode objects found in the scene.");
			}
		}

		public static void SurfaceExplosionLoop()
		{
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			if (Variables.slSpawnTimer > 0f)
			{
				Variables.slSpawnTimer = Random.Range(-4, -1);
				PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
				PlayerControllerB val = allPlayerScripts[Random.Range(0, allPlayerScripts.Length)];
				if ((Object)(object)val != (Object)null && !val.isInHangarShipRoom && !val.isInsideFactory)
				{
					if (Vector3.Distance(((Component)val).transform.position, new Vector3(9.33f, 5.2f, 1021f)) < 1f)
					{
						Variables.slSpawnTimer = 1f;
						return;
					}
					GameObject val2 = Object.Instantiate<GameObject>(Variables.landmine, ((Component)val).transform.position, Quaternion.identity);
					val2.transform.position = ((Component)val).transform.position;
					Variables.mls.LogWarning((object)((Component)val).transform.position);
					val2.GetComponent<NetworkObject>().Spawn(true);
					Variables.objectsToCleanUp.Add(val2);
				}
			}
			else
			{
				Variables.slSpawnTimer += Time.deltaTime;
			}
		}

		public static void HungerGamesLoop()
		{
			if (Variables.sacrificeTargetChangeTimer >= Variables.TargetChangeInterval || (Object)(object)Variables.SacrificeTarget == (Object)null || !Variables.SacrificeTarget.isPlayerControlled)
			{
				PickNewSacrificeTarget();
				Variables.sacrificeTargetChangeTimer = 0f;
			}
			if ((Object)(object)Variables.SacrificeTarget != (Object)null && Variables.SacrificeTarget.isInsideFactory)
			{
				ApplySacrificeEffect();
				Variables.Tribute = false;
			}
		}

		public static void PickNewSacrificeTarget()
		{
			PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
			if (allPlayerScripts.Length != 0)
			{
				Variables.SacrificeTarget = allPlayerScripts[Random.Range(0, allPlayerScripts.Length)];
			}
		}

		public static void ApplySacrificeEffect()
		{
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			if (!Variables.SacrificeTarget.isPlayerDead)
			{
				HUDManager.Instance.AddTextToChatOnServer("<color=purple>" + Variables.SacrificeTarget.playerUsername + "</color> <color=orange>volunteered as Tribute!</color>", -1);
				Variables.SacrificeTarget.DamagePlayerFromOtherClientServerRpc(500, default(Vector3), (int)GameNetworkManager.Instance.localPlayerController.playerClientId);
			}
		}

		public static void EnterLunge(MouthDogAI __instance, Ray ray, RaycastHit rayHit, RoundManager roundManager)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: 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_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: 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_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			((EnemyAI)__instance).SwitchToBehaviourState(3);
			__instance.endingLunge = false;
			((Ray)(ref ray))..ctor(((Component)__instance).transform.position + Vector3.up, ((Component)__instance).transform.forward);
			Vector3 val = ((!Physics.Raycast(ray, ref rayHit, 17f, StartOfRound.Instance.collidersAndRoomMask)) ? ((Ray)(ref ray)).GetPoint(17f) : ((RaycastHit)(ref rayHit)).point);
			val = roundManager.GetNavMeshPosition(val, default(NavMeshHit), 5f, -1);
			((EnemyAI)__instance).SetDestinationToPosition(val, false);
			((EnemyAI)__instance).agent.speed = 13f;
		}

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

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

		public static void LogEnemyList(SelectableLevel level)
		{
			if (!((Object)(object)level != (Object)null) || level.Enemies.Count <= 0)
			{
				return;
			}
			foreach (SpawnableEnemyWithRarity enemy in level.Enemies)
			{
				BcpLogger.Log($"{enemy.enemyType.enemyName} with a Rarity of {enemy.rarity} on {level.sceneName}");
			}
		}

		public static void CloneEnemyList(SelectableLevel level)
		{
			if (!((Object)(object)level != (Object)null) || level.Enemies.Count <= 0)
			{
				return;
			}
			foreach (SpawnableEnemyWithRarity enemy in level.Enemies)
			{
				Variables.OriginalEnemyListWithRarity.Add(enemy);
				BcpLogger.Log($"{enemy.enemyType.enemyName} with a Rarity of {enemy.rarity} on {level.sceneName}");
			}
		}

		public static void SetEnemyListOriginalState(SelectableLevel level)
		{
			if (!((Object)(object)level != (Object)null) || Variables.OriginalEnemyListWithRarity.Count <= 0)
			{
				return;
			}
			level.Enemies.Clear();
			foreach (SpawnableEnemyWithRarity item in Variables.OriginalEnemyListWithRarity)
			{
				level.Enemies.Add(item);
				BcpLogger.Log($"Reverting {item.enemyType.enemyName} with a Rarity of {item.rarity} on {level.sceneName}");
			}
			Variables.OriginalEnemyListWithRarity.Clear();
		}

		public static void CleanUpAllVariables()
		{
			Variables.DogForceOwnership = false;
			Variables.InsideOutOwnership = false;
			Variables.BlobsHaveEvolved = false;
			Variables.InstaJester = false;
			Variables.TheRumbling = false;
			Variables.SmiteEnabled = false;
			Variables.SacrificeTarget = null;
			Variables.Tribute = false;
			Variables.SpawnInsideOut = false;
			Variables.WaitUntilPlayerInside = false;
			Variables.Landed = false;
			Variables.sacrificeTargetChangeTimer = 0f;
			Variables.surpriseLandmines = -1;
			Variables.SpawnedInsideOutID.Clear();
			Variables.presetEnemiesToSpawn.Clear();
			Variables.DogsSpawnedInside.Clear();
			foreach (Type item in Variables.aiPresence.Keys.ToList())
			{
				Variables.aiPresence[item] = false;
			}
		}
	}
	public static class Variables
	{
		public struct EnemySpawnInfo
		{
			public Type EnemyType;

			public int Amount;

			public SpawnLocation Location;

			public bool ForceInside;

			public bool ForceOutside;

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

		public static bool BlobsHaveEvolved = false;

		public static bool InstaJester = false;

		public static bool WaitUntilPlayerInside = false;

		public static PlayerControllerB SacrificeTarget = null;

		public static bool Tribute = false;

		public static float sacrificeTargetChangeTimer = 0f;

		public static float TargetChangeInterval = 30f;

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

		public static bool DogForceOwnership = false;

		public static bool SpawnDogsInside = false;

		public static bool DogIsLunging = false;

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

		public static bool InsideOutOwnership = false;

		public static bool SpawnInsideOut = false;

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

		public static bool TheRumbling = false;

		public static float timeNearDoor = 0f;

		public static float requiredTime = 2f;

		public static bool Landed = false;

		public static bool TakeOffExecuted = false;

		public static TimeOfDay TOD;

		public static float messageTimer = 58f;

		public static int surpriseLandmines;

		public static GameObject landmine;

		public static GameObject turret;

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

		public static float slSpawnTimer;

		public static bool shouldSpawnTurret;

		public static bool TurretSpawned = false;

		public static bool loaded;

		public static EventEnum lastEvent = EventEnum.None;

		public static float CurrentLevelHeatValue = 0f;

		public static readonly Harmony _harmony = new Harmony("BrutalCompanyPlus");

		public static SelectableLevel CurrentLevel = null;

		public static List<SelectableLevel> levelsModified = new List<SelectableLevel>();

		public static Dictionary<SelectableLevel, float> levelHeatVal;

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

		public static Dictionary<SpawnableEnemyWithRarity, int> enemyRaritys;

		public static Dictionary<SpawnableEnemyWithRarity, AnimationCurve> enemyPropCurves;

		public static ManualLogSource mls;

		public static Dictionary<SelectableLevel, List<SpawnableEnemyWithRarity>> originalEnemyLists = new Dictionary<SelectableLevel, List<SpawnableEnemyWithRarity>>();

		public static Dictionary<Type, bool> defaultRemovableEnemyTypes = new Dictionary<Type, bool>
		{
			{
				typeof(BlobAI),
				false
			},
			{
				typeof(CentipedeAI),
				false
			},
			{
				typeof(CrawlerAI),
				false
			},
			{
				typeof(DressGirlAI),
				false
			},
			{
				typeof(FlowermanAI),
				false
			},
			{
				typeof(HoarderBugAI),
				false
			},
			{
				typeof(JesterAI),
				false
			},
			{
				typeof(PufferAI),
				false
			},
			{
				typeof(SandSpiderAI),
				false
			},
			{
				typeof(SpringManAI),
				false
			},
			{
				typeof(NutcrackerEnemyAI),
				false
			},
			{
				typeof(MaskedPlayerEnemy),
				false
			}
		};

		public static Dictionary<Type, bool> aiPresence = new Dictionary<Type, bool>
		{
			{
				typeof(BaboonBirdAI),
				false
			},
			{
				typeof(BlobAI),
				false
			},
			{
				typeof(CentipedeAI),
				false
			},
			{
				typeof(CrawlerAI),
				false
			},
			{
				typeof(DoublewingAI),
				false
			},
			{
				typeof(DressGirlAI),
				false
			},
			{
				typeof(FlowermanAI),
				false
			},
			{
				typeof(ForestGiantAI),
				false
			},
			{
				typeof(HoarderBugAI),
				false
			},
			{
				typeof(JesterAI),
				false
			},
			{
				typeof(MouthDogAI),
				false
			},
			{
				typeof(PufferAI),
				false
			},
			{
				typeof(RedLocustBees),
				false
			},
			{
				typeof(SandSpiderAI),
				false
			},
			{
				typeof(SandWormAI),
				false
			},
			{
				typeof(SpringManAI),
				false
			},
			{
				typeof(NutcrackerEnemyAI),
				false
			},
			{
				typeof(MaskedPlayerEnemy),
				false
			}
		};

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

		public static Random Smite_seed = new Random();

		public static GameObject[] Smite_outsideNodes;

		public static Vector3 lastRandomStrikePosition;

		public static float timeAtLastStrike;

		public static float randomThunderTime;

		public static NavMeshHit Smite_navHit;

		public static float lightningStrikeInterval = 3f;

		public static float lastStrikeTime;

		public static bool SmiteEnabled = false;

		public static List<EnemySpawnInfo> presetEnemiesToSpawn = new List<EnemySpawnInfo>();
	}
	public class BrutalPlus : MonoBehaviour
	{
		public void Awake()
		{
			Variables.mls.LogWarning((object)"Brutal Plus is Awake");
		}

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

		public void OnDestroy()
		{
			BcpLogger.Close();
		}

		private void Update()
		{
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (!((Object)(object)StartOfRound.Instance != (Object)null) || !((NetworkBehaviour)RoundManager.Instance).IsHost)
				{
					return;
				}
				if (Variables.SmiteEnabled)
				{
					Functions.SetLightningStrikeInterval();
					if (Time.time - Variables.lastStrikeTime > Variables.lightningStrikeInterval)
					{
						Functions.LightningStrikeRandom();
						Variables.lastStrikeTime = Time.time;
					}
				}
				if (Variables.Tribute)
				{
					Functions.HungerGamesLoop();
				}
				if (Variables.surpriseLandmines > 0 && Variables.Landed)
				{
					Functions.SurfaceExplosionLoop();
				}
				if (Variables.shouldSpawnTurret & ((Object)(object)Variables.turret != (Object)null))
				{
					Variables.shouldSpawnTurret = false;
					Variables.TurretSpawned = true;
					GameObject val = Object.Instantiate<GameObject>(Variables.turret, new Vector3(3.87f, 0.84f, -14.23f), Quaternion.identity);
					val.transform.position = new Vector3(3.87f, 0.84f, -14.23f);
					val.transform.forward = new Vector3(1f, 0f, 0f);
					val.GetComponent<NetworkObject>().Spawn(true);
					Variables.objectsToCleanUp.Add(val);
				}
				if (Variables.presetEnemiesToSpawn.Count > 0 && Variables.WaitUntilPlayerInside)
				{
					for (int i = 0; i < StartOfRound.Instance.allPlayerScripts.Length; i++)
					{
						if (StartOfRound.Instance.allPlayerScripts[i].isInsideFactory)
						{
							Functions.SpawnMultipleEnemies(Variables.presetEnemiesToSpawn);
							Variables.presetEnemiesToSpawn.Clear();
						}
					}
				}
				if (StartOfRound.Instance.shipHasLanded && !Variables.Landed)
				{
					Variables.Landed = true;
					if (Variables.presetEnemiesToSpawn.Count > 0 && !Variables.WaitUntilPlayerInside)
					{
						Functions.SpawnMultipleEnemies(Variables.presetEnemiesToSpawn);
					}
					if (Variables.SpawnInsideOut)
					{
						Functions.InsideOutEnemies();
					}
				}
				if (StartOfRound.Instance.shipIsLeaving)
				{
					if (Variables.TakeOffExecuted)
					{
						return;
					}
					if (Plugin.EnableFreeMoney.Value)
					{
						if (!StartOfRound.Instance.allPlayersDead)
						{
							Terminal val2 = Object.FindObjectOfType<Terminal>();
							val2.groupCredits += Plugin.FreeMoneyValue.Value;
							val2.SyncGroupCreditsServerRpc(val2.groupCredits, val2.numberOfItemsInDropship);
							HUDManager.Instance.AddTextToChatOnServer("\"<size=10><color=green> You survived another day! Here's free cash c: </color></size>", -1);
						}
						else
						{
							HUDManager.Instance.AddTextToChatOnServer("\"<size=10><color=red> That was Brutal! No free cash today :c </color></size>", -1);
						}
					}
					if (Variables.TurretSpawned)
					{
						Variables.mls.LogWarning((object)"Disabling Turret due to ship leaving");
						Turret[] array = Object.FindObjectsOfType<Turret>();
						for (int j = 0; j < array.Length; j++)
						{
							array[j].ToggleTurretEnabled(false);
						}
						Variables.TurretSpawned = false;
					}
					Functions.CleanUpAllVariables();
					Variables.TakeOffExecuted = true;
				}
				else
				{
					Variables.TakeOffExecuted = false;
				}
			}
			catch (Exception ex)
			{
				Variables.mls.LogError((object)("Error in Update: " + ex.Message));
				BcpLogger.Log("Error in Update: " + ex.Message);
			}
		}

		public static void CleanupAllSpawns()
		{
			foreach (GameObject item in Variables.objectsToCleanUp)
			{
				if ((Object)(object)item != (Object)null)
				{
					item.GetComponent<NetworkObject>().Despawn(true);
				}
			}
			Variables.objectsToCleanUp.Clear();
		}
	}
	public enum EventEnum
	{
		None,
		Turret,
		Delivery,
		BlobEvolution,
		Guards,
		SurfaceExplosion,
		FaceHuggers,
		TheRumbling,
		TheyWant2Play,
		BeastInside,
		Unfair,
		InsideOut,
		OutsideBox,
		InstaJester,
		Landmine,
		Sacrifice,
		ShipTurret,
		ShadowRealm,
		HoardTown,
		TheyAreShy,
		ResetHeat
	}
	public enum InsideEnemyEnum
	{
		Centipede,
		SandSpider,
		HoarderBug,
		FlowerMan,
		Crawler,
		Blob,
		DressGirl,
		Puffer,
		SpringMan,
		Jester
	}
	public enum OutsideEnemyEnum
	{
		MouthDog,
		ForestGiant,
		SandWorm,
		RedLocustBees,
		DoubleWing,
		DocileLocustBees
	}
	public enum SpawnLocation
	{
		Outside,
		Vent
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "BrutalCompanyPlus";

		public const string PLUGIN_NAME = "BrutalCompanyPlus";

		public const string PLUGIN_VERSION = "3.5.1";
	}
}

BepInEx/plugins/HullBreakerCompany.dll

Decompiled 2 years ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using HullBreakerCompany.Events;
using HullBreakerCompany.Hull;
using Unity.Netcode;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("HullBreakerCompany")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Making it more challenging to work for the company")]
[assembly: AssemblyFileVersion("1.3.9.0")]
[assembly: AssemblyInformationalVersion("1.3.9")]
[assembly: AssemblyProduct("HullBreakerCompany")]
[assembly: AssemblyTitle("HullBreakerCompany")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.3.9.0")]
[module: UnverifiableCode]
namespace HullBreakerCompany
{
	[BepInPlugin("HullBreakerCompany", "HullBreakerCompany", "1.3.9")]
	public class Plugin : BaseUnityPlugin
	{
		private static Dictionary<int, SelectableLevelState> _levelStates = new Dictionary<int, SelectableLevelState>();

		private static bool _loaded;

		public static ManualLogSource Mls;

		public static bool OneForAllIsActive;

		public static bool BountyIsActive;

		public static int DaysPassed;

		public static float BunkerEnemyScale;

		public static float LandMineTurretScale;

		public static bool UseShortChatMessages;

		public static bool EnableEventMessages;

		public static bool UseHullBreakerLevelSettings;

		public static bool UseDefaultGameSettings;

		public static int MaxEnemyPowerCount;

		public static int MaxOutsideEnemyPowerCount;

		public static int MaxDaytimeEnemyPowerCount;

		public static int MinScrap;

		public static int MaxScrap;

		public static int MinTotalScrapValue;

		public static int MaxTotalScrapValue;

		public static bool ChangeQuotaValue;

		public static int QuotaIncrease;

		public static bool IncreaseEventCountPerDay;

		public static int EventCount;

		public static List<SpawnableItemWithRarity> NotModifiedSpawnableItemsWithRarity = new List<SpawnableItemWithRarity>();

		public static Dictionary<string, Type> EnemyBase = new Dictionary<string, Type>
		{
			{
				"flowerman",
				typeof(FlowermanAI)
			},
			{
				"hoarderbug",
				typeof(HoarderBugAI)
			},
			{
				"springman",
				typeof(SpringManAI)
			},
			{
				"crawler",
				typeof(CrawlerAI)
			},
			{
				"sandspider",
				typeof(SandSpiderAI)
			},
			{
				"jester",
				typeof(JesterAI)
			},
			{
				"centipede",
				typeof(CentipedeAI)
			},
			{
				"blobai",
				typeof(BlobAI)
			},
			{
				"dressgirl",
				typeof(DressGirlAI)
			},
			{
				"pufferenemy",
				typeof(PufferAI)
			},
			{
				"eyelessdogs",
				typeof(MouthDogAI)
			},
			{
				"forestgiant",
				typeof(ForestGiantAI)
			},
			{
				"sandworm",
				typeof(SandWormAI)
			},
			{
				"baboonbird",
				typeof(BaboonBirdAI)
			},
			{
				"nutcrackerenemy",
				typeof(NutcrackerEnemyAI)
			},
			{
				"maskedplayerenemy",
				typeof(MaskedPlayerEnemy)
			}
		};

		public static List<HullEvent> EventDictionary = new List<HullEvent>
		{
			new FlowerManEvent(),
			new LandMineEvent(),
			new HoarderBugEvent(),
			new SpringManEvent(),
			new LizardsEvent(),
			new ArachnophobiaEvent(),
			new BeeEvent(),
			new SlimeEvent(),
			new DevochkaPizdecEvent(),
			new EnemyBountyEvent(),
			new OpenTheNoorEvent(),
			new OnAPowderKegEvent(),
			new OutSideEnemyDayEvent(),
			new HellEvent(),
			new NothingEvent(),
			new HackedTurretsEvent(),
			new BabkinPogrebEvent(),
			new HullBreakEvent(),
			new NutcrackerEvent()
		};

		private readonly Harmony _harmony = new Harmony("HULLBREAKER");

		private void Awake()
		{
			Mls = Logger.CreateLogSource("HULLBREAKER 1.3.9");
			Mls.LogInfo((object)"Ready to break hull; HullBreakerCompany");
			_harmony.PatchAll(typeof(Plugin));
			if (!_loaded)
			{
				Initialize();
			}
		}

		public void Start()
		{
			if (!_loaded)
			{
				Initialize();
			}
		}

		public void OnDestroy()
		{
			if (!_loaded)
			{
				Initialize();
			}
		}

		public void Initialize()
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but got Unknown
			ConfigManager.SetConfigValue();
			GameObject val = new GameObject("HullManager");
			Object.DontDestroyOnLoad((Object)(object)val);
			((Object)val).hideFlags = (HideFlags)61;
			val.AddComponent<HullManager>();
			Mls.LogInfo((object)"HullManager created");
			CustomEventLoader.LoadCustomEvents();
			_loaded = true;
		}

		[HarmonyPatch(typeof(RoundManager), "LoadNewLevel")]
		[HarmonyPrefix]
		private static bool ModifiedLoad(ref SelectableLevel newLevel)
		{
			//IL_0392: Unknown result type (might be due to invalid IL or missing references)
			//IL_0397: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03bc: Expected O, but got Unknown
			//IL_03cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e3: Expected O, but got Unknown
			//IL_0469: Unknown result type (might be due to invalid IL or missing references)
			//IL_046e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0473: Unknown result type (might be due to invalid IL or missing references)
			//IL_047d: Expected O, but got Unknown
			Mls.LogInfo((object)("Client is host: " + ((NetworkBehaviour)RoundManager.Instance).IsHost));
			if (!((NetworkBehaviour)RoundManager.Instance).IsHost)
			{
				return true;
			}
			CustomEventLoader.DebugLoadCustomEvents();
			int levelID = newLevel.levelID;
			if (!_levelStates.ContainsKey(levelID))
			{
				_levelStates[levelID] = new SelectableLevelState(newLevel);
			}
			else
			{
				_levelStates[levelID].RestoreState(newLevel);
			}
			if (newLevel.levelID == 3)
			{
				Mls.LogInfo((object)"Level is company, skipping");
				DaysPassed = 0;
				return true;
			}
			DaysPassed++;
			Mls.LogInfo((object)$"Days passed: {DaysPassed}");
			BountyIsActive = false;
			OneForAllIsActive = false;
			ResetLevelUnits(newLevel);
			SelectableLevel val = newLevel;
			List<string> randomGameEvents = RandomSelector.GetRandomGameEvents();
			Dictionary<Type, int> dictionary = new Dictionary<Type, int>();
			Dictionary<Type, int> dictionary2 = new Dictionary<Type, int>();
			dictionary.Clear();
			NotModifiedSpawnableItemsWithRarity.Clear();
			foreach (SpawnableItemWithRarity item in val.spawnableScrap)
			{
				NotModifiedSpawnableItemsWithRarity.Add(item);
			}
			if (EventCount != 0 && EnableEventMessages)
			{
				HUDManager.Instance.AddTextToChatOnServer("<color=red>NOTES ABOUT MOON:</color>\"", -1);
			}
			foreach (string gameEvent in randomGameEvents)
			{
				try
				{
					HullEvent hullEvent = EventDictionary.FirstOrDefault((HullEvent e) => e.ID() == gameEvent);
					if (hullEvent != null)
					{
						hullEvent.Execute(newLevel, dictionary, dictionary2);
						Mls.LogInfo((object)("Event: " + gameEvent));
						UpdateRarity(newLevel.Enemies, dictionary);
						UpdateRarity(newLevel.OutsideEnemies, dictionary2);
					}
				}
				catch (NullReferenceException ex)
				{
					Mls.LogError((object)$"NullReferenceException caught while processing event: {gameEvent}. Exception message: {ex.Message}. Caused : {ex.InnerException}");
				}
			}
			HullManager.LogEnemyRarity(newLevel.Enemies, "⬛⬛⬛⬛⬛⬛ENEMIES RARITY⬛⬛⬛⬛⬛⬛");
			HullManager.LogEnemyRarity(newLevel.DaytimeEnemies, "⬛⬛⬛⬛⬛⬛DAYTIME ENEMIES RARITY⬛⬛⬛⬛⬛⬛");
			HullManager.LogEnemyRarity(newLevel.OutsideEnemies, "⬛⬛⬛⬛⬛⬛OUTSIDE ENEMIES RARITY⬛⬛⬛⬛⬛⬛");
			if (!randomGameEvents.Contains("Bee"))
			{
				using IEnumerator<SpawnableEnemyWithRarity> enumerator3 = val.DaytimeEnemies.Where((SpawnableEnemyWithRarity unit) => (Object)(object)unit.enemyType.enemyPrefab.GetComponent<RedLocustBees>() != (Object)null).GetEnumerator();
				if (enumerator3.MoveNext())
				{
					SpawnableEnemyWithRarity current2 = enumerator3.Current;
					current2.rarity = 22;
				}
			}
			if (UseHullBreakerLevelSettings)
			{
				val.maxEnemyPowerCount += 16;
				val.maxOutsideEnemyPowerCount += 20;
				val.maxScrap += Random.Range(6, 24);
				val.maxTotalScrapValue += Random.Range(400, 800);
				val.daytimeEnemySpawnChanceThroughDay = new AnimationCurve((Keyframe[])(object)new Keyframe[2]
				{
					new Keyframe(0f, 5f),
					new Keyframe(0.5f, 5f)
				});
				val.enemySpawnChanceThroughoutDay = new AnimationCurve((Keyframe[])(object)new Keyframe[1]
				{
					new Keyframe(0f, 256f)
				});
			}
			else if (UseDefaultGameSettings)
			{
				Mls.LogInfo((object)"Default settings");
			}
			else
			{
				val.maxEnemyPowerCount = MaxEnemyPowerCount;
				val.maxOutsideEnemyPowerCount = MaxOutsideEnemyPowerCount;
				val.maxDaytimeEnemyPowerCount = MaxDaytimeEnemyPowerCount;
				val.minScrap = MinScrap;
				val.maxScrap = MaxScrap;
				val.minTotalScrapValue = MinTotalScrapValue;
				val.maxTotalScrapValue = MaxTotalScrapValue;
				val.enemySpawnChanceThroughoutDay = new AnimationCurve((Keyframe[])(object)new Keyframe[1]
				{
					new Keyframe(0f, BunkerEnemyScale)
				});
			}
			newLevel = val;
			return true;
		}

		private static void UpdateRarity(List<SpawnableEnemyWithRarity> enemies, Dictionary<Type, int> componentRarity)
		{
			if (componentRarity.Count <= 0)
			{
				return;
			}
			foreach (SpawnableEnemyWithRarity unit in enemies)
			{
				foreach (KeyValuePair<Type, int> item in componentRarity)
				{
					if ((Object)(object)unit.enemyType.enemyPrefab.GetComponent(item.Key) == (Object)null)
					{
						continue;
					}
					if (enemies.Any((SpawnableEnemyWithRarity e) => (Object)(object)e.enemyType == (Object)(object)unit.enemyType))
					{
						unit.rarity = item.Value;
						componentRarity.Remove(item.Key);
					}
					break;
				}
			}
		}

		public static void LevelUnits(SelectableLevel n, bool turret = false, bool landmine = false)
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Expected O, but got Unknown
			Mls.LogInfo((object)$"Turret: {turret}, Landmine: {landmine}");
			AnimationCurve numberToSpawn = new AnimationCurve((Keyframe[])(object)new Keyframe[2]
			{
				new Keyframe(0f, LandMineTurretScale),
				new Keyframe(1f, 25f)
			});
			SpawnableMapObject[] spawnableMapObjects = n.spawnableMapObjects;
			foreach (SpawnableMapObject val in spawnableMapObjects)
			{
				Landmine componentInChildren = val.prefabToSpawn.GetComponentInChildren<Landmine>();
				if ((Object)(object)componentInChildren != (Object)null)
				{
					val.numberToSpawn = numberToSpawn;
				}
			}
		}

		private static void ResetLevelUnits(SelectableLevel level)
		{
			//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_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Expected O, but got Unknown
			SpawnableMapObject[] spawnableMapObjects = level.spawnableMapObjects;
			foreach (SpawnableMapObject val in spawnableMapObjects)
			{
				Landmine componentInChildren = val.prefabToSpawn.GetComponentInChildren<Landmine>();
				if ((Object)(object)componentInChildren != (Object)null)
				{
					val.numberToSpawn = new AnimationCurve((Keyframe[])(object)new Keyframe[1]
					{
						new Keyframe(0f, 2.5f)
					});
				}
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(EnemyAI), "KillEnemyServerRpc")]
		private static void EnemyBounty()
		{
			Mls.LogInfo((object)$"Enemy killed, bounty is active: {BountyIsActive}");
			if (BountyIsActive)
			{
				Terminal val = Object.FindObjectOfType<Terminal>();
				val.groupCredits += 30;
				val.SyncGroupCreditsServerRpc(val.groupCredits, val.numberOfItemsInDropship);
				HullManager.SendChatEventMessage("<color=green>Workers get paid for killing enemy</color>");
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(PlayerControllerB), "KillPlayerServerRpc")]
		private static void OneForAll()
		{
			Mls.LogInfo((object)$"Player killed, one for all is active: {OneForAllIsActive}");
			if (OneForAllIsActive)
			{
				HullManager hullManager = Object.FindObjectOfType<HullManager>();
				hullManager.timeOfDay.votedShipToLeaveEarlyThisRound = true;
				hullManager.timeOfDay.SetShipLeaveEarlyServerRpc();
				HullManager.SendChatEventMessage("<color=red>One of the workers died, the ship will go into orbit in an hour</color>");
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(GameNetworkManager), "StartHost")]
		private static void ResetDayPassed()
		{
			DaysPassed = 0;
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "HullBreakerCompany";

		public const string PLUGIN_NAME = "HullBreakerCompany";

		public const string PLUGIN_VERSION = "1.3.9";
	}
}
namespace HullBreakerCompany.Hull
{
	public class ConfigManager
	{
		private static string _configPath = Path.Combine(Paths.ConfigPath, "HullBreakerCompany.cfg");

		private static ConfigFile _configFile;

		public static T GetConfigValue<T>(string key, T defaultValue, string description = null)
		{
			EnsureConfigExists();
			return _configFile.Bind<T>("Settings", key, defaultValue, description).Value;
		}

		public static void SetConfigValue()
		{
			Plugin.LandMineTurretScale = GetConfigValue("LandMineTurretScale", 64, "Should change amount of Landmines & Turrets when these events are active: (Landmine & Turret)");
			Plugin.UseShortChatMessages = GetConfigValue("UseShortChatMessages", defaultValue: false, "Use short event message (one/two words), can add surprise effect & difficulty");
			Plugin.EnableEventMessages = GetConfigValue("EnableEventMessages", defaultValue: true, "Enable chat event messages");
			Plugin.UseHullBreakerLevelSettings = GetConfigValue("UseHullBreakerLevelSettings", defaultValue: true, "Use HullBreaker level settings, if false, use default level settings");
			Plugin.UseDefaultGameSettings = GetConfigValue("UseDefaultLevelSettings", defaultValue: false, "Use default level settings, if false, you can change on one's own");
			Plugin.ChangeQuotaValue = GetConfigValue("ChangeQuota", defaultValue: true, "Change quota");
			Plugin.QuotaIncrease = GetConfigValue("IncreasedQuota", 256, "Increased quota");
			Plugin.MaxEnemyPowerCount = GetConfigValue("MaxEnemyPowerCount", 10, "Max enemy power count");
			Plugin.MaxOutsideEnemyPowerCount = GetConfigValue("MaxOutsideEnemyPowerCount", 10, "Max outside enemy power count");
			Plugin.MaxDaytimeEnemyPowerCount = GetConfigValue("MaxDaytimeEnemyPowerCount", 20, "Max daytime enemy power count");
			Plugin.MinScrap = GetConfigValue("MinScrap", 10, "Min scrap");
			Plugin.MaxScrap = GetConfigValue("MaxScrap", 15, "Max scrap");
			Plugin.MinTotalScrapValue = GetConfigValue("MinTotalScrapValue", 300, "Min total scrap value");
			Plugin.MaxTotalScrapValue = GetConfigValue("MaxTotalScrapValue", 700, "Max total scrap value");
			Plugin.BunkerEnemyScale = GetConfigValue("BunkerEnemyScale", 256, "Should change global bunker enemy spawn rate, not sure if its work");
			Plugin.IncreaseEventCountPerDay = GetConfigValue("IncreaseEventCountPerDay", defaultValue: false, "The number of events will increase every day. Visit the company building to reset");
			Plugin.EventCount = GetConfigValue("EventCount", 3, "The number of events that will be active at the same time");
		}

		public static Dictionary<string, int> GetWeights()
		{
			EnsureConfigExists();
			Dictionary<string, int> dictionary = new Dictionary<string, int>();
			foreach (HullEvent item in Plugin.EventDictionary)
			{
				dictionary[item.ID()] = _configFile.Bind<int>("Weights", item.ID(), item.GetWeight(), item.GetDescription()).Value;
			}
			return dictionary;
		}

		private static void EnsureConfigExists()
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Expected O, but got Unknown
			if (_configFile == null)
			{
				if (!File.Exists(_configPath))
				{
					CreateDefaultConfigFile();
				}
				_configFile = new ConfigFile(_configPath, true);
			}
		}

		private static void CreateDefaultConfigFile()
		{
			using StreamWriter streamWriter = File.CreateText(_configPath);
			streamWriter.WriteLine("[Weights]");
			foreach (HullEvent item in Plugin.EventDictionary)
			{
				streamWriter.WriteLine(item.ID() + "=" + item.GetWeight());
			}
		}
	}
	public class CustomEventLoader
	{
		public static void LoadCustomEvents()
		{
			List<Dictionary<string, string>> list = LoadEventDataFromCfgFiles();
			if (list.Count == 0)
			{
				return;
			}
			foreach (Dictionary<string, string> item in list)
			{
				CustomEvent customEvent = new CustomEvent();
				customEvent.SetID(item["EventID"]);
				customEvent.SetWeight(int.Parse(item["EventWeight"]));
				customEvent.Rarity = int.Parse(item["EnemyRarity"]);
				if (item.ContainsKey("SpawnableEnemies"))
				{
					customEvent.EnemySpawnList = new HashSet<string>(item["SpawnableEnemies"].Split(',')).ToList();
				}
				if (item.ContainsKey("SpawnableOutsideEnemies"))
				{
					customEvent.OutsideSpawnList = new HashSet<string>(item["SpawnableOutsideEnemies"].Split(',')).ToList();
				}
				customEvent.SetMessage(item["InGameMessage"]);
				customEvent.SetShortMessage(item["InGameShortMessage"]);
				Plugin.EventDictionary.Add(customEvent);
			}
		}

		private static List<Dictionary<string, string>> LoadEventDataFromCfgFiles()
		{
			string text = Paths.BepInExRootPath + "\\HullEvents";
			if (!Directory.Exists(text))
			{
				Plugin.Mls.LogError((object)("Directory does not exist: " + text));
				return new List<Dictionary<string, string>>();
			}
			string[] files = Directory.GetFiles(text, "*.cfg");
			List<Dictionary<string, string>> list = new List<Dictionary<string, string>>();
			string[] array = files;
			foreach (string path in array)
			{
				string[] array2 = File.ReadAllLines(path);
				Dictionary<string, string> dictionary = new Dictionary<string, string>();
				string[] array3 = array2;
				foreach (string text2 in array3)
				{
					if (!text2.StartsWith("[") && !string.IsNullOrWhiteSpace(text2))
					{
						string[] array4 = text2.Split('=');
						if (array4.Length == 2)
						{
							string key = array4[0].Trim();
							string value = array4[1].Trim();
							dictionary[key] = value;
						}
					}
				}
				list.Add(dictionary);
				Plugin.Mls.LogInfo((object)("Loaded event: " + dictionary["EventID"]));
			}
			return list;
		}

		public static void AddEvent(HullEvent newEvent)
		{
			Plugin.Mls.LogInfo((object)("Adding new event" + newEvent.ID() + " to dictionary"));
			Plugin.EventDictionary.Add(newEvent);
		}

		public static void DebugLoadCustomEvents()
		{
			foreach (HullEvent item in Plugin.EventDictionary)
			{
				if (item is CustomEvent customEvent)
				{
					Plugin.Mls.LogInfo((object)("Event ID: " + customEvent.ID()));
					Plugin.Mls.LogInfo((object)("Spawnable Enemies: " + string.Join(", ", customEvent.EnemySpawnList)));
					Plugin.Mls.LogInfo((object)("Message: " + customEvent.GetMessage()));
				}
			}
		}
	}
	public abstract class HullEvent
	{
		public abstract string ID();

		public virtual int GetWeight()
		{
			return 1;
		}

		public virtual string GetDescription()
		{
			return "Default description";
		}

		public virtual string GetMessage()
		{
			return "Default message";
		}

		public virtual string GetShortMessage()
		{
			return "SHORT";
		}

		public virtual void Execute(SelectableLevel level, Dictionary<Type, int> enemyComponentRarity, Dictionary<Type, int> outsideComponentRarity)
		{
		}
	}
	public class HullManager : MonoBehaviour
	{
		public TimeOfDay timeOfDay;

		public static HullManager Instance { get; private set; }

		public void Update()
		{
			if ((Object)(object)timeOfDay == (Object)null)
			{
				timeOfDay = Object.FindFirstObjectByType<TimeOfDay>();
			}
			else if (Plugin.ChangeQuotaValue)
			{
				timeOfDay.quotaVariables.baseIncrease = Plugin.QuotaIncrease;
			}
		}

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
				Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject);
			}
			else
			{
				Object.Destroy((Object)(object)((Component)this).gameObject);
			}
		}

		public void AddMoney(int amount)
		{
			Terminal val = Object.FindObjectOfType<Terminal>();
			val.groupCredits += amount;
			val.SyncGroupCreditsServerRpc(val.groupCredits, val.numberOfItemsInDropship);
		}

		public void ExecuteAfterDelay(Action action, float delay)
		{
			((MonoBehaviour)this).StartCoroutine(DelayedExecution(action, delay));
		}

		private IEnumerator DelayedExecution(Action action, float delay)
		{
			yield return (object)new WaitForSeconds(delay);
			action();
		}

		public static void SendChatEventMessage(HullEvent hullEvent)
		{
			if ((Object)(object)HUDManager.Instance != (Object)null && hullEvent != null && Plugin.EnableEventMessages)
			{
				HUDManager.Instance.AddTextToChatOnServer(Plugin.UseShortChatMessages ? hullEvent.GetShortMessage() : hullEvent.GetMessage(), -1);
			}
		}

		public static void SendChatEventMessage(string message)
		{
			if ((Object)(object)HUDManager.Instance != (Object)null && message != null && Plugin.EnableEventMessages)
			{
				HUDManager.Instance.AddTextToChatOnServer(message, -1);
			}
		}

		public static void LogEnemyRarity(List<SpawnableEnemyWithRarity> enemies, string title)
		{
			Plugin.Mls.LogInfo((object)"");
			Plugin.Mls.LogInfo((object)title);
			foreach (SpawnableEnemyWithRarity enemy in enemies)
			{
				Plugin.Mls.LogInfo((object)$"{((Object)enemy.enemyType.enemyPrefab).name} - {enemy.rarity}");
			}
		}
	}
	public abstract class RandomSelector
	{
		private static Random _random = new Random();

		public static List<string> GetRandomGameEvents()
		{
			int count = (Plugin.IncreaseEventCountPerDay ? Plugin.DaysPassed : Plugin.EventCount);
			return GetWeightedRandomGameEvents(ConfigManager.GetWeights(), count);
		}

		private static List<T> GetWeightedRandomGameEvents<T>(Dictionary<T, int> weights, int count)
		{
			int maxValue = weights.Where((KeyValuePair<T, int> x) => x.Value > 0).Sum((KeyValuePair<T, int> x) => x.Value);
			HashSet<T> hashSet = new HashSet<T>();
			while (hashSet.Count < count)
			{
				int num = _random.Next(maxValue);
				foreach (KeyValuePair<T, int> weight in weights)
				{
					if (weight.Value != 0)
					{
						if (num < weight.Value)
						{
							hashSet.Add(weight.Key);
							break;
						}
						num -= weight.Value;
					}
				}
			}
			return hashSet.ToList();
		}

		private static void Shuffle<T>(IList<T> list)
		{
			int num = list.Count;
			while (num > 1)
			{
				num--;
				int num2 = _random.Next(num + 1);
				int index = num2;
				int index2 = num;
				T val = list[num];
				T val2 = list[num2];
				T val4 = (list[index] = val);
				val4 = (list[index2] = val2);
			}
		}
	}
	public class SelectableLevelState
	{
		public int MinScrap;

		public int MaxScrap;

		public int MinTotalScrapValue;

		public int MaxTotalScrapValue;

		public int MaxEnemyPowerCount = 8;

		public int MaxOutsideEnemyPowerCount = 15;

		public int MaxDaytimeEnemyPowerCount = 20;

		public AnimationCurve EnemySpawnChanceThroughoutDay;

		public AnimationCurve OutsideEnemySpawnChanceThroughDay;

		public AnimationCurve DaytimeEnemySpawnChanceThroughDay;

		public List<SpawnableEnemyWithRarity> EnemyList = new List<SpawnableEnemyWithRarity>();

		public List<SpawnableEnemyWithRarity> OutsideEnemyList = new List<SpawnableEnemyWithRarity>();

		public List<SpawnableEnemyWithRarity> DaytimeEnemyList = new List<SpawnableEnemyWithRarity>();

		public SelectableLevelState(SelectableLevel level)
		{
			MinScrap = level.minScrap;
			MaxScrap = level.maxScrap;
			MinTotalScrapValue = level.minTotalScrapValue;
			MaxTotalScrapValue = level.maxTotalScrapValue;
			MaxEnemyPowerCount = level.maxEnemyPowerCount;
			MaxOutsideEnemyPowerCount = level.maxOutsideEnemyPowerCount;
			MaxDaytimeEnemyPowerCount = level.maxDaytimeEnemyPowerCount;
			EnemySpawnChanceThroughoutDay = level.enemySpawnChanceThroughoutDay;
			OutsideEnemySpawnChanceThroughDay = level.outsideEnemySpawnChanceThroughDay;
			DaytimeEnemySpawnChanceThroughDay = level.daytimeEnemySpawnChanceThroughDay;
			CloneEnemies(level.Enemies, EnemyList);
			CloneEnemies(level.OutsideEnemies, OutsideEnemyList);
			CloneEnemies(level.DaytimeEnemies, DaytimeEnemyList);
		}

		public void RestoreState(SelectableLevel level)
		{
			level.minScrap = MinScrap;
			level.maxScrap = MaxScrap;
			level.minTotalScrapValue = MinTotalScrapValue;
			level.maxTotalScrapValue = MaxTotalScrapValue;
			level.maxEnemyPowerCount = MaxEnemyPowerCount;
			level.maxOutsideEnemyPowerCount = MaxOutsideEnemyPowerCount;
			level.maxDaytimeEnemyPowerCount = MaxDaytimeEnemyPowerCount;
			level.enemySpawnChanceThroughoutDay = EnemySpawnChanceThroughoutDay;
			level.outsideEnemySpawnChanceThroughDay = OutsideEnemySpawnChanceThroughDay;
			level.daytimeEnemySpawnChanceThroughDay = DaytimeEnemySpawnChanceThroughDay;
			level.Enemies.Clear();
			CloneEnemies(EnemyList, level.Enemies);
			level.OutsideEnemies.Clear();
			CloneEnemies(OutsideEnemyList, level.OutsideEnemies);
			level.DaytimeEnemies.Clear();
			CloneEnemies(DaytimeEnemyList, level.DaytimeEnemies);
		}

		private void CloneEnemies(List<SpawnableEnemyWithRarity> source, List<SpawnableEnemyWithRarity> destination)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Expected O, but got Unknown
			foreach (SpawnableEnemyWithRarity item2 in source)
			{
				SpawnableEnemyWithRarity item = new SpawnableEnemyWithRarity
				{
					enemyType = item2.enemyType,
					rarity = item2.rarity
				};
				destination.Add(item);
			}
		}
	}
}
namespace HullBreakerCompany.Events
{
	public class ArachnophobiaEvent : HullEvent
	{
		public override string ID()
		{
			return "Arachnophobia";
		}

		public override int GetWeight()
		{
			return 20;
		}

		public override string GetDescription()
		{
			return "Increased chance of spider spawning";
		}

		public override string GetMessage()
		{
			return "<color=white>Possible habitat of spiders</color>";
		}

		public override string GetShortMessage()
		{
			return "<color=white>ARACHNOPHOBIA</color>";
		}

		public override void Execute(SelectableLevel level, Dictionary<Type, int> enemyComponentRarity, Dictionary<Type, int> outsideComponentRarity)
		{
			enemyComponentRarity.Add(typeof(SandSpiderAI), 256);
			HullManager.SendChatEventMessage(this);
		}
	}
	public class BabkinPogrebEvent : HullEvent
	{
		public override string ID()
		{
			return "BabkinPogreb";
		}

		public override int GetWeight()
		{
			return 10;
		}

		public override string GetDescription()
		{
			return "Only jars of pickles spawn on the moon";
		}

		public override string GetMessage()
		{
			return "<color=white>On the this moon, something strange happened with scrap...</color>";
		}

		public override string GetShortMessage()
		{
			return "<color=white>ITEM MYSTERY</color>";
		}

		public override void Execute(SelectableLevel level, Dictionary<Type, int> enemyComponentRarity, Dictionary<Type, int> outsideComponentRarity)
		{
			try
			{
				if ((Object)(object)HullManager.Instance == (Object)null)
				{
					Plugin.Mls.LogError((object)"HullManager.Instance is null");
					return;
				}
				if ((Object)(object)level == (Object)null)
				{
					Plugin.Mls.LogError((object)"level is null");
					return;
				}
				level.spawnableScrap.RemoveAll((SpawnableItemWithRarity item) => item.spawnableItem.itemName != "Jar of pickles");
				if (level.spawnableScrap.Count == 0)
				{
					Plugin.Mls.LogError((object)"No jars of pickles found in spawnableScrap list!");
					DelayedReturnList(level);
					return;
				}
				foreach (SpawnableItemWithRarity item in level.spawnableScrap.Where((SpawnableItemWithRarity item) => item.spawnableItem.itemName == "Jar of pickles"))
				{
					item.rarity = 100;
				}
				HullManager.Instance.ExecuteAfterDelay(delegate
				{
					DelayedReturnList(level);
				}, 12f);
				HullManager.SendChatEventMessage(this);
			}
			catch (ArgumentOutOfRangeException ex)
			{
				Plugin.Mls.LogError((object)("ArgumentOutOfRangeException caught in BabkinPogrebEvent.Execute: " + ex.Message));
			}
		}

		private void DelayedReturnList(SelectableLevel level)
		{
			Plugin.Mls.LogInfo((object)"Resetting spawnable items...");
			level.spawnableScrap.Clear();
			foreach (SpawnableItemWithRarity item in Plugin.NotModifiedSpawnableItemsWithRarity)
			{
				level.spawnableScrap.Add(item);
			}
		}
	}
	public class BeeEvent : HullEvent
	{
		public override string ID()
		{
			return "Bee";
		}

		public override int GetWeight()
		{
			return 30;
		}

		public override string GetDescription()
		{
			return "Increased chance of bee hives spawning";
		}

		public override string GetMessage()
		{
			return "<color=white>Possibly a large amount of bee hives</color>";
		}

		public override string GetShortMessage()
		{
			return "<color=white>ANNOYING BUZZING</color>";
		}

		public override void Execute(SelectableLevel level, Dictionary<Type, int> enemyComponentRarity, Dictionary<Type, int> outsideComponentRarity)
		{
			using (IEnumerator<SpawnableEnemyWithRarity> enumerator = level.DaytimeEnemies.Where((SpawnableEnemyWithRarity unit) => (Object)(object)unit.enemyType.enemyPrefab.GetComponent<RedLocustBees>() != (Object)null).GetEnumerator())
			{
				if (enumerator.MoveNext())
				{
					SpawnableEnemyWithRarity current = enumerator.Current;
					current.rarity = 256;
				}
			}
			HullManager.SendChatEventMessage(this);
		}
	}
	public class CustomEvent : HullEvent
	{
		private string _id;

		private int _weight;

		private string _message;

		private string _shortMessage;

		public List<string> EnemySpawnList = new List<string>();

		public List<string> OutsideSpawnList = new List<string>();

		public int Rarity = 1;

		public override string ID()
		{
			return _id;
		}

		public void SetID(string value)
		{
			_id = value;
		}

		public void SetWeight(int value)
		{
			_weight = value;
		}

		public override int GetWeight()
		{
			return _weight;
		}

		public void SetMessage(string value)
		{
			_message = value;
		}

		public void SetShortMessage(string value)
		{
			_shortMessage = value;
		}

		public override string GetMessage()
		{
			return _message;
		}

		public override string GetShortMessage()
		{
			return _shortMessage;
		}

		public override void Execute(SelectableLevel level, Dictionary<Type, int> componentRarity, Dictionary<Type, int> outsideComponentRarity)
		{
			foreach (string item in EnemySpawnList.TakeWhile((string enemy) => enemy != "off"))
			{
				componentRarity.Add(Plugin.EnemyBase[item], Rarity);
			}
			foreach (string item2 in OutsideSpawnList.TakeWhile((string enemy) => enemy != "off"))
			{
				outsideComponentRarity.Add(Plugin.EnemyBase[item2], Rarity);
			}
			HullManager.SendChatEventMessage(Plugin.UseShortChatMessages ? GetShortMessage() : GetMessage());
		}
	}
	public class DevochkaPizdecEvent : HullEvent
	{
		public override string ID()
		{
			return "DevochkaPizdec";
		}

		public override int GetWeight()
		{
			return 5;
		}

		public override string GetDescription()
		{
			return "Increased chance of phantom girl spawn";
		}

		public override string GetMessage()
		{
			return "<color=white>A lot of workers are going crazy here</color>";
		}

		public override string GetShortMessage()
		{
			return "<color=white>COTARD SYNDROME</color>";
		}

		public override void Execute(SelectableLevel level, Dictionary<Type, int> enemyComponentRarity, Dictionary<Type, int> outsideComponentRarity)
		{
			enemyComponentRarity.Add(typeof(DressGirlAI), 32);
			HullManager.SendChatEventMessage(this);
		}
	}
	public class EnemyBountyEvent : HullEvent
	{
		public override string ID()
		{
			return "EnemyBounty";
		}

		public override int GetWeight()
		{
			return 50;
		}

		public override string GetDescription()
		{
			return "Company pays money for killing the enemies / 60 per enemy";
		}

		public override string GetMessage()
		{
			return "<color=white>Company pays money for killing the enemies!</color>";
		}

		public override string GetShortMessage()
		{
			return "<color=white>ENEMY BOUNTY</color>";
		}

		public override void Execute(SelectableLevel level, Dictionary<Type, int> enemyComponentRarity, Dictionary<Type, int> outsideComponentRarity)
		{
			Plugin.BountyIsActive = true;
			HullManager.SendChatEventMessage(this);
		}
	}
	public class FlowerManEvent : HullEvent
	{
		public override string ID()
		{
			return "FlowerMan";
		}

		public override int GetWeight()
		{
			return 20;
		}

		public override string GetDescription()
		{
			return "Increased chance of flowerman spawn";
		}

		public override string GetMessage()
		{
			return "<color=white>So many eyes in the dark, carefully</color>";
		}

		public override string GetShortMessage()
		{
			return "<color=white>WHITE EYES...</color>";
		}

		public override void Execute(SelectableLevel level, Dictionary<Type, int> enemyComponentRarity, Dictionary<Type, int> outsideComponentRarity)
		{
			enemyComponentRarity.Add(typeof(FlowermanAI), 256);
			HullManager.SendChatEventMessage(this);
		}
	}
	public class HackedTurretsEvent : HullEvent
	{
		public override string ID()
		{
			return "HackedTurrets";
		}

		public override int GetWeight()
		{
			return 10;
		}

		public override string GetDescription()
		{
			return "Turrets dont work on the moon";
		}

		public override string GetMessage()
		{
			return "<color=white>The company's hackers have disabled all turrets on this moon, you can breathe easy</color>";
		}

		public override string GetShortMessage()
		{
			return "<color=white>SYSTEM FAILURE</color>";
		}

		public override void Execute(SelectableLevel level, Dictionary<Type, int> enemyComponentRarity, Dictionary<Type, int> outsideComponentRarity)
		{
			if ((Object)(object)HullManager.Instance == (Object)null)
			{
				Plugin.Mls.LogError((object)"HullManager.Instance is null");
				return;
			}
			if ((Object)(object)level == (Object)null)
			{
				Plugin.Mls.LogError((object)"level is null");
				return;
			}
			HullManager.Instance.ExecuteAfterDelay(delegate
			{
				HackTurrets();
			}, 16f);
			HullManager.SendChatEventMessage(this);
		}

		private void HackTurrets()
		{
			Turret[] array = Object.FindObjectsOfType<Turret>();
			Turret[] array2 = array;
			foreach (Turret val in array2)
			{
				val.ToggleTurretServerRpc(false);
			}
		}
	}
	public class HellEvent : HullEvent
	{
		public override string ID()
		{
			return "Hell";
		}

		public override int GetWeight()
		{
			return 1;
		}

		public override string GetDescription()
		{
			return "Increased chance of spawning Jester and more enemies";
		}

		public override string GetMessage()
		{
			return "<color=orange>It says here that there is total hell happening on the this moon</color>";
		}

		public override string GetShortMessage()
		{
			return "<color=white>HELL</color>";
		}

		public override void Execute(SelectableLevel level, Dictionary<Type, int> enemyComponentRarity, Dictionary<Type, int> outsideComponentRarity)
		{
			enemyComponentRarity.Add(typeof(JesterAI), 64);
			HullManager.SendChatEventMessage(this);
			RoundManager.Instance.hourTimeBetweenEnemySpawnBatches = 1;
			HullManager.Instance.ExecuteAfterDelay(delegate
			{
				Hell();
			}, 16f);
		}

		private void Hell()
		{
			EnemyVent[] array = Object.FindObjectsOfType<EnemyVent>();
			for (int i = 0; i < 8; i++)
			{
				if (array.Length != 0)
				{
					EnemyVent val = array[Random.Range(0, array.Length)];
					RoundManager.Instance.SpawnEnemyFromVent(val);
				}
			}
		}
	}
	public class HoarderBugEvent : HullEvent
	{
		public override string ID()
		{
			return "HoarderBug";
		}

		public override int GetWeight()
		{
			return 50;
		}

		public override string GetDescription()
		{
			return "Increased chance of hoarder bug spawn";
		}

		public override string GetMessage()
		{
			return "<color=white>Keep an eye on the loot, Hoarding Bugs nearby</color>";
		}

		public override string GetShortMessage()
		{
			return "<color=white>BUG INVASION</color>";
		}

		public override void Execute(SelectableLevel level, Dictionary<Type, int> enemyComponentRarity, Dictionary<Type, int> outsideComponentRarity)
		{
			enemyComponentRarity.Add(typeof(HoarderBugAI), 512);
			HullManager.SendChatEventMessage(this);
		}
	}
	public class HullBreakEvent : HullEvent
	{
		public override string ID()
		{
			return "HullBreak";
		}

		public override int GetWeight()
		{
			return 5;
		}

		public override string GetDescription()
		{
			return "Getting money for visiting this moon";
		}

		public override string GetMessage()
		{
			return "<color=green>Take a break, the company is sending money for visiting the moon</color>";
		}

		public override string GetShortMessage()
		{
			return "<color=white>TAKE A BREAK</color>";
		}

		public override void Execute(SelectableLevel level, Dictionary<Type, int> enemyComponentRarity, Dictionary<Type, int> outsideComponentRarity)
		{
			HullManager.Instance.AddMoney(120);
			HullManager.SendChatEventMessage(this);
		}
	}
	public class LandMineEvent : HullEvent
	{
		public override string ID()
		{
			return "LandMine";
		}

		public override int GetWeight()
		{
			return 30;
		}

		public override string GetDescription()
		{
			return "Increased chance of landmines spawning";
		}

		public override string GetMessage()
		{
			return "<color=white>Watch your step, there are a lot of landmines</color>";
		}

		public override string GetShortMessage()
		{
			return "<color=white>LANDMINE</color>";
		}

		public override void Execute(SelectableLevel level, Dictionary<Type, int> enemyComponentRarity, Dictionary<Type, int> outsideComponentRarity)
		{
			Plugin.LevelUnits(level, turret: false, landmine: true);
			HullManager.SendChatEventMessage(this);
		}
	}
	public class LizardsEvent : HullEvent
	{
		public override string ID()
		{
			return "Lizards";
		}

		public override int GetWeight()
		{
			return 15;
		}

		public override string GetDescription()
		{
			return "Increased chance of puffers spawn";
		}

		public override string GetMessage()
		{
			return "<color=white>Horrible smell from toxic lizards</color>";
		}

		public override string GetShortMessage()
		{
			return "<color=white>LIZARDSSS</color>";
		}

		public override void Execute(SelectableLevel level, Dictionary<Type, int> enemyComponentRarity, Dictionary<Type, int> outsideComponentRarity)
		{
			enemyComponentRarity.Add(typeof(PufferAI), 64);
			HullManager.SendChatEventMessage(this);
		}
	}
	public class NothingEvent : HullEvent
	{
		public override string ID()
		{
			return "Nothing";
		}

		public override int GetWeight()
		{
			return 60;
		}

		public override string GetDescription()
		{
			return "Nothing happens";
		}

		public override string GetMessage()
		{
			return "<color=white>---</color>";
		}

		public override string GetShortMessage()
		{
			return "<color=white>---</color>";
		}

		public override void Execute(SelectableLevel level, Dictionary<Type, int> enemyComponentRarity, Dictionary<Type, int> outsideComponentRarity)
		{
			HullManager.SendChatEventMessage(this);
		}
	}
	public class NutcrackerEvent : HullEvent
	{
		public override string ID()
		{
			return "Nutcracker";
		}

		public override int GetWeight()
		{
			return 5;
		}

		public override string GetDescription()
		{
			return "Increased chance of NutCracker spawn";
		}

		public override string GetMessage()
		{
			return "<color=white>NutCrackers detected in the area!</color>";
		}

		public override string GetShortMessage()
		{
			return "<color=orange>NUTCRACKERS INCOMING</color>";
		}

		public override void Execute(SelectableLevel level, Dictionary<Type, int> enemyComponentRarity, Dictionary<Type, int> outsideComponentRarity)
		{
			enemyComponentRarity.Add(typeof(NutcrackerEnemyAI), 64);
			HullManager.SendChatEventMessage(this);
		}
	}
	public class OnAPowderKegEvent : HullEvent
	{
		public override string ID()
		{
			return "OnAPowderKeg";
		}

		public override int GetWeight()
		{
			return 10;
		}

		public override string GetDescription()
		{
			return "Landmines can detonate at any time";
		}

		public override string GetMessage()
		{
			return "<color=red>CAUTION,</color> <color=white>landmines can detonate at any time</color>";
		}

		public override string GetShortMessage()
		{
			return "<color=red>ON A POWDER KEG</color>";
		}

		public override void Execute(SelectableLevel level, Dictionary<Type, int> enemyComponentRarity, Dictionary<Type, int> outsideComponentRarity)
		{
			HullManager.Instance.ExecuteAfterDelay(delegate
			{
				DetonateLandMine();
			}, Random.Range(30, 680));
			HullManager.SendChatEventMessage(this);
		}

		private void DetonateLandMine()
		{
			Landmine[] array = Object.FindObjectsOfType<Landmine>();
			Landmine[] array2 = array;
			foreach (Landmine val in array2)
			{
				val.ExplodeMineServerRpc();
			}
		}
	}
	public class OneForAllEvent : HullEvent
	{
		public override string ID()
		{
			return "OneForAll";
		}

		public override int GetWeight()
		{
			return 5;
		}

		public override string GetDescription()
		{
			return "The ship will fly into orbit in an hour if one of the workers dies";
		}

		public override string GetMessage()
		{
			return "<color=white>The ship will fly into orbit in an hour if one of the workers dies</color>";
		}

		public override string GetShortMessage()
		{
			return "<color=red>ONE FOR ALL!</color>";
		}

		public override void Execute(SelectableLevel level, Dictionary<Type, int> enemyComponentRarity, Dictionary<Type, int> outsideComponentRarity)
		{
			Plugin.OneForAllIsActive = true;
			HullManager.SendChatEventMessage(this);
		}
	}
	public class OpenTheNoorEvent : HullEvent
	{
		public override string ID()
		{
			return "OpenTheNoor";
		}

		public override int GetWeight()
		{
			return 25;
		}

		public override string GetDescription()
		{
			return "All big doors are locked in the level";
		}

		public override string GetMessage()
		{
			return "<color=white>All big doors are locked in the level</color>";
		}

		public override string GetShortMessage()
		{
			return "<color=white>OPEN THE NOOR...</color>";
		}

		public override void Execute(SelectableLevel level, Dictionary<Type, int> enemyComponentRarity, Dictionary<Type, int> outsideComponentRarity)
		{
			if ((Object)(object)HullManager.Instance == (Object)null)
			{
				Plugin.Mls.LogError((object)"HullManager.Instance is null");
				return;
			}
			if ((Object)(object)level == (Object)null)
			{
				Plugin.Mls.LogError((object)"level is null");
				return;
			}
			HullManager.Instance.ExecuteAfterDelay(delegate
			{
				CloseBigDoors();
			}, 16f);
			HullManager.SendChatEventMessage(this);
		}

		private void CloseBigDoors()
		{
			TerminalAccessibleObject[] array = Object.FindObjectsOfType<TerminalAccessibleObject>();
			TerminalAccessibleObject[] array2 = array;
			foreach (TerminalAccessibleObject val in array2)
			{
				val.SetDoorOpenServerRpc(false);
			}
		}
	}
	public class OutSideEnemyDayEvent : HullEvent
	{
		public override string ID()
		{
			return "OutSideEnemyDay";
		}

		public override int GetWeight()
		{
			return 3;
		}

		public override string GetDescription()
		{
			return "Increased amount of enemies on the surface during the daytime";
		}

		public override string GetMessage()
		{
			return "<color=white>Increased amount of enemies on the surface during the daytime</color>";
		}

		public override string GetShortMessage()
		{
			return "<color=red>SILENCE SEASON</color>";
		}

		public override void Execute(SelectableLevel level, Dictionary<Type, int> enemyComponentRarity, Dictionary<Type, int> outsideComponentRarity)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Expected O, but got Unknown
			level.outsideEnemySpawnChanceThroughDay = new AnimationCurve((Keyframe[])(object)new Keyframe[1]
			{
				new Keyframe(0f, 512f)
			});
			HullManager.SendChatEventMessage(this);
		}
	}
	public class SlimeEvent : HullEvent
	{
		public override string ID()
		{
			return "Slime";
		}

		public override int GetWeight()
		{
			return 20;
		}

		public override string GetDescription()
		{
			return "Increased chance of slime spawn";
		}

		public override string GetMessage()
		{
			return "<color=white>Inhabited with slime</color>";
		}

		public override string GetShortMessage()
		{
			return "<color=white>SO SLIMY</color>";
		}

		public override void Execute(SelectableLevel level, Dictionary<Type, int> enemyComponentRarity, Dictionary<Type, int> outsideComponentRarity)
		{
			enemyComponentRarity.Add(typeof(BlobAI), 48);
			HullManager.SendChatEventMessage(this);
		}
	}
	public class SpringManEvent : HullEvent
	{
		public override string ID()
		{
			return "SpringMan";
		}

		public override int GetWeight()
		{
			return 10;
		}

		public override string GetDescription()
		{
			return "Increased chance of spring man spawning (coil-head)";
		}

		public override string GetMessage()
		{
			return "<color=white>It's impossible not to look at them</color>";
		}

		public override string GetShortMessage()
		{
			return "<color=white>SKULL COILS</color>";
		}

		public override void Execute(SelectableLevel level, Dictionary<Type, int> enemyComponentRarity, Dictionary<Type, int> outsideComponentRarity)
		{
			enemyComponentRarity.Add(typeof(SpringManAI), 128);
			HullManager.SendChatEventMessage(this);
		}
	}
	public class TurretEvent : HullEvent
	{
		public override string ID()
		{
			return "Turret";
		}

		public override int GetWeight()
		{
			return 5;
		}

		public override string GetDescription()
		{
			return "Increased chance of turrets spawning";
		}

		public override string GetMessage()
		{
			return "<color=white>Alert, turrets detected</color>";
		}

		public override string GetShortMessage()
		{
			return "<color=white>TURRETS</color>";
		}

		public override void Execute(SelectableLevel level, Dictionary<Type, int> enemyComponentRarity, Dictionary<Type, int> outsideComponentRarity)
		{
			Plugin.LevelUnits(level, turret: true);
			HullManager.SendChatEventMessage(this);
		}
	}
}

BepInEx/plugins/LateCompanyV1.0.6.dll

Decompiled 2 years ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Unity.Netcode;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.6", FrameworkDisplayName = ".NET Framework 4.6")]
[assembly: AssemblyCompany("LateCompany")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+31dbb98cfa5670c23f3ffb21c05582c54159b82d")]
[assembly: AssemblyProduct("LateCompany")]
[assembly: AssemblyTitle("LateCompany")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace LateCompany
{
	public static class PluginInfo
	{
		public const string GUID = "twig.latecompany";

		public const string PrintName = "Late Company";

		public const string Version = "1.0.6";
	}
	[BepInPlugin("twig.latecompany", "Late Company", "1.0.6")]
	internal class Plugin : BaseUnityPlugin
	{
		private ConfigEntry<bool> configLateJoinOrbitOnly;

		public static bool OnlyLateJoinInOrbit = false;

		public static bool LobbyJoinable = true;

		public void Awake()
		{
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Expected O, but got Unknown
			configLateJoinOrbitOnly = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Late join orbit only", true, "Don't allow joining while the ship is not in orbit.");
			OnlyLateJoinInOrbit = configLateJoinOrbitOnly.Value;
			Harmony val = new Harmony("twig.latecompany");
			val.PatchAll(typeof(Plugin).Assembly);
			((BaseUnityPlugin)this).Logger.Log((LogLevel)16, (object)"Late Company loaded!");
		}

		public static void SetLobbyJoinable(bool joinable)
		{
			LobbyJoinable = joinable;
			GameNetworkManager.Instance.SetLobbyJoinable(joinable);
			QuickMenuManager val = Object.FindObjectOfType<QuickMenuManager>();
			if (Object.op_Implicit((Object)(object)val))
			{
				val.inviteFriendsTextAlpha.alpha = (joinable ? 1f : 0.2f);
			}
		}
	}
}
namespace LateCompany.Patches
{
	[HarmonyPatch(typeof(GameNetworkManager), "LeaveLobbyAtGameStart")]
	[HarmonyWrapSafe]
	internal static class LeaveLobbyAtGameStart_Patch
	{
		[HarmonyPrefix]
		private static bool Prefix()
		{
			return false;
		}
	}
	[HarmonyPatch(typeof(GameNetworkManager), "ConnectionApproval")]
	[HarmonyWrapSafe]
	internal static class ConnectionApproval_Patch
	{
		[HarmonyPostfix]
		private static void Postfix(ConnectionApprovalRequest request, ConnectionApprovalResponse response)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			if (request.ClientNetworkId != NetworkManager.Singleton.LocalClientId && response.Reason.Contains("Game has already started") && Plugin.LobbyJoinable)
			{
				response.Reason = "";
				response.CreatePlayerObject = false;
				response.Approved = true;
				response.Pending = false;
			}
		}
	}
	[HarmonyPatch(typeof(QuickMenuManager), "DisableInviteFriendsButton")]
	[HarmonyWrapSafe]
	internal static class DisableInviteFriendsButton_Patch
	{
		[HarmonyPrefix]
		private static bool Prefix()
		{
			return false;
		}
	}
	[HarmonyPatch(typeof(QuickMenuManager), "InviteFriendsButton")]
	[HarmonyWrapSafe]
	internal static class InviteFriendsButton_Patch
	{
		[HarmonyPrefix]
		private static bool Prefix()
		{
			if (Plugin.LobbyJoinable)
			{
				GameNetworkManager.Instance.InviteFriendsUI();
			}
			return false;
		}
	}
	internal class RpcEnum : NetworkBehaviour
	{
		public static int None => 0;

		public static int Client => 2;

		public static int Server => 1;
	}
	internal static class WeatherSync
	{
		public static bool DoOverride = false;

		public static LevelWeatherType CurrentWeather = (LevelWeatherType)(-1);
	}
	[HarmonyPatch(typeof(RoundManager), "__rpc_handler_1193916134")]
	[HarmonyWrapSafe]
	internal static class __rpc_handler_1193916134_Patch
	{
		public static FieldInfo RPCExecStage = typeof(NetworkBehaviour).GetField("__rpc_exec_stage", BindingFlags.Instance | BindingFlags.NonPublic);

		[HarmonyPrefix]
		private static bool Prefix(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			try
			{
				int num = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref num);
				int num2 = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref num2);
				int num3 = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref num3);
				WeatherSync.DoOverride = true;
				WeatherSync.CurrentWeather = (LevelWeatherType)num3;
				RPCExecStage.SetValue(target, RpcEnum.Client);
				((RoundManager)((target is RoundManager) ? target : null)).GenerateNewLevelClientRpc(num, num2);
				RPCExecStage.SetValue(target, RpcEnum.None);
			}
			catch
			{
				((FastBufferReader)(ref reader)).Seek(0);
				return true;
			}
			return false;
		}
	}
	[HarmonyPatch(typeof(RoundManager), "SetToCurrentLevelWeather")]
	[HarmonyWrapSafe]
	internal static class SetToCurrentLevelWeather_Patch
	{
		[HarmonyPrefix]
		private static bool Prefix()
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			if (!WeatherSync.DoOverride)
			{
				return true;
			}
			WeatherSync.DoOverride = false;
			TimeOfDay.Instance.currentLevelWeather = WeatherSync.CurrentWeather;
			return false;
		}
	}
	[HarmonyPatch(typeof(StartOfRound), "OnPlayerConnectedClientRpc")]
	[HarmonyWrapSafe]
	internal class OnPlayerConnectedClientRpc_Patch
	{
		public static MethodInfo BeginSendClientRpc = typeof(RoundManager).GetMethod("__beginSendClientRpc", BindingFlags.Instance | BindingFlags.NonPublic);

		public static MethodInfo EndSendClientRpc = typeof(RoundManager).GetMethod("__endSendClientRpc", BindingFlags.Instance | BindingFlags.NonPublic);

		[HarmonyPostfix]
		private static void Postfix(ulong clientId, int connectedPlayers, ulong[] connectedPlayerIdsOrdered, int assignedPlayerObjectId, int serverMoneyAmount, int levelID, int profitQuota, int timeUntilDeadline, int quotaFulfilled, int randomSeed)
		{
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: 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_00fc: 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_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0163: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_018f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
			StartOfRound instance = StartOfRound.Instance;
			PlayerControllerB val = instance.allPlayerScripts[assignedPlayerObjectId];
			if (instance.connectedPlayersAmount + 1 >= instance.allPlayerScripts.Length)
			{
				Plugin.SetLobbyJoinable(joinable: false);
			}
			val.DisablePlayerModel(instance.allPlayerObjects[assignedPlayerObjectId], true, true);
			if (((NetworkBehaviour)instance).IsServer && !instance.inShipPhase)
			{
				RoundManager instance2 = RoundManager.Instance;
				ClientRpcParams val2 = default(ClientRpcParams);
				val2.Send = new ClientRpcSendParams
				{
					TargetClientIds = new List<ulong> { clientId }
				};
				ClientRpcParams val3 = val2;
				FastBufferWriter val4 = (FastBufferWriter)BeginSendClientRpc.Invoke(instance2, new object[3] { 1193916134u, val3, 0 });
				BytePacker.WriteValueBitPacked(val4, StartOfRound.Instance.randomMapSeed);
				BytePacker.WriteValueBitPacked(val4, StartOfRound.Instance.currentLevelID);
				BytePacker.WriteValueBitPacked(val4, (short)instance2.currentLevel.currentWeather);
				EndSendClientRpc.Invoke(instance2, new object[4] { val4, 1193916134u, val3, 0 });
				FastBufferWriter val5 = (FastBufferWriter)BeginSendClientRpc.Invoke(instance2, new object[3] { 2729232387u, val3, 0 });
				EndSendClientRpc.Invoke(instance2, new object[4] { val5, 2729232387u, val3, 0 });
			}
			instance.livingPlayers = instance.connectedPlayersAmount + 1;
			for (int i = 0; i < instance.allPlayerScripts.Length; i++)
			{
				PlayerControllerB val6 = instance.allPlayerScripts[i];
				if (val6.isPlayerControlled && val6.isPlayerDead)
				{
					instance.livingPlayers--;
				}
			}
		}
	}
	[HarmonyPatch(typeof(StartOfRound), "OnPlayerDC")]
	[HarmonyWrapSafe]
	internal class OnPlayerDC_Patch
	{
		[HarmonyPostfix]
		public static void Postfix()
		{
			if (StartOfRound.Instance.inShipPhase || !Plugin.OnlyLateJoinInOrbit)
			{
				Plugin.SetLobbyJoinable(joinable: true);
			}
		}
	}
	[HarmonyPatch(typeof(StartOfRound), "StartGame")]
	[HarmonyWrapSafe]
	internal class StartGame_Patch
	{
		[HarmonyPrefix]
		public static void Prefix()
		{
			if (Plugin.OnlyLateJoinInOrbit)
			{
				Plugin.SetLobbyJoinable(joinable: false);
			}
		}
	}
	[HarmonyPatch(typeof(StartOfRound), "SetShipReadyToLand")]
	[HarmonyWrapSafe]
	internal class SetShipReadyToLand_Patch
	{
		[HarmonyPrefix]
		public static void Postfix()
		{
			if (Plugin.OnlyLateJoinInOrbit && StartOfRound.Instance.connectedPlayersAmount + 1 < StartOfRound.Instance.allPlayerScripts.Length)
			{
				Plugin.SetLobbyJoinable(joinable: true);
			}
		}
	}
}

BepInEx/plugins/LethalPresents.dll

Decompiled 2 years ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Unity.Netcode;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("LethalPresents")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("LethalPresents mod")]
[assembly: AssemblyFileVersion("1.0.3.0")]
[assembly: AssemblyInformationalVersion("1.0.3")]
[assembly: AssemblyProduct("LethalPresents")]
[assembly: AssemblyTitle("LethalPresents")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.3.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace LethalPresents
{
	[BepInPlugin("LethalPresents", "LethalPresents", "1.0.3")]
	public class LethalPresentsPlugin : BaseUnityPlugin
	{
		private readonly Harmony harmony = new Harmony("LethalPresents");

		private static bool isHost;

		private static SelectableLevel currentLevel;

		public static ManualLogSource mls;

		private static int spawnChance = 5;

		private static string[] disabledEnemies = new string[0];

		private static bool IsAllowlist = false;

		private static bool ShouldSpawnMines = false;

		private static bool ShouldSpawnTurrets = false;

		private void Awake()
		{
			mls = Logger.CreateLogSource("LethalPresents");
			mls.LogInfo((object)"Plugin LethalPresents is loaded!");
			loadConfig();
			harmony.PatchAll(typeof(LethalPresentsPlugin));
		}

		private void loadConfig()
		{
			spawnChance = ((BaseUnityPlugin)this).Config.Bind<int>("General", "SpawnChance", 5, "Chance of spawning an enemy when opening a present [0-100]").Value;
			disabledEnemies = ((BaseUnityPlugin)this).Config.Bind<string>("General", "EnemyBlocklist", "", "Enemy blocklist separated by , and without whitespaces").Value.Split(",");
			IsAllowlist = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "IsAllowlist", false, "Turns blocklist into allowlist, blocklist must contain at least one inside and one outside enemy, use at your own risk").Value;
			ShouldSpawnMines = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "ShouldSpawnMines", true, "Add mines to the spawn pool [WIP]").Value;
			ShouldSpawnTurrets = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "ShouldSpawnTurrets", true, "Add turrets to the spawn pool [WIP]").Value;
		}

		[HarmonyPatch(typeof(RoundManager), "Start")]
		[HarmonyPrefix]
		private static void setIsHost()
		{
			isHost = ((NetworkBehaviour)RoundManager.Instance).NetworkManager.IsHost;
		}

		[HarmonyPatch(typeof(RoundManager), "AdvanceHourAndSpawnNewBatchOfEnemies")]
		[HarmonyPrefix]
		private static void updateCurrentLevelInfo(ref EnemyVent[] ___allEnemyVents, ref SelectableLevel ___currentLevel)
		{
			currentLevel = ___currentLevel;
			mls.LogInfo((object)"List of spawnable enemies (inside):");
			currentLevel.Enemies.ForEach(delegate(SpawnableEnemyWithRarity e)
			{
				mls.LogInfo((object)((Object)e.enemyType).name);
			});
			mls.LogInfo((object)"List of spawnable enemies (outside):");
			currentLevel.OutsideEnemies.ForEach(delegate(SpawnableEnemyWithRarity e)
			{
				mls.LogInfo((object)((Object)e.enemyType).name);
			});
		}

		private static void chooseAndSpawnEnemy(bool inside, Vector3 pos, Vector3 player_pos)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0171: Unknown result type (might be due to invalid IL or missing references)
			//IL_017f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: Unknown result type (might be due to invalid IL or missing references)
			//IL_0186: Unknown result type (might be due to invalid IL or missing references)
			//IL_0189: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_0218: Unknown result type (might be due to invalid IL or missing references)
			//IL_0219: Unknown result type (might be due to invalid IL or missing references)
			//IL_0223: Unknown result type (might be due to invalid IL or missing references)
			//IL_0228: Unknown result type (might be due to invalid IL or missing references)
			//IL_022d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0236: Unknown result type (might be due to invalid IL or missing references)
			//IL_0237: Unknown result type (might be due to invalid IL or missing references)
			//IL_024a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0267: Unknown result type (might be due to invalid IL or missing references)
			//IL_028a: Unknown result type (might be due to invalid IL or missing references)
			//IL_028b: Unknown result type (might be due to invalid IL or missing references)
			//IL_033c: Unknown result type (might be due to invalid IL or missing references)
			//IL_033d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0347: Unknown result type (might be due to invalid IL or missing references)
			//IL_034c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0351: Unknown result type (might be due to invalid IL or missing references)
			//IL_036e: Unknown result type (might be due to invalid IL or missing references)
			//IL_036f: Unknown result type (might be due to invalid IL or missing references)
			//IL_038a: Unknown result type (might be due to invalid IL or missing references)
			ManualLogSource obj = mls;
			Vector3 val = player_pos;
			obj.LogInfo((object)("Player pos " + ((object)(Vector3)(ref val)).ToString()));
			List<SpawnableEnemyWithRarity> list = currentLevel.Enemies.Where((SpawnableEnemyWithRarity e) => disabledEnemies.Contains(e.enemyType.enemyName) ? IsAllowlist : (!IsAllowlist)).ToList();
			List<SpawnableEnemyWithRarity> list2 = currentLevel.OutsideEnemies.Where((SpawnableEnemyWithRarity e) => disabledEnemies.Contains(e.enemyType.enemyName) ? IsAllowlist : (!IsAllowlist)).ToList();
			int num = Random.Range(1, 2 + (list2.Count + list.Count) / 2);
			if (num == 2 && !ShouldSpawnMines)
			{
				num = 1;
			}
			if (num == 1 && !ShouldSpawnTurrets)
			{
				num = 2;
			}
			if (num == 2 && !ShouldSpawnMines)
			{
				num = 3;
			}
			switch (num)
			{
			case 1:
			{
				SpawnableMapObject[] spawnableMapObjects2 = currentLevel.spawnableMapObjects;
				foreach (SpawnableMapObject val4 in spawnableMapObjects2)
				{
					if (!((Object)(object)val4.prefabToSpawn.GetComponentInChildren<Turret>() == (Object)null))
					{
						pos -= Vector3.up * 1.8f;
						GameObject val5 = Object.Instantiate<GameObject>(val4.prefabToSpawn, pos, Quaternion.identity);
						val5.transform.position = pos;
						Transform transform = val5.transform;
						val = player_pos - pos;
						transform.forward = ((Vector3)(ref val)).normalized;
						val5.GetComponent<NetworkObject>().Spawn(true);
						ManualLogSource obj3 = mls;
						val = pos;
						obj3.LogInfo((object)("Tried spawning a turret at " + ((object)(Vector3)(ref val)).ToString()));
						break;
					}
				}
				return;
			}
			case 2:
			{
				SpawnableMapObject[] spawnableMapObjects = currentLevel.spawnableMapObjects;
				foreach (SpawnableMapObject val2 in spawnableMapObjects)
				{
					if (!((Object)(object)val2.prefabToSpawn.GetComponentInChildren<Landmine>() == (Object)null))
					{
						pos -= Vector3.up * 1.8f;
						GameObject val3 = Object.Instantiate<GameObject>(val2.prefabToSpawn, pos, Quaternion.identity);
						val3.transform.position = pos;
						val3.transform.forward = new Vector3(1f, 0f, 0f);
						val3.GetComponent<NetworkObject>().Spawn(true);
						ManualLogSource obj2 = mls;
						val = pos;
						obj2.LogInfo((object)("Tried spawning a mine at " + ((object)(Vector3)(ref val)).ToString()));
						break;
					}
				}
				return;
			}
			}
			SpawnableEnemyWithRarity val6;
			if (inside)
			{
				if (list.Count < 1)
				{
					mls.LogInfo((object)"Cant spawn enemy - no other enemies present to copy from");
					return;
				}
				val6 = list[Random.Range(0, list.Count - 1)];
			}
			else
			{
				if (list2.Count < 1)
				{
					mls.LogInfo((object)"Cant spawn enemy - no other enemies present to copy from");
					return;
				}
				val6 = list2[Random.Range(0, list2.Count - 1)];
			}
			pos += Vector3.up * 0.25f;
			ManualLogSource obj4 = mls;
			string enemyName = val6.enemyType.enemyName;
			val = pos;
			obj4.LogInfo((object)("Spawning " + enemyName + " at " + ((object)(Vector3)(ref val)).ToString()));
			SpawnEnemy(val6, pos, 0f);
		}

		[HarmonyPatch(typeof(GiftBoxItem), "OpenGiftBoxServerRpc")]
		[HarmonyPrefix]
		private static void spawnRandomEntity(GiftBoxItem __instance)
		{
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)__instance).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			int value = Traverse.Create((object)__instance).Field("__rpc_exec_stage").GetValue<int>();
			mls.LogInfo((object)("IsServer:" + networkManager.IsServer + " IsHost:" + networkManager.IsHost + " __rpc_exec_stage:" + value));
			if (value == 1 && isHost)
			{
				int num = Random.Range(1, 100);
				mls.LogInfo((object)("Player's fortune:" + num));
				if (num < spawnChance)
				{
					chooseAndSpawnEnemy(((GrabbableObject)__instance).isInFactory, ((Component)__instance).transform.position, ((Component)Traverse.Create((object)__instance).Field("previousPlayerHeldBy").GetValue<PlayerControllerB>()).transform.position);
				}
			}
		}

		private static void SpawnEnemy(SpawnableEnemyWithRarity enemy, Vector3 pos, float rot)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			RoundManager.Instance.SpawnEnemyGameObject(pos, rot, -1, enemy.enemyType);
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "LethalPresents";

		public const string PLUGIN_NAME = "LethalPresents";

		public const string PLUGIN_VERSION = "1.0.3";
	}
}

BepInEx/plugins/MaskedEnemyRework.dll

Decompiled 2 years ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using MaskedEnemyRework.Patches;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.8.1", FrameworkDisplayName = ".NET Framework 4.8.1")]
[assembly: AssemblyCompany("MaskedEnemyRework")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("My first plugin")]
[assembly: AssemblyFileVersion("2.1.0.0")]
[assembly: AssemblyInformationalVersion("2.1.0")]
[assembly: AssemblyProduct("MaskedEnemyRework")]
[assembly: AssemblyTitle("MaskedEnemyRework")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("2.1.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace MaskedEnemyRework
{
	[BepInPlugin("MaskedEnemyRework", "MaskedEnemyRework", "2.1.0")]
	public class Plugin : BaseUnityPlugin
	{
		private readonly Harmony harmony = new Harmony("MaskedEnemyRework");

		private static Plugin Instance;

		internal ManualLogSource logger;

		private ConfigEntry<bool> RemoveMasksConfig;

		private ConfigEntry<bool> RemoveZombieArmsConfig;

		private ConfigEntry<bool> UseSpawnRarityConfig;

		private ConfigEntry<int> SpawnRarityConfig;

		private ConfigEntry<bool> CanSpawnOutsideConfig;

		private ConfigEntry<int> MaxSpawnCountConfig;

		private ConfigEntry<bool> ZombieApocalypeModeConfig;

		private ConfigEntry<bool> UseVanillaSpawnsConfig;

		private ConfigEntry<int> ZombieApocalypeRandomChanceConfig;

		private ConfigEntry<float> InsideEnemySpawnCurveConfig;

		private ConfigEntry<float> MiddayInsideEnemySpawnCurveConfig;

		private ConfigEntry<float> StartOutsideEnemySpawnCurveConfig;

		private ConfigEntry<float> MidOutsideEnemySpawnCurveConfig;

		private ConfigEntry<float> EndOutsideEnemySpawnCurveConfig;

		public static bool RemoveMasks;

		public static bool RemoveZombieArms;

		public static bool UseSpawnRarity;

		public static int SpawnRarity;

		public static bool CanSpawnOutside;

		public static int MaxSpawnCount;

		public static bool ZombieApocalypseMode;

		public static bool UseVanillaSpawns;

		public static int RandomChanceZombieApocalypse;

		public static float InsideEnemySpawnCurve;

		public static float MiddayInsideEnemySpawnCurve;

		public static float StartOutsideEnemySpawnCurve;

		public static float MidOutsideEnemySpawnCurve;

		public static float EndOutsideEnemySpawnCurve;

		public static int PlayerCount;

		public static SpawnableEnemyWithRarity maskedPrefab;

		public static SpawnableEnemyWithRarity flowerPrefab;

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			RemoveMasksConfig = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Remove Mask From Masked Enemy", true, "Whether or not the Masked Enemy has a mask on.");
			RemoveZombieArmsConfig = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Remove Zombie Arms", true, "Remove the animation where the Masked raise arms like a zombie.");
			UseVanillaSpawnsConfig = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Use Vanilla Spawns", false, "Ignores anything else in this mod. Only uses the above settings from this config. Will not spawn on all moons. will ignore EVERYTHING in the config below this point.");
			UseSpawnRarityConfig = ((BaseUnityPlugin)this).Config.Bind<bool>("Spawns", "Use Spawn Rarity", false, "Use custom spawn rate from config. If this is false, the masked spawns at the same rate as the Bracken. If true, will spawn at whatever rarity is given in Spawn Rarity config option");
			SpawnRarityConfig = ((BaseUnityPlugin)this).Config.Bind<int>("Spawns", "Spawn Rarity", 15, "The rarity for the Masked Enemy to spawn. The higher the number, the more likely to spawn. Can go to 1000000000, any higher will break. Use Spawn Rarity must be set to True");
			CanSpawnOutsideConfig = ((BaseUnityPlugin)this).Config.Bind<bool>("Spawns", "Allow Masked To Spawn Outside", false, "Whether the Masked Enemy can spawn outside the building");
			MaxSpawnCountConfig = ((BaseUnityPlugin)this).Config.Bind<int>("Spawns", "Max Number of Masked", 2, "Max Number of possible masked to spawn in one level");
			ZombieApocalypeModeConfig = ((BaseUnityPlugin)this).Config.Bind<bool>("Zombie Apocalypse Mode", "Zombie Apocalype Mode", false, "Only spawns Masked! Make sure to crank up the Max Spawn Count in this config! Would also recommend bringing a gun (mod), a shovel works fine too though.... This mode does not play nice with other mods that affect spawn rates. Disable those before playing for best results");
			ZombieApocalypeRandomChanceConfig = ((BaseUnityPlugin)this).Config.Bind<int>("Zombie Apocalypse Mode", "Random Zombie Apocalype Mode", -1, "[Must Be Whole Number] The percent chance from 1 to 100 that a day could contain a zombie apocalypse. Put at -1 to never have the chance arise and don't have Only Spawn Masked turned on");
			InsideEnemySpawnCurveConfig = ((BaseUnityPlugin)this).Config.Bind<float>("Zombie Apocalypse Mode", "StartOfDay Inside Masked Spawn Curve", 0.1f, "Spawn curve for masked inside, start of the day. Crank this way up for immediate action. More info in the readme");
			MiddayInsideEnemySpawnCurveConfig = ((BaseUnityPlugin)this).Config.Bind<float>("Zombie Apocalypse Mode", "Midday Inside Masked Spawn Curve", 500f, "Spawn curve for masked inside, midday.");
			StartOutsideEnemySpawnCurveConfig = ((BaseUnityPlugin)this).Config.Bind<float>("Zombie Apocalypse Mode", "StartOfDay Masked Outside Spawn Curve", -30f, "Spawn curve for outside masked, start of the day.");
			MidOutsideEnemySpawnCurveConfig = ((BaseUnityPlugin)this).Config.Bind<float>("Zombie Apocalypse Mode", "Midday Outside Masked Spawn Curve", -30f, "Spawn curve for outside masked, midday.");
			EndOutsideEnemySpawnCurveConfig = ((BaseUnityPlugin)this).Config.Bind<float>("Zombie Apocalypse Mode", "EOD Outside Masked Spawn Curve", 10f, "Spawn curve for outside masked, end of day");
			RemoveMasks = RemoveMasksConfig.Value;
			UseVanillaSpawns = UseVanillaSpawnsConfig.Value;
			RemoveZombieArms = RemoveZombieArmsConfig.Value;
			UseSpawnRarity = UseSpawnRarityConfig.Value;
			CanSpawnOutside = CanSpawnOutsideConfig.Value;
			MaxSpawnCount = MaxSpawnCountConfig.Value;
			SpawnRarity = SpawnRarityConfig.Value;
			ZombieApocalypseMode = ZombieApocalypeModeConfig.Value;
			InsideEnemySpawnCurve = InsideEnemySpawnCurveConfig.Value;
			MiddayInsideEnemySpawnCurve = MiddayInsideEnemySpawnCurveConfig.Value;
			StartOutsideEnemySpawnCurve = StartOutsideEnemySpawnCurveConfig.Value;
			MidOutsideEnemySpawnCurve = MaxSpawnCountConfig.Value;
			EndOutsideEnemySpawnCurve = EndOutsideEnemySpawnCurveConfig.Value;
			RandomChanceZombieApocalypse = ZombieApocalypeRandomChanceConfig.Value;
			logger = Logger.CreateLogSource("MaskedEnemyRework");
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin MaskedEnemyRework is loaded! Woohoo!");
			harmony.PatchAll(typeof(Plugin));
			harmony.PatchAll(typeof(GetMaskedPrefabForLaterUse));
			harmony.PatchAll(typeof(MaskedVisualRework));
			harmony.PatchAll(typeof(MaskedSpawnSettings));
			harmony.PatchAll(typeof(RemoveZombieArms));
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "MaskedEnemyRework";

		public const string PLUGIN_NAME = "MaskedEnemyRework";

		public const string PLUGIN_VERSION = "2.1.0";
	}
}
namespace MaskedEnemyRework.Patches
{
	[HarmonyPatch(typeof(Terminal))]
	internal class GetMaskedPrefabForLaterUse
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void SavesPrefabForLaterUse(ref SelectableLevel[] ___moonsCatalogueList)
		{
			ManualLogSource val = Logger.CreateLogSource("MaskedEnemyRework");
			SelectableLevel[] array = ___moonsCatalogueList;
			foreach (SelectableLevel val2 in array)
			{
				foreach (SpawnableEnemyWithRarity enemy in val2.Enemies)
				{
					if (enemy.enemyType.enemyName == "Masked")
					{
						val.LogInfo((object)"Found Masked!");
						Plugin.maskedPrefab = enemy;
					}
					else if (enemy.enemyType.enemyName == "Flowerman")
					{
						Plugin.flowerPrefab = enemy;
						val.LogInfo((object)"Found Flowerman!");
					}
				}
			}
		}
	}
	[HarmonyPatch(typeof(RoundManager))]
	internal class MaskedSpawnSettings
	{
		[HarmonyPatch("BeginEnemySpawning")]
		[HarmonyPrefix]
		private static void UpdateSpawnRates(ref SelectableLevel ___currentLevel)
		{
			//IL_0234: Unknown result type (might be due to invalid IL or missing references)
			//IL_0239: Unknown result type (might be due to invalid IL or missing references)
			//IL_024a: Unknown result type (might be due to invalid IL or missing references)
			//IL_024f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0259: Unknown result type (might be due to invalid IL or missing references)
			//IL_0263: Expected O, but got Unknown
			//IL_0277: Unknown result type (might be due to invalid IL or missing references)
			//IL_027c: Unknown result type (might be due to invalid IL or missing references)
			//IL_028d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0292: Unknown result type (might be due to invalid IL or missing references)
			//IL_029c: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a6: Expected O, but got Unknown
			//IL_02ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ff: Expected O, but got Unknown
			if (Plugin.UseVanillaSpawns)
			{
				return;
			}
			ManualLogSource val = Logger.CreateLogSource("MaskedEnemyRework");
			val.LogInfo((object)"Starting Round Manager");
			SpawnableEnemyWithRarity maskedPrefab = Plugin.maskedPrefab;
			SpawnableEnemyWithRarity val2 = Plugin.flowerPrefab;
			SelectableLevel obj = ___currentLevel;
			obj.maxEnemyPowerCount += maskedPrefab.enemyType.MaxCount;
			SelectableLevel obj2 = ___currentLevel;
			obj2.maxDaytimeEnemyPowerCount += maskedPrefab.enemyType.MaxCount;
			SelectableLevel obj3 = ___currentLevel;
			obj3.maxOutsideEnemyPowerCount += maskedPrefab.enemyType.MaxCount;
			List<SpawnableEnemyWithRarity> enemies = ___currentLevel.Enemies;
			for (int i = 0; i < ___currentLevel.Enemies.Count; i++)
			{
				SpawnableEnemyWithRarity val3 = ___currentLevel.Enemies[i];
				if (val3.enemyType.enemyName == "Masked")
				{
					enemies.Remove(val3);
				}
				if (val3.enemyType.enemyName == "Flowerman")
				{
					val2 = val3;
				}
			}
			___currentLevel.Enemies = enemies;
			maskedPrefab.enemyType.PowerLevel = 1;
			maskedPrefab.enemyType.probabilityCurve = val2.enemyType.probabilityCurve;
			if (Plugin.UseSpawnRarity)
			{
				maskedPrefab.rarity = Plugin.SpawnRarity;
			}
			else
			{
				maskedPrefab.rarity = val2.rarity;
			}
			maskedPrefab.enemyType.MaxCount = Plugin.MaxSpawnCount;
			maskedPrefab.enemyType.isOutsideEnemy = Plugin.CanSpawnOutside;
			int num = 0;
			num = ((StartOfRound.Instance.randomMapSeed.ToString().Length >= 3) ? int.Parse(StartOfRound.Instance.randomMapSeed.ToString().Substring(1, 2)) : 0);
			val.LogInfo((object)("Map seed " + num + " random chance " + Plugin.RandomChanceZombieApocalypse));
			num = Mathf.Clamp(num, 0, 100);
			if (Plugin.ZombieApocalypseMode || (num <= Plugin.RandomChanceZombieApocalypse && Plugin.RandomChanceZombieApocalypse >= 0))
			{
				val.LogInfo((object)"ZOMBIE APOCALYPSE");
				___currentLevel.enemySpawnChanceThroughoutDay = new AnimationCurve((Keyframe[])(object)new Keyframe[2]
				{
					new Keyframe(0f, Plugin.InsideEnemySpawnCurve),
					new Keyframe(0.5f, Plugin.MiddayInsideEnemySpawnCurve)
				});
				___currentLevel.daytimeEnemySpawnChanceThroughDay = new AnimationCurve((Keyframe[])(object)new Keyframe[2]
				{
					new Keyframe(0f, 7f),
					new Keyframe(0.5f, 7f)
				});
				___currentLevel.outsideEnemySpawnChanceThroughDay = new AnimationCurve((Keyframe[])(object)new Keyframe[3]
				{
					new Keyframe(0f, Plugin.StartOutsideEnemySpawnCurve),
					new Keyframe(20f, Plugin.MidOutsideEnemySpawnCurve),
					new Keyframe(21f, Plugin.EndOutsideEnemySpawnCurve)
				});
				___currentLevel.DaytimeEnemies.Clear();
				___currentLevel.OutsideEnemies.Clear();
				maskedPrefab.rarity = 1000000000;
				foreach (SpawnableEnemyWithRarity enemy in ___currentLevel.Enemies)
				{
					enemy.rarity = 0;
				}
				if (Plugin.CanSpawnOutside)
				{
					maskedPrefab.enemyType.isOutsideEnemy = true;
					___currentLevel.OutsideEnemies.Add(maskedPrefab);
					___currentLevel.DaytimeEnemies.Add(maskedPrefab);
				}
			}
			else
			{
				val.LogInfo((object)"no zombies :(");
			}
			___currentLevel.Enemies.Add(maskedPrefab);
		}
	}
	[HarmonyPatch(typeof(MaskedPlayerEnemy))]
	internal class MaskedVisualRework
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void ReformVisuals(ref MaskedPlayerEnemy __instance)
		{
			ManualLogSource val = Logger.CreateLogSource("MaskedEnemyRework");
			PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
			int num = StartOfRound.Instance.ClientPlayerList.Count;
			if (num == 0)
			{
				num = Random.Range(0, 2);
				val.LogInfo((object)"Player count was zero");
			}
			int num2 = StartOfRound.Instance.randomMapSeed % num;
			val.LogInfo((object)("player count" + num));
			val.LogInfo((object)("player index" + num2));
			num2 = Mathf.Clamp(num2, 0, num);
			PlayerControllerB val2 = allPlayerScripts[num2];
			__instance.mimickingPlayer = val2;
			__instance.SetSuit(val2.currentSuitID);
			if (Plugin.RemoveMasks)
			{
				((Component)((Component)__instance).gameObject.transform.Find("ScavengerModel/metarig/spine/spine.001/spine.002/spine.003/spine.004/HeadMaskComedy")).gameObject.SetActive(false);
				((Component)((Component)__instance).gameObject.transform.Find("ScavengerModel/metarig/spine/spine.001/spine.002/spine.003/spine.004/HeadMaskTragedy")).gameObject.SetActive(false);
			}
		}
	}
	internal class RemoveZombieArms
	{
		[HarmonyPatch(typeof(MaskedPlayerEnemy), "SetHandsOutClientRpc")]
		[HarmonyPrefix]
		private static void RemoveArms(ref bool setOut)
		{
			if (Plugin.RemoveZombieArms)
			{
				setOut = false;
			}
		}
	}
}

BepInEx/plugins/QuickRestart.dll

Decompiled 2 years ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using GameNetcodeStuff;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.InputSystem;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("QuickRestart")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("My first plugin")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+a395cfe8aac0ee2687d75817f75fae451f729511")]
[assembly: AssemblyProduct("QuickRestart")]
[assembly: AssemblyTitle("QuickRestart")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace QuickRestart
{
	[BepInPlugin("QuickRestart", "QuickRestart", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		public static bool verifying;

		private ConfigEntry<bool> overrideConfirmation;

		public static bool bypassConfirm;

		private Harmony harmony;

		private static MethodInfo chat;

		private void Awake()
		{
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Expected O, but got Unknown
			overrideConfirmation = ((BaseUnityPlugin)this).Config.Bind<bool>("Config", "Override Confirmation", false, "Ignore the confirmation step of restarting.");
			bypassConfirm = overrideConfirmation.Value;
			harmony = new Harmony("QuickRestart");
			harmony.PatchAll();
			chat = AccessTools.Method(typeof(HUDManager), "AddChatMessage", (Type[])null, (Type[])null);
			((BaseUnityPlugin)this).Logger.LogInfo((object)"QuickRestart loaded!");
		}

		public static void SendChatMessage(string message)
		{
			chat?.Invoke(HUDManager.Instance, new object[2] { message, "" });
			HUDManager.Instance.lastChatMessage = "";
		}

		public static void ConfirmRestart()
		{
			verifying = true;
			SendChatMessage("Are you sure? Type CONFIRM or DENY.");
		}

		public static void AcceptRestart(StartOfRound manager)
		{
			SendChatMessage("Restart confirmed.");
			verifying = false;
			int[] array = new int[4]
			{
				manager.gameStats.daysSpent,
				manager.gameStats.scrapValueCollected,
				manager.gameStats.deaths,
				manager.gameStats.allStepsTaken
			};
			manager.FirePlayersAfterDeadlineClientRpc(array, false);
		}

		public static void DeclineRestart()
		{
			SendChatMessage("Restart aborted.");
			verifying = false;
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "QuickRestart";

		public const string PLUGIN_NAME = "QuickRestart";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace QuickRestart.Patches
{
	[HarmonyPatch(typeof(HUDManager), "SubmitChat_performed")]
	public class SubmitChat
	{
		private static bool Prefix(HUDManager __instance, ref CallbackContext context)
		{
			if (!((CallbackContext)(ref context)).performed)
			{
				return true;
			}
			if (string.IsNullOrEmpty(__instance.chatTextField.text))
			{
				return true;
			}
			PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController;
			if ((Object)(object)localPlayerController == (Object)null)
			{
				return true;
			}
			StartOfRound playersManager = localPlayerController.playersManager;
			if ((Object)(object)playersManager == (Object)null)
			{
				return true;
			}
			string text = __instance.chatTextField.text;
			if (Plugin.verifying)
			{
				if (text.ToLower() == "confirm")
				{
					ResetTextbox(__instance, localPlayerController);
					if (!localPlayerController.isInHangarShipRoom || !playersManager.inShipPhase || playersManager.travellingToNewLevel)
					{
						Plugin.SendChatMessage("Cannot restart, ship must be in orbit.");
						return false;
					}
					Plugin.AcceptRestart(playersManager);
					return false;
				}
				if (text.ToLower() == "deny")
				{
					ResetTextbox(__instance, localPlayerController);
					Plugin.DeclineRestart();
					return false;
				}
				return true;
			}
			if (text == "/restart")
			{
				ResetTextbox(__instance, localPlayerController);
				if (!GameNetworkManager.Instance.isHostingGame)
				{
					Plugin.SendChatMessage("Only the host can restart.");
					return false;
				}
				if (!localPlayerController.isInHangarShipRoom || !playersManager.inShipPhase || playersManager.travellingToNewLevel)
				{
					Plugin.SendChatMessage("Cannot restart, ship must be in orbit.");
					return false;
				}
				if (Plugin.bypassConfirm)
				{
					Plugin.AcceptRestart(playersManager);
				}
				else
				{
					Plugin.ConfirmRestart();
				}
				return false;
			}
			return true;
		}

		private static void ResetTextbox(HUDManager manager, PlayerControllerB local)
		{
			local.isTypingChat = false;
			manager.chatTextField.text = "";
			EventSystem.current.SetSelectedGameObject((GameObject)null);
			manager.PingHUDElement(manager.Chat, 2f, 1f, 0.2f);
			((Behaviour)manager.typingIndicator).enabled = false;
		}
	}
}

BepInEx/plugins/QuotaRollover.dll

Decompiled 2 years ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using QuotaRollover.Patches;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("QuotaRollover")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("QuotaRollover")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("bc931127-211b-4882-bb8e-44687a45d42b")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace QuotaRollover
{
	[BepInPlugin("Boxofbiscuits97.QuotraRollover", "Quota Rollover", "2.1.0")]
	public class QuotaRolloverBase : BaseUnityPlugin
	{
		private readonly Harmony harmony = new Harmony("Boxofbiscuits97.QuotraRollover");

		private static QuotaRolloverBase Instance;

		public static ManualLogSource logger;

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			logger = ((BaseUnityPlugin)this).Logger;
			logger.LogInfo((object)"Mod Boxofbiscuits97.QuotraRollover is loaded!");
			harmony.PatchAll(typeof(QuotaRolloverBase));
			harmony.PatchAll(typeof(TimeOfDayPatch));
		}
	}
}
namespace QuotaRollover.Patches
{
	[HarmonyPatch(typeof(TimeOfDay))]
	internal class TimeOfDayPatch
	{
		[HarmonyPatch("SetNewProfitQuota")]
		[HarmonyPrefix]
		private static bool GetQuotaFulfilledHost(ref int ___quotaFulfilled, ref int ___profitQuota, out int __state)
		{
			if (TimeOfDay.Instance.timeUntilDeadline <= 0f)
			{
				__state = ___quotaFulfilled - ___profitQuota;
				QuotaRolloverBase.logger.LogInfo((object)$"Host Got New Quota at: {__state} ful: {___quotaFulfilled}");
				return true;
			}
			__state = ___quotaFulfilled;
			return false;
		}

		[HarmonyPatch("SetNewProfitQuota")]
		[HarmonyPostfix]
		private static void SetQuotaFulfilledHost(ref int ___quotaFulfilled, int __state)
		{
			___quotaFulfilled = __state;
			QuotaRolloverBase.logger.LogInfo((object)$"Host Set New Quota at: {__state}");
		}

		[HarmonyPatch("SyncNewProfitQuotaClientRpc")]
		[HarmonyPrefix]
		private static void GetNewQuotaFulfilledClient(ref int ___quotaFulfilled, ref int ___profitQuota, out int __state)
		{
			__state = ___quotaFulfilled - ___profitQuota;
			QuotaRolloverBase.logger.LogInfo((object)$"Client Got New Quota at: {__state}");
		}

		[HarmonyPatch("SyncNewProfitQuotaClientRpc")]
		[HarmonyPostfix]
		private static void SetNewQuotaFulfiledClient(ref int ___quotaFulfilled, int __state)
		{
			if (___quotaFulfilled == 0)
			{
				___quotaFulfilled = __state;
				QuotaRolloverBase.logger.LogInfo((object)$"Client Set New Quota at: {__state}");
			}
		}
	}
}