Decompiled source of WesleysMoonsHQModule v1.2.0

Tomatobird.WesleysMoonsHQModule.dll

Decompiled a month ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using JLL.Components;
using JLL.Components.Filters;
using LethalLevelLoader;
using LethalLevelLoader.Tools;
using Microsoft.CodeAnalysis;
using MrovLib;
using TMPro;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
using WeatherRegistry;
using WesleyMoonScripts;
using WesleyMoonScripts.Components;
using WesleysMoonsHQModule.Patches;
using WesleysWeatherStuff.Stuff;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: IgnoresAccessChecksTo("LethalLevelLoader")]
[assembly: IgnoresAccessChecksTo("MrovLib")]
[assembly: IgnoresAccessChecksTo("WeatherRegistry")]
[assembly: IgnoresAccessChecksTo("WesleysWeatherStuff")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Tomatobird.WesleysMoonsHQModule")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.2.0.0")]
[assembly: AssemblyInformationalVersion("1.2.0+931d4a439b26a24c22ff2cf9fbd531ea9f02ad7b")]
[assembly: AssemblyProduct("WesleysMoonsHQModule")]
[assembly: AssemblyTitle("Tomatobird.WesleysMoonsHQModule")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.2.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace WesleysMoonsHQModule
{
	internal static class OtherPluginInfos
	{
		public const string HQFIXES_GUID = "chboo1.lethalcompany.hqfixes";

		public const string WEATHERREGISTRY_GUID = "mrov.WeatherRegistry";

		public const string LLL_GUID = "imabatby.lethallevelloader";

		public const string JLL_GUID = "JacobG5.JLL";

		public const string JLL_WMS_GUID = "JacobG5.WesleyMoonScripts";

		public const string MROVLIB_GUID = "MrovLib";

		public const string FREEMOONS_GUID = "SlushyRH.LethalCompany.FreeMoons";

		public const string CULLFACTORY_GUID = "com.fumiko.CullFactory";

		public const string LETHALLIB_GUID = "evaisa.lethallib";

		public const string PATHFINDINGLIB_GUID = "Zaggy1024.PathfindingLib";

		public const string PATHFINDINGLAGFIX_GUID = "Zaggy1024.PathfindingLagFix";

		public const string STARLANCERAIFIX_GUID = "AudioKnight.StarlancerAIFix";

		public const string STREAMOVERLAYS_GUID = "com.github.zehsteam.StreamOverlays";

		public const string LOADSTONE_GUID = "com.adibtw.loadstone";

		public const string VLOG_GUID = "OreoM.VLog";
	}
	internal class PackDefinition
	{
		internal static Dictionary<string, string> commonRequiredMods = new Dictionary<string, string> { { "com.adibtw.loadstone", "0.1.23" } };

		internal static Dictionary<string, string> commonOptionalMods = new Dictionary<string, string>
		{
			{ "SlushyRH.LethalCompany.FreeMoons", "1.0.2" },
			{ "com.fumiko.CullFactory", "2.0.4" }
		};

		internal static Dictionary<string, string> v69Mods = new Dictionary<string, string>
		{
			{ "imabatby.lethallevelloader", "1.4.11" },
			{ "Zaggy1024.PathfindingLagFix", "2.2.4" },
			{ "Zaggy1024.PathfindingLib", "2.3.2" },
			{ "AudioKnight.StarlancerAIFix", "3.9.0" },
			{ "evaisa.lethallib", "1.0.1" }
		};

		internal static Dictionary<string, string> v72Mods = new Dictionary<string, string>
		{
			{ "imabatby.lethallevelloader", "1.4.11" },
			{ "Zaggy1024.PathfindingLagFix", "2.2.4" },
			{ "Zaggy1024.PathfindingLib", "2.3.2" },
			{ "AudioKnight.StarlancerAIFix", "3.11.1" },
			{ "evaisa.lethallib", "1.1.1" }
		};

		internal static Dictionary<string, string> v73Mods = new Dictionary<string, string>
		{
			{ "imabatby.lethallevelloader", "1.6.8" },
			{ "mrov.WeatherRegistry", "0.7.5" },
			{ "MrovLib", "0.4.2" },
			{ "Zaggy1024.PathfindingLagFix", "2.2.5" },
			{ "Zaggy1024.PathfindingLib", "2.4.1" },
			{ "AudioKnight.StarlancerAIFix", "3.11.1" },
			{ "evaisa.lethallib", "1.1.1" }
		};
	}
	[BepInPlugin("Tomatobird.WesleysMoonsHQModule", "WesleysMoonsHQModule", "1.2.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class WesleysMoonsHQModule : BaseUnityPlugin
	{
		internal static List<string> allowedItemNames = new List<string>(2) { "Bury the child videotape", "Teach the disloyal videotape" };

		internal static List<string> scenesToSkip = new List<string>(3) { "MainMenu", "InitScene", "InitSceneLaunchOptions" };

		internal static Dictionary<string, PluginInfo> pluginInfos = new Dictionary<string, PluginInfo>();

		public static WesleysMoonsHQModule Instance { get; private set; } = null;

		internal static ManualLogSource Logger { get; private set; } = null;

		internal static Harmony? Harmony { get; set; }

		private void Awake()
		{
			Logger = ((BaseUnityPlugin)this).Logger;
			Instance = this;
			pluginInfos = Chainloader.PluginInfos;
			Patch();
			SceneManager.sceneLoaded += OnSceneLoad;
			Logger.LogInfo((object)("Pack launched in " + (WesleyScripts.LockMoons.Value ? "High Quota" : "Single Moon High Quota") + " mode!"));
			Logger.LogInfo((object)"Tomatobird.WesleysMoonsHQModule v1.2.0 has loaded!");
		}

		internal static void Patch()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			if (Harmony == null)
			{
				Harmony = new Harmony("Tomatobird.WesleysMoonsHQModule");
			}
			Logger.LogDebug((object)"Patching...");
			Harmony.PatchAll(typeof(StartOfRoundPatcher));
			Harmony.PatchAll(typeof(MenuManagerPatcher));
			if (Chainloader.PluginInfos.TryGetValue("imabatby.lethallevelloader", out var value))
			{
				if (value.Metadata.Version <= new Version(PackDefinition.v73Mods["imabatby.lethallevelloader"]))
				{
					Harmony.PatchAll(typeof(SoundManagerPatcher));
				}
				if (value.Metadata.Version >= new Version(PackDefinition.v73Mods["imabatby.lethallevelloader"]))
				{
					Harmony.PatchAll(typeof(LLLConfigLoaderPatcher_v2));
					Harmony.PatchAll(typeof(WesleysWeatherStuffPatcher));
					Harmony.PatchAll(typeof(ExpandedMineshaftExtraItemsPatcher));
				}
				else
				{
					Harmony.PatchAll(typeof(LLLConfigLoaderPatcher_v1));
				}
			}
			if (Chainloader.PluginInfos.TryGetValue("mrov.WeatherRegistry", out var _))
			{
				Harmony.PatchAll(typeof(WeatherRegistryConfigPatcher));
			}
			Logger.LogDebug((object)"Finished patching!");
		}

		internal static void OnSceneLoad(Scene scene, LoadSceneMode mode)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			if (!scenesToSkip.Contains(((Scene)(ref scene)).name))
			{
				RemoveAprilFools(scene);
				if (((Scene)(ref scene)).name == "MusemaScene")
				{
					EditMusemaScene(scene);
				}
				if (((Scene)(ref scene)).name == "Asteroid14Scene" && WesleyScripts.LockMoons.Value)
				{
					EditHyveScene(scene);
				}
				if (((Scene)(ref scene)).name == "CalistScene")
				{
					EditCalistScene(scene);
				}
			}
		}

		internal static GameObject GetRootGameObject(Scene scene, string name)
		{
			return ((IEnumerable<GameObject>)((Scene)(ref scene)).GetRootGameObjects()).FirstOrDefault((Func<GameObject, bool>)((GameObject g) => ((Object)g).name == name));
		}

		internal static void EditMusemaScene(Scene scene)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			Logger.LogInfo((object)"Editing Galetry Scene.");
			GameObject rootGameObject = GetRootGameObject(scene, "Environment");
			ItemShop[] componentsInChildren = ((Component)rootGameObject.transform.Find("Giftshop/Itemshop")).GetComponentsInChildren<ItemShop>();
			foreach (ItemShop val in componentsInChildren)
			{
				if (!((Object)(object)val == (Object)null) && val.Catalogue[0].ItemName == "Mortar hammer")
				{
					val.Catalogue = val.Catalogue.Where((WeightedItemRefrence item) => allowedItemNames.Contains(item.ItemName)).ToArray();
					break;
				}
			}
		}

		internal static void EditHyveScene(Scene scene)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Expected O, but got Unknown
			Logger.LogInfo((object)"Editing Galetry Scene.");
			GameObject rootGameObject = GetRootGameObject(scene, "Environment");
			WeightedEnemyRefrence item = new WeightedEnemyRefrence
			{
				rarity = 99
			};
			EnemySpawner[] componentsInChildren = rootGameObject.GetComponentsInChildren<EnemySpawner>();
			foreach (EnemySpawner val in componentsInChildren)
			{
				if (!(((Object)val).name != "Spawner"))
				{
					val.randomPool = new List<WeightedEnemyRefrence>(1) { item };
				}
			}
		}

		internal static void EditCalistScene(Scene scene)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			Logger.LogInfo((object)"Editing Calist Scene.");
			Transform transform = GetRootGameObject(scene, "Environment").transform;
			Transform val = transform.Find("Lighting/BrightDay/Sun");
			Transform[] array = (Transform[])(object)new Transform[3]
			{
				((Component)val).transform.Find("SunAnimContainer/GameObject"),
				((Component)val).transform.Find("SunAnimContainer/AsteroidsPAck"),
				((Component)val).transform.Find("SunAnimContainer/Sphere")
			};
			Transform[] array2 = array;
			foreach (Transform val2 in array2)
			{
				val2.SetParent(((Component)val).transform);
			}
		}

		internal static void RemoveAprilFools(Scene scene)
		{
			DateFilter[] array = Object.FindObjectsOfType<DateFilter>();
			DateFilter[] array2 = array;
			foreach (DateFilter val in array2)
			{
				if (((Object)((Component)val).gameObject).name != "randomAprilEffect")
				{
					break;
				}
				Logger.LogInfo((object)"Removing randomAprilEffect...");
				Object.Destroy((Object)(object)((Component)val).gameObject);
			}
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "Tomatobird.WesleysMoonsHQModule";

		public const string PLUGIN_NAME = "WesleysMoonsHQModule";

		public const string PLUGIN_VERSION = "1.2.0";
	}
}
namespace WesleysMoonsHQModule.Patches
{
	[HarmonyPatch(typeof(RoundManager))]
	internal class ExpandedMineshaftExtraItemsPatcher
	{
		public static int GetLevel3ButCoolID()
		{
			if ((Object)(object)RoundManager.Instance == (Object)null)
			{
				return -1;
			}
			for (int i = 0; i < RoundManager.Instance.dungeonFlowTypes.Length; i++)
			{
				if (((Object)RoundManager.Instance.dungeonFlowTypes[i].dungeonFlow).name == "Level3ButCoolFlow")
				{
					return i;
				}
			}
			return -1;
		}

