Decompiled source of LevelScaling v0.9.1

LevelScaling.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using ExitGames.Client.Photon;
using HarmonyLib;
using LevelScaling.LevelStats;
using LevelScaling.Patches;
using Photon.Pun;
using REPOLib.Modules;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.Video;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("LevelScaling")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("LevelScaling")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("94187d6e-952a-4336-b083-0210fe153e6f")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace LevelScaling
{
	public class ChallengeManager
	{
		public enum ChallengeType
		{
			None,
			LightsOut,
			HighQuota,
			LargeMap,
			EnemyRush,
			FragileValuables,
			IncreasedDamage,
			HiddenInformation,
			FoggyLevel,
			TimeAttack,
			OverOvercharge,
			NoMap,
			DangerZone,
			SharedDurability
		}

		public class Challenge
		{
			public ChallengeType type;

			public string name;

			public int startingLevel;

			public string info;

			public int Weight => type switch
			{
				ChallengeType.LightsOut => Plugin.ChallengeChanceMultiplier_LightsOut.Value, 
				ChallengeType.HighQuota => Plugin.ChallengeChanceMultiplier_HighQuota.Value, 
				ChallengeType.LargeMap => Plugin.ChallengeChanceMultiplier_LargeMap.Value, 
				ChallengeType.FoggyLevel => Plugin.ChallengeChanceMultiplier_FoggyLevel.Value, 
				ChallengeType.IncreasedDamage => Plugin.ChallengeChanceMultiplier_IncreasedDamage.Value, 
				ChallengeType.FragileValuables => Plugin.ChallengeChanceMultiplier_FragileValuables.Value, 
				ChallengeType.OverOvercharge => Plugin.ChallengeChanceMultiplier_OverOvercharge.Value, 
				ChallengeType.NoMap => Plugin.ChallengeChanceMultiplier_NoMap.Value, 
				ChallengeType.EnemyRush => Plugin.ChallengeChanceMultiplier_EnemyRush.Value, 
				ChallengeType.HiddenInformation => Plugin.ChallengeChanceMultiplier_HiddenInformation.Value, 
				ChallengeType.DangerZone => Plugin.ChallengeChanceMultiplier_DangerZone.Value, 
				ChallengeType.SharedDurability => Plugin.ChallengeChanceMultiplier_SharedDurability.Value, 
				_ => 0, 
			};

			public Challenge(ChallengeType type, string name, int startingLevel, string info)
			{
				this.type = type;
				this.name = name;
				this.startingLevel = startingLevel;
				this.info = info;
			}
		}

		public static List<ChallengeType> currentChallenges = new List<ChallengeType>();

		public static ChallengeType forceChallenge = ChallengeType.None;

		public static NetworkedEvent ChallengeSync;

		public static Dictionary<string, int> challengesDofD = new Dictionary<string, int>
		{
			{ "currentSeed", 1 },
			{ "lastChallengeLevel", -1 },
			{ "lastChallengeType", -1 }
		};

		public static readonly List<Challenge> allChallenges = new List<Challenge>
		{
			new Challenge(ChallengeType.LightsOut, "Lights Out", 3, "The level's lights have stopped working,<br>you'll be stuck in the dark."),
			new Challenge(ChallengeType.HighQuota, "Overtime", 7, "Taxman is requiring extra effort for this level.<br>Your quotas will be significantly higher."),
			new Challenge(ChallengeType.LargeMap, "Enlarged Level", 12, "This level's layout is much larger than normal.<br>Remember to use your map."),
			new Challenge(ChallengeType.FoggyLevel, "Dense Fog", 15, "There's lots of heavy fog on this level.<br>Visibility will be low, tread carefully."),
			new Challenge(ChallengeType.IncreasedDamage, "Increased Damage", 5, "All incoming damage for both Semibots and enemies<br>will be greatly increased. Be careful."),
			new Challenge(ChallengeType.FragileValuables, "Fragile Valuables", 15, "All valuables are very fragile, regardless of how they<br>look on the outside. Each valuable will be priced slightly higher."),
			new Challenge(ChallengeType.OverOvercharge, "Over-Overcharge", 10, "Overcharge will build up from holding valuables too.<br>Pay close attention and don't explode yourself."),
			new Challenge(ChallengeType.NoMap, "Broken Map", 7, "Your map is disabled, however Semibots will naturally<br>regenerate health slowly; up to the health they started the level with."),
			new Challenge(ChallengeType.EnemyRush, "Enemy Rush", 10, "There are many more enemies than usual on this level,<br>but enemies are lighter, and have significantly reduced health."),
			new Challenge(ChallengeType.HiddenInformation, "Hidden Information", 10, "This level's size and length are randomized, and some important<br>information will be obstructed for the duration of the level."),
			new Challenge(ChallengeType.DangerZone, "Danger Zone", 5, "Semibots will take damage over time, gradually speeding up the longer<br>you spend on the level. Damaging enemies heals all Semibots."),
			new Challenge(ChallengeType.SharedDurability, "Shared Durability", 12, "A portion of damage valuables take is instead given to Semibots. More value<br>lost, more damage given. Extractions will heal Semibots based on value extracted.")
		};

		public static int CurrentSeed
		{
			get
			{
				if (!challengesDofD.ContainsKey("currentSeed"))
				{
					challengesDofD.Add("currentSeed", 1);
				}
				return challengesDofD["currentSeed"];
			}
			set
			{
				if (!challengesDofD.ContainsKey("currentSeed"))
				{
					challengesDofD.Add("currentSeed", value);
				}
				else
				{
					challengesDofD["currentSeed"] = value;
				}
			}
		}

		public static int LastChallengeLevel
		{
			get
			{
				if (!challengesDofD.ContainsKey("lastChallengeLevel"))
				{
					challengesDofD.Add("lastChallengeLevel", -1);
				}
				return challengesDofD["lastChallengeLevel"];
			}
			set
			{
				if (!challengesDofD.ContainsKey("lastChallengeLevel"))
				{
					challengesDofD.Add("lastChallengeLevel", value);
				}
				else
				{
					challengesDofD["lastChallengeLevel"] = value;
				}
			}
		}

		public static int LastChallengeType
		{
			get
			{
				if (!challengesDofD.ContainsKey("lastChallengeType"))
				{
					challengesDofD.Add("lastChallengeType", -1);
				}
				return challengesDofD["lastChallengeType"];
			}
			set
			{
				if (!challengesDofD.ContainsKey("lastChallengeType"))
				{
					challengesDofD.Add("lastChallengeType", value);
				}
				else
				{
					challengesDofD["lastChallengeType"] = value;
				}
			}
		}

		public static bool IsChallengeActive(ChallengeType challenge)
		{
			return currentChallenges.Contains(challenge);
		}

		public static Challenge GetChallenge(ChallengeType challenge)
		{
			foreach (Challenge allChallenge in allChallenges)
			{
				if (allChallenge.type == challenge)
				{
					return allChallenge;
				}
			}
			return new Challenge(ChallengeType.None, "????????", 0, "Unknown challenge - can't get any info. Sorry!");
		}

		public static void Setup()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			ChallengeSync = new NetworkedEvent("Challenge Sync", (Action<EventData>)OnChallengeSync);
		}

		public static void DetermineChallengeForLevel(int level, int initialSeed)
		{
			//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e8: Unknown result type (might be due to invalid IL or missing references)
			if (!SemiFunc.IsMasterClientOrSingleplayer())
			{
				return;
			}
			Random random = new Random(initialSeed + level);
			int num = Mathf.Max(0, level - Mathf.Max(1, LastChallengeLevel) - 1);
			float num2 = Mathf.Clamp(2.5f * Mathf.Sqrt(1.5f * (float)level), 1f, 30f);
			float num3 = Mathf.Clamp((float)num * 4f, 0f, 20f);
			float num4 = num2 + num3;
			if (num >= 3 && level >= 10)
			{
				num4 += 5f;
				if (num >= 5)
				{
					num4 += 7f;
				}
			}
			if (level >= 5 && LastChallengeLevel == -1)
			{
				num4 += 15f;
				if (level >= 7)
				{
					num4 += 20f;
				}
			}
			num4 *= Plugin.ChallengeChanceMultiplier.Value;
			float num5 = (float)random.Next(0, 1000) / 10f;
			bool num6 = (Object)(object)RunManager.instance.levelCurrent == (Object)(object)RunManager.instance.levelShop || (Object)(object)RunManager.instance.levelCurrent == (Object)(object)RunManager.instance.levelTutorial || (Object)(object)RunManager.instance.levelCurrent == (Object)(object)RunManager.instance.levelArena || (Object)(object)RunManager.instance.levelCurrent == (Object)(object)RunManager.instance.levelLobby || (Object)(object)RunManager.instance.levelCurrent == (Object)(object)RunManager.instance.levelLobbyMenu;
			bool flag = level < 3 || (level <= 20 && level % 5 == 0 && Plugin.ChallengeDisableMoonPhase.Value);
			bool flag2 = num5 >= num4;
			bool flag3 = LastChallengeLevel == level - 1 && random.Next(0, 100) >= 5;
			if (num6 || (!Plugin.ChallengeGuarantee.Value && forceChallenge == ChallengeType.None && (flag || flag2 || flag3)))
			{
				ChallengeSync.RaiseEvent((object)0, NetworkingEvents.RaiseAll, SendOptions.SendReliable);
				return;
			}
			int num7 = 0;
			int num8 = 0;
			int num9 = 0;
			List<Challenge> list = new List<Challenge>();
			foreach (Challenge allChallenge in allChallenges)
			{
				if ((Plugin.ChallengeGuarantee.Value || (LevelGeneratorPatch.CurrentLevel >= allChallenge.startingLevel && allChallenge.type != (ChallengeType)LastChallengeType)) && (allChallenge.type != ChallengeType.OverOvercharge || level >= 10))
				{
					list.Add(allChallenge);
					num9 += allChallenge.Weight;
				}
			}
			int num10 = random.Next(0, num9);
			foreach (Challenge item in list)
			{
				num8 += item.Weight;
				if (num8 > num10)
				{
					num7 = (int)item.type;
					break;
				}
			}
			if (forceChallenge != 0)
			{
				num7 = (int)forceChallenge;
			}
			forceChallenge = ChallengeType.None;
			LastChallengeLevel = level;
			LastChallengeType = num7;
			if (SemiFunc.IsMultiplayer())
			{
				ChallengeSync.RaiseEvent((object)num7, NetworkingEvents.RaiseAll, SendOptions.SendReliable);
			}
			else
			{
				SetupChallenges((ChallengeType)num7);
			}
		}

		public static void SetupChallenges(ChallengeType challenge)
		{
			currentChallenges.Clear();
			if (challenge != 0)
			{
				currentChallenges.Add(challenge);
			}
		}

		private static void OnChallengeSync(EventData data)
		{
			SetupChallenges((ChallengeType)(int)data.CustomData);
		}
	}
	internal class Helpers
	{
		public static PlayerChatBoxState truckScreenState = (PlayerChatBoxState)0;

		private static readonly Dictionary<int, Color> difficultyColors = new Dictionary<int, Color>
		{
			{
				2147483639,
				new Color(0f, 0f, 0f)
			},
			{
				999,
				new Color(0f, 0f, 0f)
			},
			{
				100,
				new Color(0.2f, 0.2f, 0.2f)
			},
			{
				90,
				new Color(0f, 1f, 0.5f)
			},
			{
				80,
				new Color(0f, 1f, 1f)
			},
			{
				70,
				new Color(0f, 0.5f, 1f)
			},
			{
				60,
				new Color(0f, 0f, 1f)
			},
			{
				50,
				new Color(0.5f, 0f, 1f)
			},
			{
				40,
				new Color(1f, 0f, 1f)
			},
			{
				30,
				new Color(1f, 0f, 0.5f)
			},
			{
				20,
				new Color(1f, 0f, 0f)
			},
			{
				15,
				new Color(1f, 0.5f, 0f)
			},
			{
				10,
				new Color(1f, 1f, 0f)
			},
			{
				5,
				new Color(0.5f, 1f, 0f)
			},
			{
				1,
				new Color(0f, 1f, 0f)
			}
		};

		public static int PlayerCount => GameDirector.instance.PlayerList.Count;

		public static bool TruckLeaving
		{
			get
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				//IL_0006: Invalid comparison between Unknown and I4
				//IL_0008: Unknown result type (might be due to invalid IL or missing references)
				//IL_000e: Invalid comparison between Unknown and I4
				if ((int)truckScreenState != 2)
				{
					return (int)truckScreenState == 3;
				}
				return true;
			}
		}

		public static int CurrentLevel => LevelGeneratorPatch.CurrentLevel;

		public static void DebugForceLoadLevel(int level, ChallengeManager.ChallengeType forcedChallenge = ChallengeManager.ChallengeType.None)
		{
			RunManager.instance.levelsCompleted = level - 1;
			ChallengeManager.forceChallenge = forcedChallenge;
			RunManager.instance.ChangeLevel(true, false, (ChangeLevelType)1);
		}

		public static string TimeToString(float seconds)
		{
			seconds = Mathf.Clamp(seconds, 0f, 360000f);
			int num = (int)(seconds * 1000f) % 1000;
			int num2 = (int)seconds % 60;
			int num3 = (int)(seconds / 60f) % 60;
			int num4 = (int)(seconds / 3600f);
			return $"{num4:00}:{num3:00}:{num2:00}<size=75%>.{num:000}</size>";
		}

		public static Color GetDifficultyColor(int level)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: 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)
			Color val = Color.black;
			int num = 0;
			foreach (KeyValuePair<int, Color> difficultyColor in difficultyColors)
			{
				if (level >= difficultyColor.Key)
				{
					float num2 = (float)(level - difficultyColor.Key) / (float)(num - difficultyColor.Key);
					return Color.Lerp(difficultyColor.Value, val, num2);
				}
				val = difficultyColor.Value;
				num = difficultyColor.Key;
			}
			return new Color(0f, 0f, 0f);
		}

		public static string ColoredText(string text, Color color)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			string text2 = ColorUtility.ToHtmlStringRGB(color);
			return ColoredText(text, "#" + text2);
		}

		public static string ColoredText(string text, string hexColor)
		{
			return "<color=" + hexColor + ">" + text + "</color>";
		}

		public static string PlusMinus(int number)
		{
			if (number < 0)
			{
				return number.ToString();
			}
			if (number > 0)
			{
				return $"+{number}";
			}
			return $"±{number}";
		}

		public static string PlusMinus(float number)
		{
			if (number < 0f)
			{
				return $"{number:0.00}";
			}
			if (number > 0f)
			{
				return $"+{number:0.00}";
			}
			return $"±{number:0.00}";
		}

		public static float RoundTo100(float original)
		{
			return Mathf.Round(original / 100f) * 100f;
		}
	}
	[HarmonyPatch(typeof(ExtractionPoint))]
	internal class ExtractionPointPatch
	{
		private static int TotalMapValueAtStartOfRound;

		[HarmonyPatch("HaulGoalSet")]
		[HarmonyPrefix]
		private static void HaulGoalSetPrefix(ref int value)
		{
			int value2 = Traverse.Create((object)RoundDirector.instance).Field("haulGoalMax").GetValue<int>();
			int value3 = Traverse.Create((object)RoundDirector.instance).Field("extractionPoints").GetValue<int>();
			int value4 = Traverse.Create((object)RoundDirector.instance).Field("extractionPointsCompleted").GetValue<int>();
			if (value4 == 0)
			{
				TotalMapValueAtStartOfRound = value2;
			}
			float num = 1f;
			if (Plugin.Modify_HaulGoal.Value)
			{
				num = SwaggiFunc.DetermineBaseQuotaDifficulty(LevelGeneratorPatch.CurrentLevel);
			}
			if (ChallengeManager.IsChallengeActive(ChallengeManager.ChallengeType.HighQuota))
			{
				float num2 = Mathf.Abs(1f - num);
				num += Mathf.Clamp(num2 / 2f, 0.05f, 0.4f);
			}
			if (Plugin.Modify_HaulGoal.Value)
			{
				value = SwaggiFunc.DetermineQuota(value4, value3, TotalMapValueAtStartOfRound, num);
			}
			else
			{
				value = Mathf.RoundToInt((float)value * num);
			}
		}

		[HarmonyPatch("ActivateTheFirstExtractionPointAutomaticallyWhenAPlayerLeaveTruck")]
		[HarmonyPostfix]
		private static void ActivateTheFirstExtractionPointAutomaticallyWhenAPlayerLeaveTruckP()
		{
			LevelStatsManager.firstExtractionOpenedThisLevel = true;
		}

		[HarmonyPatch("DestroyTheFirstPhysObjectsInHaulList")]
		[HarmonyPrefix]
		private static void DestroyTheFirstPhysObjectsInHaulListP()
		{
			if (!SemiFunc.IsMasterClientOrSingleplayer() || RoundDirector.instance.dollarHaulList.Count == 0 || !Object.op_Implicit((Object)(object)RoundDirector.instance.dollarHaulList[0]))
			{
				return;
			}
			ValuableObject component = RoundDirector.instance.dollarHaulList[0].GetComponent<ValuableObject>();
			SurplusValuable component2 = RoundDirector.instance.dollarHaulList[0].GetComponent<SurplusValuable>();
			if (Object.op_Implicit((Object)(object)component))
			{
				float value = Traverse.Create((object)component).Field("dollarValueCurrent").GetValue<float>();
				SwaggiFunc.SharedDurability_HealAllPlayers(value, value >= 10000f);
				if (!Object.op_Implicit((Object)(object)component2))
				{
					LevelStatsManager.AddValueExtracted(value);
					RunStatsManager.instance.totalValueExtracted += value;
				}
			}
		}

		[HarmonyPatch("DestroyAllPhysObjectsInHaulList")]
		[HarmonyPrefix]
		private static void DestroyAllPhysObjectsInHaulListP()
		{
			if (!SemiFunc.IsMasterClientOrSingleplayer())
			{
				return;
			}
			float num = 0f;
			foreach (GameObject dollarHaul in RoundDirector.instance.dollarHaulList)
			{
				ValuableObject component = dollarHaul.GetComponent<ValuableObject>();
				SurplusValuable component2 = dollarHaul.GetComponent<SurplusValuable>();
				if (Object.op_Implicit((Object)(object)component))
				{
					float value = Traverse.Create((object)component).Field("dollarValueCurrent").GetValue<float>();
					num += value;
					if (!Object.op_Implicit((Object)(object)component2))
					{
						LevelStatsManager.AddValueExtracted(value);
					}
				}
			}
			SwaggiFunc.SharedDurability_HealAllPlayers(num, forceHealEffect: true);
			if (SemiFunc.RunIsLevel())
			{
				RunStatsManager.instance.extractionPointsCompleted++;
			}
		}

		[HarmonyPatch("SpawnTaxReturn")]
		[HarmonyPrefix]
		private static void SpawnTaxReturnP()
		{
			if (SemiFunc.IsMasterClientOrSingleplayer())
			{
				int value = Traverse.Create((object)RoundDirector.instance).Field("extractionPointSurplus").GetValue<int>();
				if (value > 0)
				{
					LevelStatsManager._valueFromSurplus += value;
					RunStatsManager.instance.largestSurplusValue = Mathf.Max(value, RunStatsManager.instance.largestSurplusValue);
				}
			}
		}

		[HarmonyPatch("SetHaulText")]
		[HarmonyPostfix]
		private static void SetHaulTextP(ref ExtractionPoint __instance, ref bool ___isShop, ref float ___haulBarTargetScale)
		{
			if (ChallengeManager.IsChallengeActive(ChallengeManager.ChallengeType.HiddenInformation) && !___isShop)
			{
				((TMP_Text)__instance.haulGoalScreen).text = "<color=#bd4300>$</color>?????";
				___haulBarTargetScale = 1f;
				Traverse.Create((object)__instance).Method("SetEmojiScreen", new object[2] { "<sprite name=:)>", false }).GetValue();
			}
		}
	}
	[HarmonyPatch(typeof(LevelGenerator))]
	internal class LevelGeneratorPatch
	{
		public static int CurrentLevel => RunManager.instance.levelsCompleted + 1;

		private static int CurrentModCount => Traverse.Create((object)LevelGenerator.Instance).Field("ModuleAmount").GetValue<int>();

		private static int CurrentExtCount => Traverse.Create((object)LevelGenerator.Instance).Field("ExtractionAmount").GetValue<int>();

		private static int GetNewModuleCount()
		{
			if (!SemiFunc.RunIsLevel())
			{
				return CurrentModCount;
			}
			if (ChallengeManager.IsChallengeActive(ChallengeManager.ChallengeType.HiddenInformation))
			{
				return Random.Range(5, 9);
			}
			int num = CurrentModCount;
			if (Plugin.Modify_ModuleCount.Value)
			{
				num = SwaggiFunc.DetermineNumberOfModules(CurrentLevel, GameDirector.instance.PlayerList.Count, RunManager.instance.levelCurrent.NarrativeName);
			}
			if (ChallengeManager.IsChallengeActive(ChallengeManager.ChallengeType.LargeMap))
			{
				num += Mathf.Clamp(Mathf.RoundToInt((float)num * 0.4f), 6, 12);
			}
			if (ChallengeManager.IsChallengeActive(ChallengeManager.ChallengeType.FoggyLevel))
			{
				num = Mathf.Max(3, Mathf.CeilToInt((float)num / 2.33f));
			}
			if (ChallengeManager.IsChallengeActive(ChallengeManager.ChallengeType.NoMap))
			{
				num = Mathf.Max(3, Mathf.RoundToInt((float)num * 0.9f));
			}
			return num;
		}

		private static int GetNewExtractionCount()
		{
			if (!SemiFunc.RunIsLevel())
			{
				return CurrentExtCount;
			}
			if (ChallengeManager.IsChallengeActive(ChallengeManager.ChallengeType.HiddenInformation))
			{
				return Random.Range(1, 3);
			}
			if (!Plugin.Modify_ExtractionCount.Value)
			{
				return CurrentExtCount;
			}
			return SwaggiFunc.DetermineNumberOfExtractions(CurrentLevel, GameDirector.instance.PlayerList.Count);
		}

		[HarmonyPatch(/*Could not decode attribute arguments.*/)]
		[HarmonyTranspiler]
		private static IEnumerable<CodeInstruction> TileGenerationTranspiler(IEnumerable<CodeInstruction> inst)
		{
			//IL_017d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: Expected O, but got Unknown
			//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ad: Expected O, but got Unknown
			//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d1: Expected O, but got Unknown
			//IL_01de: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e8: Expected O, but got Unknown
			//IL_0204: Unknown result type (might be due to invalid IL or missing references)
			//IL_020e: Expected O, but got Unknown
			//IL_0228: Unknown result type (might be due to invalid IL or missing references)
			//IL_0232: Expected O, but got Unknown
			List<CodeInstruction> list = new List<CodeInstruction>(inst);
			if (list.Count <= 20)
			{
				Plugin.loggy.LogError((object)"Less than 20 instructions were found in TileGeneration, this is abnormal.");
				return list;
			}
			int num = -1;
			for (int i = 3; i < list.Count - 1; i++)
			{
				if (list[i].opcode == OpCodes.Ldfld && (FieldInfo)list[i].operand == AccessTools.Field(typeof(LevelGenerator), "ModuleAmount") && list[i + 1].opcode == OpCodes.Ldc_I4_3)
				{
					num = i - 3;
					break;
				}
			}
			if (num == -1)
			{
				Plugin.loggy.LogError((object)"Never found an insertion point for ModuleCount, unable to patch TileGeneration.");
				return list;
			}
			int num2 = -1;
			for (int j = 1; j < list.Count - 1; j++)
			{
				if (list[j].opcode == OpCodes.Ldarg_0 && list[j + 1].opcode == OpCodes.Ldc_I4_M1 && list[j + 4].opcode == OpCodes.Ldfld && (FieldInfo)list[j + 4].operand == AccessTools.Field(typeof(LevelGenerator), "ExtractionAmount"))
				{
					num2 = j - 1;
					break;
				}
			}
			if (num2 == -1)
			{
				Plugin.loggy.LogError((object)"Never found an insertion point for ExtractionCount, unable to patch TileGeneration.");
				return list;
			}
			List<CodeInstruction> collection = new List<CodeInstruction>
			{
				new CodeInstruction(OpCodes.Ldloc_1, (object)null),
				new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(LevelGeneratorPatch), "GetNewModuleCount", (Type[])null, (Type[])null)),
				new CodeInstruction(OpCodes.Stfld, (object)AccessTools.Field(typeof(LevelGenerator), "ModuleAmount"))
			};
			List<CodeInstruction> collection2 = new List<CodeInstruction>
			{
				new CodeInstruction(OpCodes.Ldloc_1, (object)null),
				new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(LevelGeneratorPatch), "GetNewExtractionCount", (Type[])null, (Type[])null)),
				new CodeInstruction(OpCodes.Stfld, (object)AccessTools.Field(typeof(LevelGenerator), "ExtractionAmount"))
			};
			list.InsertRange(num2, collection2);
			list.InsertRange(num, collection);
			return list;
		}
	}
	[BepInPlugin("Swaggies.LevelScaling", "LevelScaling", "0.9.1")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		public enum ExtractedUIDisplayType
		{
			AlwaysTotalMapValue,
			AlwaysCurrentMapValue,
			Alternate
		}

		public enum HaulGoalRoundingOptions
		{
			NoRounding,
			RoundToTen,
			RoundToHundred,
			RoundToThousand
		}

		private const string _guid = "Swaggies.LevelScaling";

		private const string _name = "LevelScaling";

		public const string _ver = "0.9.1";

		private readonly Harmony harmony = new Harmony("Swaggies.LevelScaling");

		public static ManualLogSource loggy;

		public static ConfigEntry<bool> StatsUIShow_Base;

		public static ConfigEntry<bool> StatsUIShow_Map;

		public static ConfigEntry<bool> StatsUIShow_EndOfLevel;

		public static ConfigEntry<bool> StatsUIShow_Shop;

		public static ConfigEntry<ExtractedUIDisplayType> StatsUIShow_ExtractedUI;

		public static ConfigEntry<bool> StatsUIDisplay_Challenge;

		public static ConfigEntry<bool> StatsUIDisplay_Time;

		public static ConfigEntry<bool> StatsUIDisplay_Deaths;

		public static ConfigEntry<bool> StatsUIDisplay_OrbDrops;

		public static ConfigEntry<bool> StatsUIDisplay_Extracted;

		public static ConfigEntry<bool> StatsUIDisplay_Broken;

		public static ConfigEntry<bool> StatsUIDisplay_Found;

		public static ConfigEntry<bool> StatsUIDisplay_Explored;

		public static ConfigEntry<bool> ShowOldOvercharge;

		public static ConfigEntry<bool> ChallengeGuarantee;

		public static ConfigEntry<bool> ChallengeDisableMoonPhase;

		public static ConfigEntry<float> ChallengeChanceMultiplier;

		public static ConfigEntry<int> ChallengeChanceMultiplier_LightsOut;

		public static ConfigEntry<int> ChallengeChanceMultiplier_HighQuota;

		public static ConfigEntry<int> ChallengeChanceMultiplier_LargeMap;

		public static ConfigEntry<int> ChallengeChanceMultiplier_FoggyLevel;

		public static ConfigEntry<int> ChallengeChanceMultiplier_IncreasedDamage;

		public static ConfigEntry<int> ChallengeChanceMultiplier_FragileValuables;

		public static ConfigEntry<int> ChallengeChanceMultiplier_OverOvercharge;

		public static ConfigEntry<int> ChallengeChanceMultiplier_NoMap;

		public static ConfigEntry<int> ChallengeChanceMultiplier_EnemyRush;

		public static ConfigEntry<int> ChallengeChanceMultiplier_HiddenInformation;

		public static ConfigEntry<int> ChallengeChanceMultiplier_DangerZone;

		public static ConfigEntry<int> ChallengeChanceMultiplier_SharedDurability;

		public static ConfigEntry<bool> Modify_ModuleCount;

		public static ConfigEntry<int> ModuleCountBase_Level1;

		public static ConfigEntry<int> ModuleCountBase_Level5;

		public static ConfigEntry<int> ModuleCountBase_Level10;

		public static ConfigEntry<int> ModuleCountBase_Level20;

		public static ConfigEntry<int> ModuleCountBase_Level50;

		public static ConfigEntry<int> ModuleCountBase_Level100;

		public static ConfigEntry<int> ModuleCount_RandomMin;

		public static ConfigEntry<int> ModuleCount_RandomMax;

		public static ConfigEntry<int> ModuleCount_PerPlayer;

		public static ConfigEntry<int> ModuleCount_PerPlayerMax;

		public static ConfigEntry<float> ModuleCountMultiplier_HeadmanManor;

		public static ConfigEntry<float> ModuleCountMultiplier_McJannekStation;

		public static ConfigEntry<float> ModuleCountMultiplier_SwiftbroomAcademy;

		public static ConfigEntry<float> ModuleCountMultiplier_MuseumOfHumanArt;

		public static ConfigEntry<bool> Modify_ExtractionCount;

		public static ConfigEntry<int> ExtractionCountBase_Level1;

		public static ConfigEntry<int> ExtractionCountBase_Level5;

		public static ConfigEntry<int> ExtractionCountBase_Level10;

		public static ConfigEntry<int> ExtractionCountBase_Level20;

		public static ConfigEntry<int> ExtractionCountBase_Level50;

		public static ConfigEntry<int> ExtractionCountBase_Level100;

		public static ConfigEntry<int> ExtractionCount_RandomMin;

		public static ConfigEntry<int> ExtractionCount_RandomMax;

		public static ConfigEntry<int> ExtractionCount_PerPlayer;

		public static ConfigEntry<int> ExtractionCount_PerPlayerMax;

		public static ConfigEntry<bool> Modify_HaulGoal;

		public static ConfigEntry<float> HaulGoalBase_Level1;

		public static ConfigEntry<float> HaulGoalBase_Level5;

		public static ConfigEntry<float> HaulGoalBase_Level10;

		public static ConfigEntry<float> HaulGoalBase_Level20;

		public static ConfigEntry<float> HaulGoalBase_Level50;

		public static ConfigEntry<float> HaulGoalBase_Level100;

		public static ConfigEntry<float> HaulGoal_ExtractionModifier;

		public static ConfigEntry<HaulGoalRoundingOptions> HaulGoal_RoundingOptions;

		public static ConfigEntry<bool> Modify_TotalMapValue;

		public static ConfigEntry<int> TotalMapValueBase_Level1;

		public static ConfigEntry<int> TotalMapValueBase_Level5;

		public static ConfigEntry<int> TotalMapValueBase_Level10;

		public static ConfigEntry<int> TotalMapValueBase_Level20;

		public static ConfigEntry<int> TotalMapValueBase_Level50;

		public static ConfigEntry<int> TotalMapValueBase_Level100;

		public static ConfigEntry<float> TotalMapValue_RandomMin;

		public static ConfigEntry<float> TotalMapValue_RandomMax;

		public static ConfigEntry<float> TotalMapValue_PerPlayer;

		public static ConfigEntry<int> TotalMapValue_PerPlayerMax;

		private void Awake()
		{
			loggy = Logger.CreateLogSource("Swaggies.LevelScaling");
			loggy.LogMessage((object)"LevelScaling's up and runnin' on 0.9.1");
			ChallengeManager.Setup();
			LevelStatsSyncing.Setup();
			harmony.PatchAll(typeof(LevelGeneratorPatch));
			harmony.PatchAll(typeof(ExtractionPointPatch));
			harmony.PatchAll(typeof(ValuableDirectorPatch));
			harmony.PatchAll(typeof(RunManagerPatch));
			harmony.PatchAll(typeof(StatsManagerPatch));
			harmony.PatchAll(typeof(GameDirectorPatch));
			harmony.PatchAll(typeof(LightManagerPatch));
			harmony.PatchAll(typeof(LoadingUIPatch));
			harmony.PatchAll(typeof(EnvironmentDirectorPatch));
			harmony.PatchAll(typeof(PlayerControllerPatch));
			harmony.PatchAll(typeof(PlayerHealthPatch));
			harmony.PatchAll(typeof(EnemyHealthPatch));
			harmony.PatchAll(typeof(PhysGrabObjectImpactDetectorPatch));
			harmony.PatchAll(typeof(ValuableObjectPatch));
			harmony.PatchAll(typeof(TruckScreenTextPatch));
			harmony.PatchAll(typeof(StatsUIPatch));
			harmony.PatchAll(typeof(EnemyParentPatch));
			harmony.PatchAll(typeof(EnemyValuablePatch));
			harmony.PatchAll(typeof(OverchargeUI));
			harmony.PatchAll(typeof(PhysGrabObjectPatch));
			harmony.PatchAll(typeof(PhysGrabberPatch));
			harmony.PatchAll(typeof(MapToolControllerPatch));
			harmony.PatchAll(typeof(PlayerAvatarPatch));
			harmony.PatchAll(typeof(EnemyDirectorPatch));
			harmony.PatchAll(typeof(EnemyRigidbodyPatch));
			harmony.PatchAll(typeof(HealthUIPatch));
			harmony.PatchAll(typeof(EnergyUIPatch));
			harmony.PatchAll(typeof(HaulUIPatch));
			harmony.PatchAll(typeof(ClownTrapPatch));
			harmony.PatchAll(typeof(ValuableEggPatch));
			harmony.PatchAll(typeof(SemiFuncPatch));
			harmony.PatchAll(typeof(MapPatch));
			harmony.PatchAll(typeof(MapModulePatch));
			harmony.PatchAll(typeof(RoundDirectorPatch));
			harmony.PatchAll(typeof(MenuPageSavesPatch));
			CreateConfig();
		}

		private void CreateConfig()
		{
			CreateStatsUIConfig();
			CreateMiscConfig();
			CreateChallengeConfig();
			CreateModuleConfig();
			CreateExtractionConfig();
			CreateHaulGoalConfig();
			CreateTotalMapValueConfig();
		}

		private void CreateStatsUIConfig()
		{
			StatsUIShow_Base = ((BaseUnityPlugin)this).Config.Bind<bool>("Level Stats UI", "Show always", true, "Whether the level stats are always displayed on screen (applies when changed)");
			StatsUIShow_Map = ((BaseUnityPlugin)this).Config.Bind<bool>("Level Stats UI", "Show when map is open", true, "Whether the level stats are displayed with the map open (if not, they will be hidden with the map open, overriding other settings) (applies when changed)");
			StatsUIShow_EndOfLevel = ((BaseUnityPlugin)this).Config.Bind<bool>("Level Stats UI", "Show at end of level", true, "Whether the level stats will be shown at the end of a level (overriden by Always Show and Show With Map) (applies when changed)");
			StatsUIShow_Shop = ((BaseUnityPlugin)this).Config.Bind<bool>("Level Stats UI", "Show in shop", true, "Whether the level stats are shown in the shop (overriden by all other settings) (applies when changed)");
			StatsUIShow_ExtractedUI = ((BaseUnityPlugin)this).Config.Bind<ExtractedUIDisplayType>("Level Stats UI", "Extracted Value Display Type", ExtractedUIDisplayType.AlwaysTotalMapValue, "If the \"extracted value\" stats displays the total map value, or current remaining map value (taking broken valuables into account). Set to Alternate for automatically swapping between them every few seconds in-game (applies when changed)");
			StatsUIDisplay_Challenge = ((BaseUnityPlugin)this).Config.Bind<bool>("Level Stats UI", "Display Active Challenge", true, "Whether to display the active challenge on the UI (applies when changed)");
			StatsUIDisplay_Time = ((BaseUnityPlugin)this).Config.Bind<bool>("Level Stats UI", "Display Level Timer", true, "Whether to display the level stopwatch on the UI (applies when changed)");
			StatsUIDisplay_Deaths = ((BaseUnityPlugin)this).Config.Bind<bool>("Level Stats UI", "Display Shop Death Count", true, "Whether to display the number of shop deaths on the UI (applies when changed)");
			StatsUIDisplay_OrbDrops = ((BaseUnityPlugin)this).Config.Bind<bool>("Level Stats UI", "Display Orb Drops Count", true, "Whether to display the number of orbs dropped from killed enemies on the UI (applies when changed)");
			StatsUIDisplay_Extracted = ((BaseUnityPlugin)this).Config.Bind<bool>("Level Stats UI", "Display Value Extracted", true, "Whether to display the amount of value extracted on the UI (applies when changed)");
			StatsUIDisplay_Broken = ((BaseUnityPlugin)this).Config.Bind<bool>("Level Stats UI", "Display Value Broken", true, "Whether to display the amount of value broken on the UI (applies when changed)");
			StatsUIDisplay_Found = ((BaseUnityPlugin)this).Config.Bind<bool>("Level Stats UI", "Display Valuables Found", true, "Whether to display the number of valuables found on the UI (applies when changed)");
			StatsUIDisplay_Explored = ((BaseUnityPlugin)this).Config.Bind<bool>("Level Stats UI", "Display Modules Explored", true, "Whether to display the number of modules explored on the UI (applies when changed)");
		}

		private void CreateMiscConfig()
		{
			ShowOldOvercharge = ((BaseUnityPlugin)this).Config.Bind<bool>("Misc", "Show old Overcharge UI", true, "Whether to enable the old Overcharge UI (number at the top left under the stamina meter - seen in old videos with overcharge) (applies at the start of each level)");
		}

		private void CreateChallengeConfig()
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Expected O, but got Unknown
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Expected O, but got Unknown
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Expected O, but got Unknown
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Expected O, but got Unknown
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Expected O, but got Unknown
			//IL_016d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0177: Expected O, but got Unknown
			//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01aa: Expected O, but got Unknown
			//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dd: Expected O, but got Unknown
			//IL_0206: Unknown result type (might be due to invalid IL or missing references)
			//IL_0210: Expected O, but got Unknown
			//IL_0239: Unknown result type (might be due to invalid IL or missing references)
			//IL_0243: Expected O, but got Unknown
			//IL_026c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0276: Expected O, but got Unknown
			//IL_029f: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a9: Expected O, but got Unknown
			//IL_02d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02dc: Expected O, but got Unknown
			ChallengeChanceMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Challenge Levels", "Chance multiplier", 1f, new ConfigDescription("Adjust the multiplier for the chance of a challenge level appearing - you can see the base challenges in the mod's README. (applies before the start of each level) (HOST ONLY)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 5f), Array.Empty<object>()));
			ChallengeGuarantee = ((BaseUnityPlugin)this).Config.Bind<bool>("Challenge Levels", "Guaranteed challenge levels", false, "Guarantees that every level will be a challenge level, regardless of all settings and multipliers. (applies before the start of each level) (HOST ONLY)");
			ChallengeDisableMoonPhase = ((BaseUnityPlugin)this).Config.Bind<bool>("Challenge Levels", "Prevent on new moon phases", true, "When enabled, challenge levels cannot appear on levels when the moon phase switches. (applies before the start of each level) (HOST ONLY)");
			ChallengeChanceMultiplier_LightsOut = ((BaseUnityPlugin)this).Config.Bind<int>("Challenge Levels", "Lights Out Weight", 30, new ConfigDescription("Adjust the chance for this challenge to appear - you can see the base weights in the mod's README. (applies before the start of each level) (HOST ONLY)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>()));
			ChallengeChanceMultiplier_HighQuota = ((BaseUnityPlugin)this).Config.Bind<int>("Challenge Levels", "Overtime Weight", 50, new ConfigDescription("Adjust the chance for this challenge to appear - you can see the base weights in the mod's README. (applies before the start of each level) (HOST ONLY)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>()));
			ChallengeChanceMultiplier_LargeMap = ((BaseUnityPlugin)this).Config.Bind<int>("Challenge Levels", "Enlarged Level Weight", 20, new ConfigDescription("Adjust the chance for this challenge to appear - you can see the base weights in the mod's README. (applies before the start of each level) (HOST ONLY)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>()));
			ChallengeChanceMultiplier_FoggyLevel = ((BaseUnityPlugin)this).Config.Bind<int>("Challenge Levels", "Dense Fog Weight", 20, new ConfigDescription("Adjust the chance for this challenge to appear - you can see the base weights in the mod's README. (applies before the start of each level) (HOST ONLY)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>()));
			ChallengeChanceMultiplier_IncreasedDamage = ((BaseUnityPlugin)this).Config.Bind<int>("Challenge Levels", "Increased Damage Weight", 30, new ConfigDescription("Adjust the chance for this challenge to appear - you can see the base weights in the mod's README. (applies before the start of each level) (HOST ONLY)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>()));
			ChallengeChanceMultiplier_FragileValuables = ((BaseUnityPlugin)this).Config.Bind<int>("Challenge Levels", "Fragile Valuables Weight", 50, new ConfigDescription("Adjust the chance for this challenge to appear - you can see the base weights in the mod's README. (applies before the start of each level) (HOST ONLY)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>()));
			ChallengeChanceMultiplier_OverOvercharge = ((BaseUnityPlugin)this).Config.Bind<int>("Challenge Levels", "Over-Overcharge Weight", 50, new ConfigDescription("Adjust the chance for this challenge to appear - you can see the base weights in the mod's README. (applies before the start of each level) (HOST ONLY)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>()));
			ChallengeChanceMultiplier_NoMap = ((BaseUnityPlugin)this).Config.Bind<int>("Challenge Levels", "Broken Map Weight", 40, new ConfigDescription("Adjust the chance for this challenge to appear - you can see the base weights in the mod's README. (applies before the start of each level) (HOST ONLY)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>()));
			ChallengeChanceMultiplier_EnemyRush = ((BaseUnityPlugin)this).Config.Bind<int>("Challenge Levels", "Enemy Rush Weight", 35, new ConfigDescription("Adjust the chance for this challenge to appear - you can see the base weights in the mod's README. (applies before the start of each level) (HOST ONLY)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>()));
			ChallengeChanceMultiplier_HiddenInformation = ((BaseUnityPlugin)this).Config.Bind<int>("Challenge Levels", "Hidden Information Weight", 15, new ConfigDescription("Adjust the chance for this challenge to appear - you can see the base weights in the mod's README. (applies before the start of each level) (HOST ONLY)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>()));
			ChallengeChanceMultiplier_DangerZone = ((BaseUnityPlugin)this).Config.Bind<int>("Challenge Levels", "Danger Zone Weight", 20, new ConfigDescription("Adjust the chance for this challenge to appear - you can see the base weights in the mod's README. (applies before the start of each level) (HOST ONLY)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>()));
			ChallengeChanceMultiplier_SharedDurability = ((BaseUnityPlugin)this).Config.Bind<int>("Challenge Levels", "Shared Durability Weight", 15, new ConfigDescription("Adjust the chance for this challenge to appear - you can see the base weights in the mod's README. (applies before the start of each level) (HOST ONLY)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>()));
		}

		private void CreateModuleConfig()
		{
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Expected O, but got Unknown
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Expected O, but got Unknown
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Expected O, but got Unknown
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Expected O, but got Unknown
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Expected O, but got Unknown
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Expected O, but got Unknown
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: Expected O, but got Unknown
			//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b0: Expected O, but got Unknown
			//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e2: Expected O, but got Unknown
			//IL_020a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0214: Expected O, but got Unknown
			//IL_0247: Unknown result type (might be due to invalid IL or missing references)
			//IL_0251: Expected O, but got Unknown
			//IL_0284: Unknown result type (might be due to invalid IL or missing references)
			//IL_028e: Expected O, but got Unknown
			//IL_02c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cb: Expected O, but got Unknown
			//IL_02fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0308: Expected O, but got Unknown
			Modify_ModuleCount = ((BaseUnityPlugin)this).Config.Bind<bool>("Modules", "Modify Module Count", true, "Whether Level Scaling should apply its progressive module counts for levels. If disabled, vanilla behaviour will take over, and all of the following config options will be ignored. (applies at the start of each level) (HOST ONLY)");
			ModuleCountBase_Level1 = ((BaseUnityPlugin)this).Config.Bind<int>("Modules", "Module Count - Level 1", 4, new ConfigDescription("Number of modules at this level. Modules between level configs will be interpolated and rounded down. (applies at the start of each level) (HOST ONLY)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(3, 32), Array.Empty<object>()));
			ModuleCountBase_Level5 = ((BaseUnityPlugin)this).Config.Bind<int>("Modules", "Module Count - Level 5", 6, new ConfigDescription("Number of modules at this level. Modules between level configs will be interpolated and rounded down. (applies at the start of each level) (HOST ONLY)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(3, 32), Array.Empty<object>()));
			ModuleCountBase_Level10 = ((BaseUnityPlugin)this).Config.Bind<int>("Modules", "Module Count - Level 10", 8, new ConfigDescription("Number of modules at this level. Modules between level configs will be interpolated and rounded down. (applies at the start of each level) (HOST ONLY)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(3, 32), Array.Empty<object>()));
			ModuleCountBase_Level20 = ((BaseUnityPlugin)this).Config.Bind<int>("Modules", "Module Count - Level 20", 15, new ConfigDescription("Number of modules at this level. Modules between level configs will be interpolated and rounded down. (applies at the start of each level) (HOST ONLY)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(3, 32), Array.Empty<object>()));
			ModuleCountBase_Level50 = ((BaseUnityPlugin)this).Config.Bind<int>("Modules", "Module Count - Level 50", 20, new ConfigDescription("Number of modules at this level. Modules between level configs will be interpolated and rounded down. (applies at the start of each level) (HOST ONLY)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(3, 32), Array.Empty<object>()));
			ModuleCountBase_Level100 = ((BaseUnityPlugin)this).Config.Bind<int>("Modules", "Module Count - Level 100", 25, new ConfigDescription("Number of modules at this level. Modules between level configs will be interpolated and rounded down. (applies at the start of each level) (HOST ONLY)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(3, 32), Array.Empty<object>()));
			ModuleCount_RandomMin = ((BaseUnityPlugin)this).Config.Bind<int>("Modules", "Random Min", 0, new ConfigDescription("Minimum number of modules to randomly add to the base amount on each level. Negative numbers can make the map smaller. (applies at the start of each level) (HOST ONLY)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(-10, 10), Array.Empty<object>()));
			ModuleCount_RandomMax = ((BaseUnityPlugin)this).Config.Bind<int>("Modules", "Random Max", 0, new ConfigDescription("Maximum number of modules to randomly add to the base amount on each level. Negative numbers can make the map smaller. (applies at the start of each level) (HOST ONLY)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(-10, 10), Array.Empty<object>()));
			ModuleCount_PerPlayer = ((BaseUnityPlugin)this).Config.Bind<int>("Modules", "Modules Added Per Player", 0, new ConfigDescription("Number of added modules per player in the lobby. (applies at the start of each level) (HOST ONLY)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(-3, 3), Array.Empty<object>()));
			ModuleCount_PerPlayerMax = ((BaseUnityPlugin)this).Config.Bind<int>("Modules", "Accounted Players", 6, new ConfigDescription("Maximum number of players to account for when adding modules per player. (applies at the start of each level) (HOST ONLY)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 9), Array.Empty<object>()));
			ModuleCountMultiplier_HeadmanManor = ((BaseUnityPlugin)this).Config.Bind<float>("Modules", "Multiplier - Headman Manor", 1f, new ConfigDescription("Module count multiplier for this specific level type. (applies at the start of each level) (HOST ONLY)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 2f), Array.Empty<object>()));
			ModuleCountMultiplier_McJannekStation = ((BaseUnityPlugin)this).Config.Bind<float>("Modules", "Multiplier - McJannek Station", 1f, new ConfigDescription("Module count multiplier for this specific level type. (applies at the start of each level) (HOST ONLY)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 2f), Array.Empty<object>()));
			ModuleCountMultiplier_SwiftbroomAcademy = ((BaseUnityPlugin)this).Config.Bind<float>("Modules", "Multiplier - Swiftbroom Academy", 1f, new ConfigDescription("Module count multiplier for this specific level type. (applies at the start of each level) (HOST ONLY)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 2f), Array.Empty<object>()));
			ModuleCountMultiplier_MuseumOfHumanArt = ((BaseUnityPlugin)this).Config.Bind<float>("Modules", "Multiplier - Museum Of Human Art", 1f, new ConfigDescription("Module count multiplier for this specific level type. (applies at the start of each level) (HOST ONLY)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 2f), Array.Empty<object>()));
		}

		private void CreateExtractionConfig()
		{
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Expected O, but got Unknown
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Expected O, but got Unknown
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Expected O, but got Unknown
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Expected O, but got Unknown
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Expected O, but got Unknown
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: Expected O, but got Unknown
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_017a: Expected O, but got Unknown
			//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ac: Expected O, but got Unknown
			//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01de: Expected O, but got Unknown
			//IL_0205: Unknown result type (might be due to invalid IL or missing references)
			//IL_020f: Expected O, but got Unknown
			Modify_ExtractionCount = ((BaseUnityPlugin)this).Config.Bind<bool>("Extractions", "Modify Extraction Count", true, "Whether Level Scaling should apply its progressive extraction counts for levels. If disabled, vanilla behaviour will take over, and all of the following config options will be ignored. (applies at the start of each level) (HOST ONLY)");
			ExtractionCountBase_Level1 = ((BaseUnityPlugin)this).Config.Bind<int>("Extractions", "Extraction Count - Level 1", 1, new ConfigDescription("Number of extractions at this level. Extractions between level configs will be interpolated and rounded down. (applies at the start of each level) (HOST ONLY)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 12), Array.Empty<object>()));
			ExtractionCountBase_Level5 = ((BaseUnityPlugin)this).Config.Bind<int>("Extractions", "Extraction Count - Level 5", 3, new ConfigDescription("Number of extractions at this level. Extractions between level configs will be interpolated and rounded down. (applies at the start of each level) (HOST ONLY)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 12), Array.Empty<object>()));
			ExtractionCountBase_Level10 = ((BaseUnityPlugin)this).Config.Bind<int>("Extractions", "Extraction Count - Level 10", 4, new ConfigDescription("Number of extractions at this level. Extractions between level configs will be interpolated and rounded down. (applies at the start of each level) (HOST ONLY)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 12), Array.Empty<object>()));
			ExtractionCountBase_Level20 = ((BaseUnityPlugin)this).Config.Bind<int>("Extractions", "Extraction Count - Level 20", 5, new ConfigDescription("Number of extractions at this level. Extractions between level configs will be interpolated and rounded down. (applies at the start of each level) (HOST ONLY)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 12), Array.Empty<object>()));
			ExtractionCountBase_Level50 = ((BaseUnityPlugin)this).Config.Bind<int>("Extractions", "Extraction Count - Level 50", 7, new ConfigDescription("Number of extractions at this level. Extractions between level configs will be interpolated and rounded down. (applies at the start of each level) (HOST ONLY)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 12), Array.Empty<object>()));
			ExtractionCountBase_Level100 = ((BaseUnityPlugin)this).Config.Bind<int>("Extractions", "Extraction Count - Level 100", 10, new ConfigDescription("Number of extractions at this level. Extractions between level configs will be interpolated and rounded down. (applies at the start of each level) (HOST ONLY)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 12), Array.Empty<object>()));
			ExtractionCount_RandomMin = ((BaseUnityPlugin)this).Config.Bind<int>("Extractions", "Random Min", 0, new ConfigDescription("Minimum number of extractions to randomly add to the base amount on each level. (applies at the start of each level) (HOST ONLY)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(-5, 5), Array.Empty<object>()));
			ExtractionCount_RandomMax = ((BaseUnityPlugin)this).Config.Bind<int>("Extractions", "Random Max", 0, new ConfigDescription("Maximum number of extractions to randomly add to the base amount on each level. (applies at the start of each level) (HOST ONLY)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(-5, 5), Array.Empty<object>()));
			ExtractionCount_PerPlayer = ((BaseUnityPlugin)this).Config.Bind<int>("Extractions", "Added Per Player", 0, new ConfigDescription("Number of added extractions per player in the lobby. (applies at the start of each level) (HOST ONLY)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(-3, 3), Array.Empty<object>()));
			ExtractionCount_PerPlayerMax = ((BaseUnityPlugin)this).Config.Bind<int>("Extractions", "Accounted Players", 6, new ConfigDescription("Maximum number of players to account for when adding extractions per player. (applies at the start of each level) (HOST ONLY)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 5), Array.Empty<object>()));
		}

		private void CreateHaulGoalConfig()
		{
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Expected O, but got Unknown
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Expected O, but got Unknown
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Expected O, but got Unknown
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Expected O, but got Unknown
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Expected O, but got Unknown
			//IL_017f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0189: Expected O, but got Unknown
			//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c6: Expected O, but got Unknown
			Modify_HaulGoal = ((BaseUnityPlugin)this).Config.Bind<bool>("Haul Goal", "Modify Haul Goal", true, "Whether Level Scaling should apply its progressive quotas for extraction points in levels. If disabled, vanilla behaviour will take over, and all of the following config options will be ignored. (applies when an extraction point is activated) (HOST ONLY)");
			HaulGoalBase_Level1 = ((BaseUnityPlugin)this).Config.Bind<float>("Haul Goal", "Quota Difficulty - Level 1", 0.25f, new ConfigDescription("Haul Goal difficulty for this level. The difficulty determines the percentage of map value required to complete all extractions (eg. 0.7 = 70% of map value). Values between level configs will be interpolated. (applies when an extraction point is activated) (HOST ONLY)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 1f), Array.Empty<object>()));
			HaulGoalBase_Level5 = ((BaseUnityPlugin)this).Config.Bind<float>("Haul Goal", "Quota Difficulty - Level 5", 0.45f, new ConfigDescription("Haul Goal difficulty for this level. The difficulty determines the percentage of map value required to complete all extractions (eg. 0.7 = 70% of map value). Values between level configs will be interpolated. (applies when an extraction point is activated) (HOST ONLY)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 1f), Array.Empty<object>()));
			HaulGoalBase_Level10 = ((BaseUnityPlugin)this).Config.Bind<float>("Haul Goal", "Quota Difficulty - Level 10", 0.55f, new ConfigDescription("Haul Goal difficulty for this level. The difficulty determines the percentage of map value required to complete all extractions (eg. 0.7 = 70% of map value). Values between level configs will be interpolated. (applies when an extraction point is activated) (HOST ONLY)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 1f), Array.Empty<object>()));
			HaulGoalBase_Level20 = ((BaseUnityPlugin)this).Config.Bind<float>("Haul Goal", "Quota Difficulty - Level 20", 0.7f, new ConfigDescription("Haul Goal difficulty for this level. The difficulty determines the percentage of map value required to complete all extractions (eg. 0.7 = 70% of map value). Values between level configs will be interpolated. (applies when an extraction point is activated) (HOST ONLY)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 1f), Array.Empty<object>()));
			HaulGoalBase_Level50 = ((BaseUnityPlugin)this).Config.Bind<float>("Haul Goal", "Quota Difficulty - Level 50", 0.75f, new ConfigDescription("Haul Goal difficulty for this level. The difficulty determines the percentage of map value required to complete all extractions (eg. 0.7 = 70% of map value). Values between level configs will be interpolated. (applies when an extraction point is activated) (HOST ONLY)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 1f), Array.Empty<object>()));
			HaulGoalBase_Level100 = ((BaseUnityPlugin)this).Config.Bind<float>("Haul Goal", "Quota Difficulty - Level 100", 0.8f, new ConfigDescription("Haul Goal difficulty for this level. The difficulty determines the percentage of map value required to complete all extractions (eg. 0.7 = 70% of map value). Values between level configs will be interpolated. (applies when an extraction point is activated) (HOST ONLY)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 1f), Array.Empty<object>()));
			HaulGoal_ExtractionModifier = ((BaseUnityPlugin)this).Config.Bind<float>("Haul Goal", "Extraction Index Modifier", 0.1f, new ConfigDescription("Reduces the quota for earlier extraction points, raising it per extraction until it reaches the base value for the final extraction. (example: with this value set to 0.1, on a map with 4 extractions, the extraction modifier in order is as follows: 0.7x, 0.8x, 0.9x, then finally 1.0x; if set to 0.15, it would instead be: 0.55x, 0.7x, 0.85x, then 1.0x) (applies when an extraction point is activated) (HOST ONLY)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 0.3f), Array.Empty<object>()));
			HaulGoal_RoundingOptions = ((BaseUnityPlugin)this).Config.Bind<HaulGoalRoundingOptions>("Haul Goal", "Rounding Options", HaulGoalRoundingOptions.NoRounding, "Determine how to round the quota for extractions. (applies when an extraction point is activated) (HOST ONLY)");
		}

		private void CreateTotalMapValueConfig()
		{
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Expected O, but got Unknown
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Expected O, but got Unknown
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Expected O, but got Unknown
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Expected O, but got Unknown
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Expected O, but got Unknown
			//IL_0167: Unknown result type (might be due to invalid IL or missing references)
			//IL_0171: Expected O, but got Unknown
			//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ae: Expected O, but got Unknown
			//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01eb: Expected O, but got Unknown
			//IL_021e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0228: Expected O, but got Unknown
			//IL_0250: Unknown result type (might be due to invalid IL or missing references)
			//IL_025a: Expected O, but got Unknown
			Modify_TotalMapValue = ((BaseUnityPlugin)this).Config.Bind<bool>("Total Map Value", "Modify Total Map Value", true, "Whether Level Scaling should apply its progressive map values for levels. If disabled, vanilla behaviour will take over, and all of the following config options will be ignored. (applies at the start of each level) (HOST ONLY)");
			TotalMapValueBase_Level1 = ((BaseUnityPlugin)this).Config.Bind<int>("Total Map Value", "Total Map Value ($K) - Level 1", 30, new ConfigDescription("Total map value (in thousands of dollars) at this level. Values between level configs will be interpolated and rounded to the nearest thousand. (applies at the start of each level) (HOST ONLY)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(10, 1000), Array.Empty<object>()));
			TotalMapValueBase_Level5 = ((BaseUnityPlugin)this).Config.Bind<int>("Total Map Value", "Total Map Value ($K) - Level 5", 90, new ConfigDescription("Total map value (in thousands of dollars) at this level. Values between level configs will be interpolated and rounded to the nearest thousand. (applies at the start of each level) (HOST ONLY)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(10, 1000), Array.Empty<object>()));
			TotalMapValueBase_Level10 = ((BaseUnityPlugin)this).Config.Bind<int>("Total Map Value", "Total Map Value ($K) - Level 10", 180, new ConfigDescription("Total map value (in thousands of dollars) at this level. Values between level configs will be interpolated and rounded to the nearest thousand. (applies at the start of each level) (HOST ONLY)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(10, 1000), Array.Empty<object>()));
			TotalMapValueBase_Level20 = ((BaseUnityPlugin)this).Config.Bind<int>("Total Map Value", "Total Map Value ($K) - Level 20", 250, new ConfigDescription("Total map value (in thousands of dollars) at this level. Values between level configs will be interpolated and rounded to the nearest thousand. (applies at the start of each level) (HOST ONLY)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(10, 1000), Array.Empty<object>()));
			TotalMapValueBase_Level50 = ((BaseUnityPlugin)this).Config.Bind<int>("Total Map Value", "Total Map Value ($K) - Level 50", 350, new ConfigDescription("Total map value (in thousands of dollars) at this level. Values between level configs will be interpolated and rounded to the nearest thousand. (applies at the start of each level) (HOST ONLY)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(10, 1000), Array.Empty<object>()));
			TotalMapValueBase_Level100 = ((BaseUnityPlugin)this).Config.Bind<int>("Total Map Value", "Total Map Value ($K) - Level 100", 550, new ConfigDescription("Total map value (in thousands of dollars) at this level. Values between level configs will be interpolated and rounded to the nearest thousand. (applies at the start of each level) (HOST ONLY)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(10, 1000), Array.Empty<object>()));
			TotalMapValue_RandomMin = ((BaseUnityPlugin)this).Config.Bind<float>("Total Map Value", "Random Min", 0f, new ConfigDescription("Minimum random modifier to total map value. (-1.0 = half, +1.0 = double) (applies at the start of each level) (HOST ONLY)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-1f, 1f), Array.Empty<object>()));
			TotalMapValue_RandomMax = ((BaseUnityPlugin)this).Config.Bind<float>("Total Map Value", "Random Max", 0f, new ConfigDescription("Maximum random modifier to total map value. (-1.0 = half, +1.0 = double) (applies at the start of each level) (HOST ONLY)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-1f, 1f), Array.Empty<object>()));
			TotalMapValue_PerPlayer = ((BaseUnityPlugin)this).Config.Bind<float>("Total Map Value", "Added Per Player", 0f, new ConfigDescription("Per-player modifier for total map value. (0.1 = +10% per player) (applies at the start of each level) (HOST ONLY)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
			TotalMapValue_PerPlayerMax = ((BaseUnityPlugin)this).Config.Bind<int>("Total Map Value", "Accounted Players", 6, new ConfigDescription("Maximum number of players to account for when adding map value per player. (applies at the start of each level) (HOST ONLY)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 9), Array.Empty<object>()));
		}
	}
	[HarmonyPatch(typeof(ValuableDirector))]
	internal class ValuableDirectorPatch
	{
		private static int TotalMaxAmount => Traverse.Create((object)ValuableDirector.instance).Field("totalMaxAmount").GetValue<int>();

		private static int TinyMaxAmount => Traverse.Create((object)ValuableDirector.instance).Field("tinyMaxAmount").GetValue<int>();

		private static int SmallMaxAmount => Traverse.Create((object)ValuableDirector.instance).Field("smallMaxAmount").GetValue<int>();

		private static int MediumMaxAmount => Traverse.Create((object)ValuableDirector.instance).Field("mediumMaxAmount").GetValue<int>();

		private static int BigMaxAmount => Traverse.Create((object)ValuableDirector.instance).Field("bigMaxAmount").GetValue<int>();

		private static int WideMaxAmount => Traverse.Create((object)ValuableDirector.instance).Field("wideMaxAmount").GetValue<int>();

		private static int TallMaxAmount => Traverse.Create((object)ValuableDirector.instance).Field("tallMaxAmount").GetValue<int>();

		private static int VeryTallMaxAmount => Traverse.Create((object)ValuableDirector.instance).Field("veryTallMaxAmount").GetValue<int>();

		private static float TotalMaxValue => Traverse.Create((object)ValuableDirector.instance).Field("totalMaxValue").GetValue<float>();

		private static float NewValueCount()
		{
			float num = TotalMaxValue;
			if (SemiFunc.RunIsLevel())
			{
				if (Plugin.Modify_TotalMapValue.Value)
				{
					num = SwaggiFunc.DetermineMapValue(LevelGeneratorPatch.CurrentLevel, GameDirector.instance.PlayerList.Count);
				}
				if (ChallengeManager.IsChallengeActive(ChallengeManager.ChallengeType.HighQuota))
				{
					num *= 1.4f;
				}
			}
			return num;
		}

		private static int MultiplyItemCount(int inAmount)
		{
			if (!Plugin.Modify_TotalMapValue.Value)
			{
				if (ChallengeManager.IsChallengeActive(ChallengeManager.ChallengeType.HighQuota))
				{
					return Mathf.RoundToInt((float)inAmount * 1.33f);
				}
				return inAmount;
			}
			float num = 1f;
			if (LevelGeneratorPatch.CurrentLevel > 5)
			{
				num = Mathf.Lerp(1f, 1.1f, Mathf.InverseLerp(5f, 11f, (float)LevelGeneratorPatch.CurrentLevel));
			}
			if (LevelGeneratorPatch.CurrentLevel > 11)
			{
				num = Mathf.Lerp(1.1f, 2.2f, Mathf.InverseLerp(11f, 100f, (float)LevelGeneratorPatch.CurrentLevel));
			}
			if (LevelGeneratorPatch.CurrentLevel > 100)
			{
				num = Mathf.Lerp(2.2f, 5f, Mathf.InverseLerp(100f, 999f, (float)LevelGeneratorPatch.CurrentLevel));
			}
			if (ChallengeManager.IsChallengeActive(ChallengeManager.ChallengeType.HighQuota))
			{
				num *= 1.33f;
			}
			return Mathf.RoundToInt((float)inAmount * num);
		}

		private static int NewTotalItemCount()
		{
			return MultiplyItemCount(TotalMaxAmount);
		}

		private static int NewTinyItemCount()
		{
			return MultiplyItemCount(TinyMaxAmount);
		}

		private static int NewSmallItemCount()
		{
			return MultiplyItemCount(SmallMaxAmount);
		}

		private static int NewMediumItemCount()
		{
			return MultiplyItemCount(MediumMaxAmount);
		}

		private static int NewBigItemCount()
		{
			return MultiplyItemCount(BigMaxAmount);
		}

		private static int NewWideItemCount()
		{
			return MultiplyItemCount(WideMaxAmount);
		}

		private static int NewTallItemCount()
		{
			return MultiplyItemCount(TallMaxAmount);
		}

		private static int NewVeryTallItemCount()
		{
			return MultiplyItemCount(VeryTallMaxAmount);
		}

		[HarmonyPatch(/*Could not decode attribute arguments.*/)]
		[HarmonyTranspiler]
		private static IEnumerable<CodeInstruction> SetupHostTranspiler(IEnumerable<CodeInstruction> inst)
		{
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Expected O, but got Unknown
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Expected O, but got Unknown
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Expected O, but got Unknown
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Expected O, but got Unknown
			//IL_0171: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: Expected O, but got Unknown
			//IL_0195: Unknown result type (might be due to invalid IL or missing references)
			//IL_019f: Expected O, but got Unknown
			//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b0: Expected O, but got Unknown
			//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d6: Expected O, but got Unknown
			//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fa: Expected O, but got Unknown
			//IL_0201: Unknown result type (might be due to invalid IL or missing references)
			//IL_020b: Expected O, but got Unknown
			//IL_0227: Unknown result type (might be due to invalid IL or missing references)
			//IL_0231: Expected O, but got Unknown
			//IL_024b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0255: Expected O, but got Unknown
			//IL_025c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0266: Expected O, but got Unknown
			//IL_0282: Unknown result type (might be due to invalid IL or missing references)
			//IL_028c: Expected O, but got Unknown
			//IL_02a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b0: Expected O, but got Unknown
			//IL_02b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c1: Expected O, but got Unknown
			//IL_02dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e7: Expected O, but got Unknown
			//IL_0301: Unknown result type (might be due to invalid IL or missing references)
			//IL_030b: Expected O, but got Unknown
			//IL_0312: Unknown result type (might be due to invalid IL or missing references)
			//IL_031c: Expected O, but got Unknown
			//IL_0338: Unknown result type (might be due to invalid IL or missing references)
			//IL_0342: Expected O, but got Unknown
			//IL_035c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0366: Expected O, but got Unknown
			//IL_036d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0377: Expected O, but got Unknown
			//IL_0393: Unknown result type (might be due to invalid IL or missing references)
			//IL_039d: Expected O, but got Unknown
			//IL_03b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c1: Expected O, but got Unknown
			//IL_03c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d2: Expected O, but got Unknown
			//IL_03ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f8: Expected O, but got Unknown
			//IL_0412: Unknown result type (might be due to invalid IL or missing references)
			//IL_041c: Expected O, but got Unknown
			List<CodeInstruction> list = new List<CodeInstruction>(inst);
			if (list.Count <= 20)
			{
				Plugin.loggy.LogError((object)"Less than 20 instructions were found in SetupHost, this is abnormal, refusing to patch.");
				return list;
			}
			int num = -1;
			for (int i = 1; i < list.Count - 1; i++)
			{
				if (list[i].opcode == OpCodes.Stfld && list[i + 1].opcode == OpCodes.Call && (FieldInfo)list[i].operand == AccessTools.Field(typeof(ValuableDirector), "veryTallMaxAmount") && (MethodInfo)list[i + 1].operand == AccessTools.Method(typeof(SemiFunc), "RunIsArena", (Type[])null, (Type[])null))
				{
					num = i;
					break;
				}
			}
			if (num == -1)
			{
				Plugin.loggy.LogError((object)"Never found an insertion point, unable to patch SetupHost.");
				return list;
			}
			List<CodeInstruction> collection = new List<CodeInstruction>
			{
				new CodeInstruction(OpCodes.Ldloc_1, (object)null),
				new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(ValuableDirectorPatch), "NewValueCount", (Type[])null, (Type[])null)),
				new CodeInstruction(OpCodes.Stfld, (object)AccessTools.Field(typeof(ValuableDirector), "totalMaxValue")),
				new CodeInstruction(OpCodes.Ldloc_1, (object)null),
				new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(ValuableDirectorPatch), "NewTotalItemCount", (Type[])null, (Type[])null)),
				new CodeInstruction(OpCodes.Stfld, (object)AccessTools.Field(typeof(ValuableDirector), "totalMaxAmount")),
				new CodeInstruction(OpCodes.Ldloc_1, (object)null),
				new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(ValuableDirectorPatch), "NewSmallItemCount", (Type[])null, (Type[])null)),
				new CodeInstruction(OpCodes.Stfld, (object)AccessTools.Field(typeof(ValuableDirector), "smallMaxAmount")),
				new CodeInstruction(OpCodes.Ldloc_1, (object)null),
				new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(ValuableDirectorPatch), "NewMediumItemCount", (Type[])null, (Type[])null)),
				new CodeInstruction(OpCodes.Stfld, (object)AccessTools.Field(typeof(ValuableDirector), "mediumMaxAmount")),
				new CodeInstruction(OpCodes.Ldloc_1, (object)null),
				new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(ValuableDirectorPatch), "NewBigItemCount", (Type[])null, (Type[])null)),
				new CodeInstruction(OpCodes.Stfld, (object)AccessTools.Field(typeof(ValuableDirector), "bigMaxAmount")),
				new CodeInstruction(OpCodes.Ldloc_1, (object)null),
				new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(ValuableDirectorPatch), "NewWideItemCount", (Type[])null, (Type[])null)),
				new CodeInstruction(OpCodes.Stfld, (object)AccessTools.Field(typeof(ValuableDirector), "wideMaxAmount")),
				new CodeInstruction(OpCodes.Ldloc_1, (object)null),
				new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(ValuableDirectorPatch), "NewVeryTallItemCount", (Type[])null, (Type[])null)),
				new CodeInstruction(OpCodes.Stfld, (object)AccessTools.Field(typeof(ValuableDirector), "veryTallMaxAmount")),
				new CodeInstruction(OpCodes.Ldloc_1, (object)null),
				new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(ValuableDirectorPatch), "NewTallItemCount", (Type[])null, (Type[])null)),
				new CodeInstruction(OpCodes.Stfld, (object)AccessTools.Field(typeof(ValuableDirector), "tallMaxAmount")),
				new CodeInstruction(OpCodes.Ldloc_1, (object)null),
				new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(ValuableDirectorPatch), "NewTinyItemCount", (Type[])null, (Type[])null)),
				new CodeInstruction(OpCodes.Stfld, (object)AccessTools.Field(typeof(ValuableDirector), "tinyMaxAmount"))
			};
			list.InsertRange(num, collection);
			Plugin.loggy.LogDebug((object)"Successfully patched ValuableDirector.SetupHost");
			return list;
		}
	}
	internal class SwaggiFunc
	{
		public static string es3Password = "Why would you want to cheat?... :o It's no fun. :') :'D";

		public static float SharedDurability_overheal = 0f;

		private static float SharedDurability_lastHealTime = 0f;

		public static int DetermineNumberOfModules(int level, int playerCount, string levelName)
		{
			int num = ((level == 1) ? Plugin.ModuleCountBase_Level1.Value : ((level <= 5) ? ((int)Mathf.Lerp((float)Plugin.ModuleCountBase_Level1.Value, (float)Plugin.ModuleCountBase_Level5.Value, Mathf.InverseLerp(1f, 5f, (float)level))) : ((level <= 10) ? ((int)Mathf.Lerp((float)Plugin.ModuleCountBase_Level5.Value, (float)Plugin.ModuleCountBase_Level10.Value, Mathf.InverseLerp(5f, 10f, (float)level))) : ((level <= 20) ? ((int)Mathf.Lerp((float)Plugin.ModuleCountBase_Level10.Value, (float)Plugin.ModuleCountBase_Level20.Value, Mathf.InverseLerp(10f, 20f, (float)level))) : ((level <= 50) ? ((int)Mathf.Lerp((float)Plugin.ModuleCountBase_Level20.Value, (float)Plugin.ModuleCountBase_Level50.Value, Mathf.InverseLerp(20f, 50f, (float)level))) : ((level > 100) ? Plugin.ModuleCountBase_Level100.Value : ((int)Mathf.Lerp((float)Plugin.ModuleCountBase_Level50.Value, (float)Plugin.ModuleCountBase_Level100.Value, Mathf.InverseLerp(50f, 100f, (float)level)))))))));
			int num2 = 0;
			if (playerCount > 1)
			{
				for (int i = 1; i < Mathf.Min(playerCount, Plugin.ModuleCount_PerPlayerMax.Value); i++)
				{
					num2 += Plugin.ModuleCount_PerPlayer.Value;
				}
			}
			int num3 = Random.Range(Plugin.ModuleCount_RandomMin.Value, Mathf.Max(Plugin.ModuleCount_RandomMin.Value, Plugin.ModuleCount_RandomMax.Value) + 1);
			float num4 = 1f;
			switch (levelName.ToLower())
			{
			case "headman manor":
				num4 = Plugin.ModuleCountMultiplier_HeadmanManor.Value;
				break;
			case "mcjannek station":
				num4 = Plugin.ModuleCountMultiplier_McJannekStation.Value;
				break;
			case "swiftbroom academy":
				num4 = Plugin.ModuleCountMultiplier_SwiftbroomAcademy.Value;
				break;
			case "museum of human art":
				num4 = Plugin.ModuleCountMultiplier_MuseumOfHumanArt.Value;
				break;
			}
			return Mathf.Clamp(Mathf.RoundToInt((float)(num + num2 + num3) * num4), 3, 32);
		}

		public static int DetermineNumberOfExtractions(int level, int playerCount)
		{
			int num = ((level == 1) ? Plugin.ExtractionCountBase_Level1.Value : ((level <= 5) ? ((int)Mathf.Lerp((float)Plugin.ExtractionCountBase_Level1.Value, (float)Plugin.ExtractionCountBase_Level5.Value, Mathf.InverseLerp(1f, 5f, (float)level))) : ((level <= 10) ? ((int)Mathf.Lerp((float)Plugin.ExtractionCountBase_Level5.Value, (float)Plugin.ExtractionCountBase_Level10.Value, Mathf.InverseLerp(5f, 10f, (float)level))) : ((level <= 20) ? ((int)Mathf.Lerp((float)Plugin.ExtractionCountBase_Level10.Value, (float)Plugin.ExtractionCountBase_Level20.Value, Mathf.InverseLerp(10f, 20f, (float)level))) : ((level <= 50) ? ((int)Mathf.Lerp((float)Plugin.ExtractionCountBase_Level20.Value, (float)Plugin.ExtractionCountBase_Level50.Value, Mathf.InverseLerp(20f, 50f, (float)level))) : ((level > 100) ? Plugin.ExtractionCountBase_Level100.Value : ((int)Mathf.Lerp((float)Plugin.ExtractionCountBase_Level50.Value, (float)Plugin.ExtractionCountBase_Level100.Value, Mathf.InverseLerp(50f, 100f, (float)level)))))))));
			int num2 = 0;
			if (playerCount > 1)
			{
				for (int i = 1; i < Mathf.Min(playerCount, Plugin.ExtractionCount_PerPlayerMax.Value); i++)
				{
					num2 += Plugin.ExtractionCount_PerPlayer.Value;
				}
			}
			int num3 = Random.Range(Plugin.ExtractionCount_RandomMin.Value, Mathf.Max(Plugin.ExtractionCount_RandomMin.Value, Plugin.ExtractionCount_RandomMax.Value) + 1);
			return Mathf.Clamp(Mathf.RoundToInt((float)(num + num2 + num3)), 1, 12) - 1;
		}

		public static float DetermineBaseQuotaDifficulty(int level)
		{
			if (level == 1)
			{
				return Plugin.HaulGoalBase_Level1.Value;
			}
			if (level <= 5)
			{
				return Mathf.Lerp(Plugin.HaulGoalBase_Level1.Value, Plugin.HaulGoalBase_Level5.Value, Mathf.InverseLerp(1f, 5f, (float)level));
			}
			if (level <= 10)
			{
				return Mathf.Lerp(Plugin.HaulGoalBase_Level5.Value, Plugin.HaulGoalBase_Level10.Value, Mathf.InverseLerp(5f, 10f, (float)level));
			}
			if (level <= 20)
			{
				return Mathf.Lerp(Plugin.HaulGoalBase_Level10.Value, Plugin.HaulGoalBase_Level20.Value, Mathf.InverseLerp(10f, 20f, (float)level));
			}
			if (level <= 50)
			{
				return Mathf.Lerp(Plugin.HaulGoalBase_Level20.Value, Plugin.HaulGoalBase_Level50.Value, Mathf.InverseLerp(20f, 50f, (float)level));
			}
			if (level <= 100)
			{
				return Mathf.Lerp(Plugin.HaulGoalBase_Level50.Value, Plugin.HaulGoalBase_Level100.Value, Mathf.InverseLerp(50f, 100f, (float)level));
			}
			return Plugin.HaulGoalBase_Level100.Value;
		}

		public static int DetermineQuota(int extractionsCompleted, int totalExtractions, float totalMapValue, float difficulty)
		{
			int num = totalExtractions - extractionsCompleted - 1;
			float num2 = 1f - Mathf.Clamp(Plugin.HaulGoal_ExtractionModifier.Value * (float)num, 0f, 0.9f);
			int num3 = Mathf.RoundToInt((float)Mathf.RoundToInt(totalMapValue * difficulty / (float)totalExtractions) * num2);
			switch (Plugin.HaulGoal_RoundingOptions.Value)
			{
			case Plugin.HaulGoalRoundingOptions.RoundToTen:
				num3 = Mathf.RoundToInt((float)num3 / 10f) * 10;
				break;
			case Plugin.HaulGoalRoundingOptions.RoundToHundred:
				num3 = Mathf.RoundToInt((float)num3 / 100f) * 100;
				break;
			case Plugin.HaulGoalRoundingOptions.RoundToThousand:
				num3 = Mathf.RoundToInt((float)num3 / 1000f) * 1000;
				break;
			}
			return Mathf.Clamp(num3, 1000, (int)totalMapValue);
		}

		public static float DetermineMapValue(int level, int playerCount)
		{
			int num = ((level == 1) ? Plugin.TotalMapValueBase_Level1.Value : ((level <= 5) ? ((int)Mathf.Lerp((float)Plugin.TotalMapValueBase_Level1.Value, (float)Plugin.TotalMapValueBase_Level5.Value, Mathf.InverseLerp(1f, 5f, (float)level))) : ((level <= 10) ? ((int)Mathf.Lerp((float)Plugin.TotalMapValueBase_Level5.Value, (float)Plugin.TotalMapValueBase_Level10.Value, Mathf.InverseLerp(5f, 10f, (float)level))) : ((level <= 20) ? ((int)Mathf.Lerp((float)Plugin.TotalMapValueBase_Level10.Value, (float)Plugin.TotalMapValueBase_Level20.Value, Mathf.InverseLerp(10f, 20f, (float)level))) : ((level <= 50) ? ((int)Mathf.Lerp((float)Plugin.TotalMapValueBase_Level20.Value, (float)Plugin.TotalMapValueBase_Level50.Value, Mathf.InverseLerp(20f, 50f, (float)level))) : ((level > 100) ? Plugin.TotalMapValueBase_Level100.Value : ((int)Mathf.Lerp((float)Plugin.TotalMapValueBase_Level50.Value, (float)Plugin.TotalMapValueBase_Level100.Value, Mathf.InverseLerp(50f, 100f, (float)level)))))))));
			float num2 = 1f;
			if (playerCount > 1)
			{
				for (int i = 1; i < Mathf.Min(playerCount, Plugin.TotalMapValue_PerPlayerMax.Value); i++)
				{
					num2 += Plugin.TotalMapValue_PerPlayer.Value;
				}
			}
			float num3 = Random.Range(Plugin.TotalMapValue_RandomMin.Value, Mathf.Max(Plugin.TotalMapValue_RandomMin.Value, Plugin.TotalMapValue_RandomMax.Value));
			int num4 = (int)((float)num * num3);
			return Mathf.Clamp(Mathf.RoundToInt((float)num + num2 + (float)num4), 10, 1337);
		}

		public static void SharedDurability_DamageAllPlayers(float valueLost, List<PlayerAvatar> targets)
		{
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			int num = Mathf.RoundToInt(Mathf.Min(valueLost, 500f) / 20f);
			if (valueLost > 500f)
			{
				num += Mathf.RoundToInt(Mathf.Min(valueLost - 500f, 500f) / 40f);
			}
			if (valueLost > 1500f)
			{
				num += Mathf.RoundToInt(Mathf.Min(valueLost - 1500f, 4900f) / 100f);
			}
			if (GameDirector.instance.PlayerList.Count == 2)
			{
				num = Mathf.CeilToInt((float)num * 0.8f);
			}
			if (GameDirector.instance.PlayerList.Count == 1)
			{
				num = Mathf.CeilToInt((float)num * 0.6f);
			}
			targets.RemoveAll((PlayerAvatar m) => Traverse.Create((object)m).Field("isDisabled").GetValue<bool>());
			int num2 = Mathf.Clamp(Mathf.CeilToInt((float)num / (float)targets.Count), 1, 100);
			foreach (PlayerAvatar target in targets)
			{
				target.playerHealth.HurtOther(num2, Vector3.zero, true, -1);
			}
		}

		public static void SharedDurability_HealAllPlayers(float value, bool forceHealEffect)
		{
			if (!SemiFunc.IsMasterClientOrSingleplayer() || !ChallengeManager.IsChallengeActive(ChallengeManager.ChallengeType.SharedDurability))
			{
				return;
			}
			int num = (int)(value / 1000f);
			SharedDurability_overheal += value % 1000f;
			while (SharedDurability_overheal >= 1000f)
			{
				num++;
				SharedDurability_overheal -= 1000f;
			}
			if (num == 0)
			{
				return;
			}
			bool flag = forceHealEffect || Time.realtimeSinceStartup - SharedDurability_lastHealTime >= 0.5f;
			foreach (PlayerAvatar player in GameDirector.instance.PlayerList)
			{
				if (!Traverse.Create((object)player).Field("isDisabled").GetValue<bool>())
				{
					player.playerHealth.HealOther(num, flag);
				}
			}
			if (flag)
			{
				SharedDurability_lastHealTime = Time.realtimeSinceStartup;
			}
		}
	}
}
namespace LevelScaling.Patches
{
	[HarmonyPatch(typeof(ClownTrap))]
	internal class ClownTrapPatch
	{
		[HarmonyPatch("TrapStop")]
		[HarmonyPostfix]
		private static void TrapStopP(ref ClownTrap __instance)
		{
			if (SemiFunc.IsMasterClientOrSingleplayer() && SemiFunc.RunIsLevel())
			{
				ValuableObject component = ((Component)__instance).GetComponent<ValuableObject>();
				if (Object.op_Implicit((Object)(object)component))
				{
					LevelStatsManager.AddValueBroken(Traverse.Create((object)component).Field("dollarValueCurrent").GetValue<float>());
				}
			}
		}
	}
	[HarmonyPatch(typeof(EnemyDirector))]
	internal class EnemyDirectorPatch
	{
		[HarmonyPatch("AmountSetup")]
		[HarmonyPrefix]
		private static bool AmountSetupPrefix(ref EnemyDirector __instance, ref int ___amountCurve1Value, ref int ___amountCurve2Value, ref int ___amountCurve3Value, ref int ___totalAmount, ref List<EnemySetup> ___enemiesDifficulty1, ref List<EnemySetup> ___enemiesDifficulty2, ref List<EnemySetup> ___enemiesDifficulty3, ref List<EnemySetup> ___enemyListCurrent, ref float ___despawnedTimeMultiplier)
		{
			if (!ChallengeManager.IsChallengeActive(ChallengeManager.ChallengeType.EnemyRush))
			{
				return true;
			}
			float num = SemiFunc.RunGetDifficultyMultiplier1();
			float num2 = SemiFunc.RunGetDifficultyMultiplier2();
			float num3 = SemiFunc.RunGetDifficultyMultiplier3();
			if (num2 > 0f)
			{
				___amountCurve3Value = Mathf.CeilToInt(__instance.amountCurve3_2.Evaluate(num) * 1.1f) + 1;
				___amountCurve2Value = Mathf.CeilToInt(__instance.amountCurve2_2.Evaluate(num) * 1.3f) + 1;
				___amountCurve1Value = Mathf.CeilToInt(__instance.amountCurve1_2.Evaluate(num) * 1.6f) + 1;
			}
			else
			{
				___amountCurve3Value = Mathf.CeilToInt(__instance.amountCurve3_1.Evaluate(num) * 1.2f) + 1;
				___amountCurve2Value = Mathf.CeilToInt(__instance.amountCurve2_1.Evaluate(num) * 1.4f) + 1;
				___amountCurve1Value = Mathf.CeilToInt(__instance.amountCurve1_1.Evaluate(num) * 1.8f) + 1;
			}
			Traverse val = Traverse.Create((object)EnemyDirector.instance);
			___enemyListCurrent.Clear();
			for (int i = 0; i < ___amountCurve1Value; i++)
			{
				val.Method("PickEnemies", new object[1] { ___enemiesDifficulty1 }).GetValue();
			}
			for (int j = 0; j < ___amountCurve2Value; j++)
			{
				val.Method("PickEnemies", new object[1] { ___enemiesDifficulty2 }).GetValue();
			}
			for (int k = 0; k < ___amountCurve3Value; k++)
			{
				val.Method("PickEnemies", new object[1] { ___enemiesDifficulty3 }).GetValue();
			}
			___despawnedTimeMultiplier = 1f;
			if (num3 > 0f)
			{
				___despawnedTimeMultiplier = __instance.despawnTimeCurve_2.Evaluate(num3);
			}
			else if (num2 > 0f)
			{
				___despawnedTimeMultiplier = __instance.despawnTimeCurve_1.Evaluate(num2);
			}
			___totalAmount = ___amountCurve1Value + ___amountCurve2Value + ___amountCurve3Value;
			return false;
		}
	}
	[HarmonyPatch(typeof(EnemyHealth))]
	internal class EnemyHealthPatch
	{
		private static float playerRewardLastHealTime;

		[HarmonyPatch("Awake")]
		[HarmonyPostfix]
		private static void AwakeP(ref int ___healthCurrent)
		{
			if (ChallengeManager.IsChallengeActive(ChallengeManager.ChallengeType.EnemyRush))
			{
				___healthCurrent /= 2;
			}
		}

		[HarmonyPatch("OnSpawn")]
		[HarmonyPostfix]
		private static void OnSpawnP(ref int ___healthCurrent)
		{
			if (ChallengeManager.IsChallengeActive(ChallengeManager.ChallengeType.EnemyRush))
			{
				___healthCurrent /= 2;
			}
		}

		[HarmonyPatch("Hurt")]
		[HarmonyPrefix]
		private static void HurtP(ref int _damage, ref int ___healthCurrent)
		{
			if (ChallengeManager.IsChallengeActive(ChallengeManager.ChallengeType.DangerZone) && SemiFunc.IsMasterClientOrSingleplayer() && !Helpers.TruckLeaving)
			{
				bool flag = _damage >= ___healthCurrent;
				int num = Mathf.Clamp(Mathf.RoundToInt((float)(Mathf.Min(_damage, ___healthCurrent) / Mathf.Max(2, GameDirector.instance.PlayerList.Count))), 1, 500);
				bool flag2 = num >= 10 || Time.realtimeSinceStartup - playerRewardLastHealTime >= 0.5f;
				foreach (PlayerAvatar player in GameDirector.instance.PlayerList)
				{
					if (Traverse.Create((object)player).Field("isDisabled").GetValue<bool>())
					{
						if (flag)
						{
							player.Revive(false);
						}
					}
					else
					{
						player.playerHealth.HealOther(num, flag2);
					}
				}
				if (flag2)
				{
					playerRewardLastHealTime = Time.realtimeSinceStartup;
				}
			}
			if (ChallengeManager.IsChallengeActive(ChallengeManager.ChallengeType.IncreasedDamage))
			{
				_damage = Mathf.CeilToInt((float)_damage * 1.33f);
			}
		}
	}
	[HarmonyPatch(typeof(EnemyParent))]
	internal class EnemyParentPatch
	{
		[HarmonyPatch("Spawn")]
		[HarmonyPostfix]
		private static void SpawnP(ref Enemy ___Enemy)
		{
			if (SemiFunc.IsMasterClientOrSingleplayer() && !LevelStatsManager.individualOrbDropCounts.ContainsKey(___Enemy))
			{
				EnemyHealth value = Traverse.Create((object)___Enemy).Field("Health").GetValue<EnemyHealth>();
				if (Object.op_Implicit((Object)(object)value) && value.spawnValuable)
				{
					LevelStatsManager.maxIndividualOrbDrops++;
					LevelStatsManager.individualOrbDropCounts.Add(___Enemy, 0);
				}
			}
		}

		[HarmonyPatch("Despawn")]
		[HarmonyPrefix]
		private static void DespawnP(ref Enemy ___Enemy)
		{
			if (!SemiFunc.IsMasterClientOrSingleplayer())
			{
				return;
			}
			EnemyHealth value = Traverse.Create((object)___Enemy).Field("Health").GetValue<EnemyHealth>();
			if (!Object.op_Implicit((Object)(object)value) || Traverse.Create((object)value).Field("healthCurrent").GetValue<int>() > 0)
			{
				return;
			}
			if (SemiFunc.IsMasterClientOrSingleplayer())
			{
				RunStatsManager.instance.enemyKills++;
			}
			if (!value.spawnValuable || Traverse.Create((object)value).Field("spawnValuableCurrent").GetValue<int>() >= value.spawnValuableMax)
			{
				return;
			}
			if (LevelStatsManager.individualOrbDropCounts.ContainsKey(___Enemy))
			{
				LevelStatsManager.individualOrbDropCounts[___Enemy]++;
				if (LevelStatsManager.individualOrbDropCounts[___Enemy] == 1)
				{
					LevelStatsManager.AddIndivOrb();
				}
			}
			foreach (KeyValuePair<Enemy, int> individualOrbDropCount in LevelStatsManager.individualOrbDropCounts)
			{
				if (individualOrbDropCount.Value == 0)
				{
					return;
				}
			}
			LevelStatsManager.SetAllOrbsFound(value: true);
		}
	}
	[HarmonyPatch(typeof(EnemyRigidbody))]
	internal class EnemyRigidbodyPatch
	{
		[HarmonyPatch("Awake")]
		[HarmonyPostfix]
		private static void AwakeP(ref EnemyRigidbody __instance)
		{
			if (ChallengeManager.IsChallengeActive(ChallengeManager.ChallengeType.EnemyRush))
			{
				GrabForce grabForceNeeded = __instance.grabForceNeeded;
				grabForceNeeded.amount *= 0.75f;
			}
		}
	}
	[HarmonyPatch(typeof(EnemyValuable))]
	internal class EnemyValuablePatch
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void StartP()
		{
			if (SemiFunc.IsMasterClientOrSingleplayer())
			{
				LevelStatsManager.AddEnemyKill();
			}
		}
	}
	[HarmonyPatch(typeof(EnergyUI))]
	internal class EnergyUIPatch
	{
		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void UpdateP(ref TextMeshProUGUI ___Text)
		{
			if (ChallengeManager.IsChallengeActive(ChallengeManager.ChallengeType.HiddenInformation) && Object.op_Implicit((Object)(object)___Text))
			{
				((TMP_Text)___Text).text = "??";
			}
		}
	}
	[HarmonyPatch(typeof(EnvironmentDirector))]
	internal class EnvironmentDirectorPatch
	{
		[HarmonyPatch("Setup")]
		[HarmonyPostfix]
		private static void SetupP(ref Camera ___MainCamera)
		{
			if (ChallengeManager.IsChallengeActive(ChallengeManager.ChallengeType.LightsOut))
			{
				RenderSettings.fogStartDistance *= 0.75f;
				RenderSettings.fogEndDistance *= 0.75f;
				___MainCamera.farClipPlane = RenderSettings.fogEndDistance + 1f;
			}
			if (ChallengeManager.IsChallengeActive(ChallengeManager.ChallengeType.FoggyLevel))
			{
				RenderSettings.fogStartDistance *= 0.38f;
				RenderSettings.fogEndDistance *= 0.38f;
				___MainCamera.farClipPlane = RenderSettings.fogEndDistance + 1f;
			}
		}
	}
	[HarmonyPatch(typeof(GameDirector))]
	internal class GameDirectorPatch
	{
		private static VideoClip cache;

		private static VideoClip Clip
		{
			get
			{
				if ((Object)(object)cache == (Object)null)
				{
					VideoClip[] array = Resources.FindObjectsOfTypeAll<VideoClip>();
					foreach (VideoClip val in array)
					{
						if (((Object)val).name == "Video Overlay")
						{
							cache = val;
							break;
						}
					}
				}
				return cache;
			}
		}

		[HarmonyPatch("gameStateStart")]
		[HarmonyPostfix]
		private static void gameStateStartP(ref float ___gameStateTimer)
		{
			if (!(___gameStateTimer > 0f) && ChallengeManager.currentChallenges.Count != 0)
			{
				ChallengeManager.Challenge challenge = ChallengeManager.GetChallenge(ChallengeManager.currentChallenges[0]);
				string name = challenge.name;
				string info = challenge.info;
				Traverse.Create((object)TutorialDirector.instance).Field("delayBeforeTip").SetValue((object)1.5f);
				Traverse.Create((object)TutorialDirector.instance).Field("showTipTimer").SetValue((object)10f);
				Traverse.Create((object)TutorialDirector.instance).Field("showTipTime").SetValue((object)10f);
				TutorialUI.instance.SetTipPage(Clip, "<size=70%><line-height=110%><b>" + name + ":</b> " + info + "<br></line-height></size>");
				((MonoBehaviour)GameDirector.instance).StartCoroutine(HideStatsCoroutine());
			}
		}

		private static IEnumerator HideStatsCoroutine()
		{
			yield return (object)new WaitForSeconds(1.5f);
			LevelStatsUI.instance.hideTimer = 10f;
		}
	}
	[HarmonyPatch(typeof(HaulUI))]
	internal class HaulUIPatch
	{
		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void UpdateP(ref TextMeshProUGUI ___Text, ref int ___currentHaulValue)
		{
			if (ChallengeManager.IsChallengeActive(ChallengeManager.ChallengeType.HiddenInformation) && SemiFunc.RunIsLevel())
			{
				string text = "<color=#558B2F>$</color>";
				string oldValue = text + SemiFunc.DollarGetString(Mathf.Max(0, ___currentHaulValue));
				((TMP_Text)___Text).text = ((TMP_Text)___Text).text.Replace(oldValue, text + "?????");
			}
		}
	}
	[HarmonyPatch(typeof(HealthUI))]
	internal class HealthUIPatch
	{
		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void UpdateP(ref TextMeshProUGUI ___Text)
		{
			if (ChallengeManager.IsChallengeActive(ChallengeManager.ChallengeType.HiddenInformation) && Object.op_Implicit((Object)(object)___Text))
			{
				((TMP_Text)___Text).text = "???";
			}
		}
	}
	[HarmonyPatch(typeof(LightManager))]
	internal class LightManagerPatch
	{
		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void SetupP(ref LightManager __instance, ref bool ___turnOffLights, ref bool ___turningOffLights, ref bool ___turningOffEmissions)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Invalid comparison between Unknown and I4
			if (ChallengeManager.IsChallengeActive(ChallengeManager.ChallengeType.LightsOut) && (int)GameDirector.instance.currentState == 2 && Object.op_Implicit((Object)(object)PlayerAvatar.instance) && !___turnOffLights)
			{
				((MonoBehaviour)__instance).StopAllCoroutines();
				___turningOffLights = true;
				((MonoBehaviour)__instance).StartCoroutine("TurnOffLights");
				___turningOffEmissions = true;
				((MonoBehaviour)__instance).StartCoroutine("TurnOffEmissions");
				___turnOffLights = true;
			}
		}
	}
	[HarmonyPatch(typeof(LoadingUI))]
	internal class LoadingUIPatch
	{
		[HarmonyPatch("LevelAnimationStart")]
		[HarmonyPostfix]
		private static void LevelAnimationStartP(ref LoadingUI __instance)
		{
			if (ChallengeManager.currentChallenges.Count == 0)
			{
				return;
			}
			string text = "";
			for (int i = 0; i < ChallengeManager.currentChallenges.Count; i++)
			{
				text += ChallengeManager.GetChallenge(ChallengeManager.currentChallenges[i]).name;
				if (i != ChallengeManager.currentChallenges.Count - 1)
				{
					text += " + ";
				}
			}
			text = text.ToUpper();
			((TMP_Text)__instance.levelNumberText).text = "<color=red>CHALLENGE LEVEL: " + text + "</color>";
			((TMP_Text)__instance.levelNameText).text = "<color=#f99>" + ((TMP_Text)__instance.levelNameText).text + "</color>";
		}
	}
	[HarmonyPatch(typeof(MapModule))]
	internal class MapModulePatch
	{
		[HarmonyPatch("Hide")]
		[HarmonyPrefix]
		private static void HideP(ref bool ___animating)
		{
			if (!___animating)
			{
				LevelStatsManager.AddModuleExplored();
			}
		}
	}
	[HarmonyPatch(typeof(Map))]
	internal class MapPatch
	{
		[HarmonyPatch("AddRoomVolume")]
		[HarmonyPostfix]
		private static void AddRoomVolumeP(ref Map __instance)
		{
			if (SemiFunc.IsMasterClientOrSingleplayer() && SemiFunc.RunIsLevel())
			{
				LevelStatsManager.totalModules = __instance.MapModules.Count;
			}
		}
	}
	[HarmonyPatch(typeof(MapToolController))]
	internal class MapToolControllerPatch
	{
		public static bool mapToolActive;

		[HarmonyPatch(typeof(MapToolController), "Update")]
		[HarmonyPostfix]
		private static void UpdateP2(ref bool ___Active, ref PhotonView ___photonView)
		{
			if (!GameManager.Multiplayer() || ___photonView.IsMine)
			{
				mapToolActive = ___Active;
			}
		}

		[HarmonyPatch("Update")]
		[HarmonyPrefix]
		private static bool UpdateP()
		{
			return !ChallengeManager.IsChallengeActive(ChallengeManager.ChallengeType.NoMap);
		}
	}
	[HarmonyPatch(typeof(MenuPageSaves))]
	internal class MenuPageSavesPatch
	{
		private static TextMeshProUGUI noSaveText;

		private static TextMeshProUGUI tableTextLeftSide;

		private static TextMeshProUGUI tableTextRightSide;

		private static TextMeshProUGUI tableTextLeftSideValues;

		private static TextMeshProUGUI tableTextRightSideValues;

		[HarmonyPatch("SaveFileSelected")]
		[HarmonyPostfix]
		private static void SaveFileSelectedP(ref MenuPageSaves __instance, ref string saveFileName)
		{
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Expected O, but got Unknown
			string text = Application.persistentDataPath + "/saves/" + saveFileName + "/LevelScaling.es3";
			if (!File.Exists(text))
			{
				((Component)noSaveText).gameObject.SetActive(true);
				((Component)tableTextLeftSide).gameObject.SetActive(false);
				((Component)tableTextRightSide).gameObject.SetActive(false);
				((Component)tableTextLeftSideValues).gameObject.SetActive(false);
				((Component)tableTextRightSideValues).gameObject.SetActive(false);
				((TMP_Text)noSaveText).text = "No LevelScaling data found :(";
				return;
			}
			try
			{
				((Component)noSaveText).gameObject.SetActive(false);
				((Component)tableTextLeftSide).gameObject.SetActive(true);
				((Component)tableTextRightSide).gameObject.SetActive(true);
				((Component)tableTextLeftSideValues).gameObject.SetActive(true);
				((Component)tableTextRightSideValues).gameObject.SetActive(true);
				ES3Settings val = new ES3Settings(text, (EncryptionType)1, SwaggiFunc.es3Password, (ES3Settings)null);
				RunStatsManager runStatsManager = ES3.Load<RunStatsManager>("runStats", text, new RunStatsManager(), val);
				((TMP_Text)tableTextLeftSideValues).text = $"x {Mathf.Clamp(runStatsManager.extractionPointsCompleted, 0, 9999)}\n" + $"x {Mathf.Clamp(runStatsManager.valuablesFound, 0, 9999)}\n" + $"x {Mathf.Clamp(runStatsManager.enemyKills, 0, 9999)}\n" + $"x {Mathf.Clamp(runStatsManager.playerDeaths, 0, 9999)}";
				((TMP_Text)tableTextRightSideValues).text = $"{Mathf.Clamp(runStatsManager.largestSurplusValue, 0, 999999)}\n" + $"-{Mathf.Clamp((int)(runStatsManager.totalValueBroken / 1000f), 0, 9999)}K\n" + $"x {Mathf.Clamp(runStatsManager.modulesExplored, 0, 9999)}