		public static bool IsMineshaftType(int dungeonType)
		{
			return dungeonType == 4 || dungeonType == GetLevel3ButCoolID();
		}

		[HarmonyPatch("SpawnScrapInLevel")]
		[HarmonyTranspiler]
		public static IEnumerable<CodeInstruction> SpawnScrapInLevel_Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Expected O, but got Unknown
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Expected O, but got Unknown
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Expected O, but got Unknown
			CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null);
			CodeMatch[] array = (CodeMatch[])(object)new CodeMatch[2]
			{
				new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(RoundManager), "currentDungeonType"), (string)null),
				new CodeMatch((OpCode?)OpCodes.Ldc_I4_4, (object)null, (string)null)
			};
			val.MatchForward(false, array).ThrowIfNotMatch("Failed to find targetPattern for patching ExpandedMineshaft bonus", Array.Empty<CodeMatch>()).Advance(1)
				.SetInstructionAndAdvance(new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(ExpandedMineshaftExtraItemsPatcher), "IsMineshaftType", (Type[])null, (Type[])null)))
				.SetOpcodeAndAdvance(OpCodes.Brfalse_S);
			return val.InstructionEnumeration();
		}
	}
	[HarmonyPatch]
	internal class LLLConfigLoaderPatcher_v1
	{
		private static readonly List<string> vanillaLevels = new List<string>(12)
		{
			"Adamance", "Offense", "Assurance", "Experimentation", "Liquidation", "Embrion", "Vow", "March", "Artifice", "Dine",
			"Titan", "Rend"
		};

		[HarmonyPatch("LethalLevelLoader.Tools.ExtendedDungeonConfig, LethalLevelLoader, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", "BindConfigs")]
		[HarmonyPrefix]
		public static void PatchDungeon(object[] __args)
		{
			object obj = __args[0];
			Type type = obj.GetType();
			PropertyInfo property = type.GetProperty("GenerateAutomaticConfigurationOptions", BindingFlags.Instance | BindingFlags.Public);
			property.SetValue(obj, false);
		}

		[HarmonyPatch("LethalLevelLoader.Tools.ExtendedLevelConfig, LethalLevelLoader, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", "BindConfigs")]
		[HarmonyPrefix]
		public static void PatchMoon(object[] __args)
		{
			object obj = __args[0];
			Type type = obj.GetType();
			PropertyInfo property = type.GetProperty("GenerateAutomaticConfigurationOptions", BindingFlags.Instance | BindingFlags.Public);
			property.SetValue(obj, false);
			PropertyInfo property2 = type.GetProperty("NumberlessPlanetName", BindingFlags.Instance | BindingFlags.Public);
			if (vanillaLevels.Contains((string)property2.GetValue(obj)))
			{
				PropertyInfo property3 = type.GetProperty("IsRouteLocked", BindingFlags.Instance | BindingFlags.Public);
				PropertyInfo property4 = type.GetProperty("IsRouteHidden", BindingFlags.Instance | BindingFlags.Public);
				property3.SetValue(obj, true);
				property4.SetValue(obj, true);
			}
		}
	}
	[HarmonyPatch]
	internal class LLLConfigLoaderPatcher_v2
	{
		private static readonly List<string> vanillaLevels = new List<string>(12)
		{
			"Adamance", "Offense", "Assurance", "Experimentation", "Liquidation", "Embrion", "Vow", "March", "Artifice", "Dine",
			"Titan", "Rend"
		};

		[HarmonyPatch(typeof(ExtendedDungeonConfig), "BindConfigs")]
		[HarmonyPrefix]
		public static void PatchDungeon(ref ExtendedDungeonFlow extendedDungeonFlow)
		{
			extendedDungeonFlow.GenerateAutomaticConfigurationOptions = false;
		}

		[HarmonyPatch(typeof(ExtendedLevelConfig), "BindConfigs")]
		[HarmonyPrefix]
		public static void PatchMoon(ref ExtendedLevel extendedLevel)
		{
			extendedLevel.GenerateAutomaticConfigurationOptions = false;
			if (vanillaLevels.Contains(extendedLevel.NumberlessPlanetName))
			{
				extendedLevel.IsRouteLocked = true;
				extendedLevel.IsRouteHidden = true;
			}
		}
	}
	[HarmonyPatch(typeof(MenuManager))]
	internal class MenuManagerPatcher
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		internal static void Start_Postfix(MenuManager __instance)
		{
			if (!__instance.isInitScene)
			{
				string text = "";
				int gameVersionNum = GameNetworkManager.Instance.gameVersionNum;
				WesleysMoonsHQModule.Logger.LogInfo((object)("Game version: " + gameVersionNum));
				text += CheckModValidity(PackDefinition.commonRequiredMods, required: true);
				text = gameVersionNum switch
				{
					69 => text + CheckModValidity(PackDefinition.v69Mods, required: true), 
					72 => text + CheckModValidity(PackDefinition.v72Mods, required: true), 
					73 => text + CheckModValidity(PackDefinition.v73Mods, required: true), 
					_ => text + "Unsupported game version", 
				} + CheckModValidity(PackDefinition.commonOptionalMods, required: false);
				if (WesleysMoonsHQModule.pluginInfos.ContainsKey("SlushyRH.LethalCompany.FreeMoons") && WesleyScripts.LockMoons.Value)
				{
					text += "Freemoons installed in non-SMHQ mode, ";
				}
				else if (!WesleysMoonsHQModule.pluginInfos.ContainsKey("SlushyRH.LethalCompany.FreeMoons") && !WesleyScripts.LockMoons.Value)
				{
					text += "Freemoons missing in SMHQ mode, ";
				}
				if (!WesleysMoonsHQModule.pluginInfos.ContainsKey("OreoM.VLog"))
				{
					text += "Vlog missing, ";
				}
				if (!Utility.IsNullOrWhiteSpace(text))
				{
					text = text.TrimEnd(',', ' ');
					WesleysMoonsHQModule.Logger.LogWarning((object)("WARNING! Modpack misconfiguration: " + text));
					__instance.DisplayMenuNotification("WARNING! Modpack misconfiguration: " + text, "[ OK ]");
				}
			}
		}

		internal static string CheckModValidity(Dictionary<string, string> dict, bool required)
		{
			string text = "";
			foreach (KeyValuePair<string, string> item in dict)
			{
				if (!WesleysMoonsHQModule.pluginInfos.ContainsKey(item.Key))
				{
					if (required)
					{
						text = text + item.Key + " v" + item.Value + " is misssing, ";
					}
				}
				else if (WesleysMoonsHQModule.pluginInfos[item.Key].Metadata.Version.ToString() != item.Value)
				{
					text = text + WesleysMoonsHQModule.pluginInfos[item.Key].Metadata.GUID + " v" + WesleysMoonsHQModule.pluginInfos[item.Key].Metadata.Version.ToString() + " didnt match required version v" + item.Value + ", ";
				}
			}
			return text;
		}
	}
	[HarmonyPatch(typeof(SoundManager))]
	internal class SoundManagerPatcher
	{
		[HarmonyPatch("ResetValues")]
		[HarmonyPostfix]
		internal static void ResetValues_Postfix(SoundManager __instance)
		{
			WesleysMoonsHQModule.Logger.LogInfo((object)"Attempting to fix chorus effect bug in SoundManager.ResetsValues.");
			((MonoBehaviour)__instance).StartCoroutine(FixChorusEffect(__instance));
		}

		private static IEnumerator FixChorusEffect(SoundManager soundManager)
		{
			yield return null;
			soundManager.SetDiageticMixerSnapshot(4, 1000f);
			yield return null;
			soundManager.SetDiageticMixerSnapshot(0, 1f);
		}
	}
	[HarmonyPatch(typeof(StartOfRound))]
	internal class StartOfRoundPatcher
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		internal static void Start_Postfix(StartOfRound __instance)
		{
			if (WesleyScripts.LockMoons.Value)
			{
				LungProp[] array = Resources.FindObjectsOfTypeAll<LungProp>();
				LungProp[] array2 = array;
				foreach (LungProp val in array2)
				{
					if (((Object)val).name == "CosmicLungApparatus" || ((Object)val).name == "CosmicLungApparatusDisabled")
					{
						((GrabbableObject)val).scrapValue = 214;
					}
				}
			}
			SelectableLevel[] levels = __instance.levels;
			foreach (SelectableLevel val2 in levels)
			{
				val2.DaySpeedMultiplier = Mathf.Max(val2.DaySpeedMultiplier, 1f);
				if (((Object)val2).name == "CosmocosLevel")
				{
					val2.DaySpeedMultiplier = 0.959f;
					if (WesleyScripts.LockMoons.Value)
					{
						val2.maxScrap = 55;
					}
				}
				if (((Object)val2).name == "EmpraLevel")
				{
					val2.DaySpeedMultiplier = 0.875f;
				}
			}
		}
	}
	[HarmonyPatch]
	public class WeatherRegistryConfigPatcher
	{
		private static TextMeshProUGUI? infoDisplay;

		private static bool VailidityCheckFailed;

		[HarmonyPatch(typeof(RoundManager), "Awake")]
		[HarmonyPostfix]
		public static void Awake_Postfix()
		{
			Settings.WeatherSelectionAlgorithm = WeatherCalculation.WeatherAlgorithms[(WeatherAlgorithm)2];
			ConfigManager.WeatherAlgorithm.Value = (WeatherAlgorithm)2;
			ConfigManager.FirstDayClear.Value = true;
			((ConfigEntryBase)ConfigManager.WeatherAlgorithm).ConfigFile.Save();
			((ConfigEntryBase)ConfigManager.FirstDayClear).ConfigFile.Save();
		}

		[HarmonyPatch(typeof(RoundManager), "Start")]
		[HarmonyPostfix]
		public static void Start_Postfix()
		{
			Weather[] array = Resources.FindObjectsOfTypeAll<Weather>();
			Weather[] array2 = array;
			foreach (Weather val in array2)
			{
				if (((ConfigHandler<float, float>)(object)val.Config.ScrapValueMultiplier).ConfigEntry.Value != (float)((ConfigEntryBase)((ConfigHandler<float, float>)(object)val.Config.ScrapValueMultiplier).ConfigEntry).DefaultValue || ((ConfigHandler<float, float>)(object)val.Config.ScrapAmountMultiplier).ConfigEntry.Value != (float)((ConfigEntryBase)((ConfigHandler<float, float>)(object)val.Config.ScrapAmountMultiplier).ConfigEntry).DefaultValue || ((ConfigHandler<int, int>)(object)val.Config.DefaultWeight).ConfigEntry.Value != (int)((ConfigEntryBase)((ConfigHandler<int, int>)(object)val.Config.DefaultWeight).ConfigEntry).DefaultValue)
				{
					WesleysMoonsHQModule.Logger.LogWarning((object)("Invalid configuration in WeatherRegistry Weather definition: " + val.Name));
					VailidityCheckFailed = true;
				}
			}
		}

		[HarmonyPatch(typeof(HUDManager), "Start")]
		[HarmonyPostfix]
		private static void HUDManager_Start_Postfix()
		{
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Expected O, but got Unknown
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01da: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
			if (!VailidityCheckFailed)
			{
				return;
			}
			if ((Object)(object)infoDisplay == (Object)null)
			{
				WesleysMoonsHQModule.Logger.LogInfo((object)"infoDisplay is null. Creating a new infodisplay.");
				GameObject val = new GameObject("WesleysMoonsHQModule_infoDisplay");
				val.transform.parent = ((TMP_Text)HUDManager.Instance.weightCounter).transform.parent;
				TextMeshProUGUI weightCounter = HUDManager.Instance.weightCounter;
				infoDisplay = val.AddComponent<TextMeshProUGUI>();
				((TMP_Text)infoDisplay).textStyle = ((TMP_Text)weightCounter).textStyle;
				((Component)infoDisplay).tag = ((Component)weightCounter).tag;
				((TMP_Text)infoDisplay).alignment = ((TMP_Text)weightCounter).alignment;
				((Graphic)infoDisplay).color = ((Graphic)weightCounter).color;
				((TMP_Text)infoDisplay).font = ((TMP_Text)weightCounter).font;
				((TMP_Text)infoDisplay).fontSize = ((TMP_Text)weightCounter).fontSize;
				((TMP_Text)infoDisplay).fontStyle = ((TMP_Text)weightCounter).fontStyle;
				((TMP_Text)infoDisplay).fontWeight = ((TMP_Text)weightCounter).fontWeight;
				((TMP_Text)infoDisplay).enableAutoSizing = ((TMP_Text)weightCounter).enableAutoSizing;
				((TMP_Text)infoDisplay).fontSizeMin = ((TMP_Text)weightCounter).fontSizeMin;
				((TMP_Text)infoDisplay).fontSizeMax = ((TMP_Text)weightCounter).fontSizeMax;
				((TMP_Text)infoDisplay).isOverlay = ((TMP_Text)weightCounter).isOverlay;
				((TMP_Text)infoDisplay).transform.position = ((TMP_Text)weightCounter).transform.position;
				((TMP_Text)infoDisplay).text = "text";
				RectTransform component = ((Component)infoDisplay).GetComponent<RectTransform>();
				if ((Object)(object)component == (Object)null)
				{
					WesleysMoonsHQModule.Logger.LogError((object)"Transform not found");
					return;
				}
				component.offsetMin = ((Component)weightCounter).GetComponent<RectTransform>().offsetMin;
				component.offsetMax = ((Component)weightCounter).GetComponent<RectTransform>().offsetMax;
				component.anchoredPosition = new Vector2(67f, -32f);
				((Transform)component).localScale = Vector3.one;
				((Transform)component).localRotation = Quaternion.identity;
			}
			if (!((Object)(object)infoDisplay == (Object)null))
			{
				((TMP_Text)infoDisplay).text = "Invalid Pack";
			}
		}
	}
	[HarmonyPatch(typeof(WeatherObjectContainer))]
	internal class WesleysWeatherStuffPatcher
	{
		[HarmonyPatch("DestroyObjects")]
		[HarmonyPrefix]
		private static void DestroyObjectsPatch(WeatherObjectContainer __instance)
		{
			__instance.weatherObjects = Object.FindObjectsOfType<WeatherObject>().ToList();
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}