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 BCMHQModule.MonoBehaviours; using BCMHQModule.Patches; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using BrutalCompanyMinus; using BrutalCompanyMinus.Minus; using BrutalCompanyMinus.Minus.Events; using BrutalCompanyMinus.Minus.Handlers; using BrutalCompanyMinus.Minus.MonoBehaviours; using HQoL.Network; using HarmonyLib; using Microsoft.CodeAnalysis; using TMPro; using UnityEngine; using UnityEngine.AI; using UnityEngine.Events; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: IgnoresAccessChecksTo("BrutalCompanyMinus")] [assembly: IgnoresAccessChecksTo("OreoM.HQoL.72")] [assembly: IgnoresAccessChecksTo("OreoM.HQoL.73")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("Tomatobird.BCMHQModule")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.5.0.0")] [assembly: AssemblyInformationalVersion("1.5.0+2dbcdf471fbd6fe298b6ee5922ce3d845da3245d")] [assembly: AssemblyProduct("BCMHQModule")] [assembly: AssemblyTitle("Tomatobird.BCMHQModule")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.5.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 BCMHQModule { [BepInPlugin("Tomatobird.BCMHQModule", "BCMHQModule", "1.5.0")] [BepInDependency("Drinkable.BrutalCompanyMinus", "0.10.12")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public class BCMHQModule : BaseUnityPlugin { internal enum Versions { v49, v50, v56, v72, v73, v81 } public static ConfigEntry internalNames = null; public static ConfigEntry sdcMode = null; internal static bool correctVersion = false; internal static string bcmVersionString = ""; internal static List versionDefinitions = new List { new VersionDefinition(Versions.v49, "0.10.12", new Type[4] { typeof(NoMasksPatcher), typeof(GetSafePositionPatcher), typeof(DelayedExecutionPatcher_v49), typeof(ShipLeaveOnQuit) }), new VersionDefinition(Versions.v50, "0.13.9", new Type[2] { typeof(DelayedExecutionPatcher), typeof(ShipLeaveOnQuit) }), new VersionDefinition(Versions.v56, "0.13.10", new Type[2] { typeof(DelayedExecutionPatcher), typeof(ShipLeaveOnQuit) }), new VersionDefinition(Versions.v72, "0.13.13", new Type[3] { typeof(DelayedExecutionPatcher), typeof(ShipLeaveOnQuit), typeof(UpdateEnemyHPPatcher) }), new VersionDefinition(Versions.v73, "0.13.14", new Type[3] { typeof(DelayedExecutionPatcher), typeof(ShipLeaveOnQuit), typeof(UpdateEnemyHPPatcher) }), new VersionDefinition(Versions.v81, "0.13.16", Array.Empty()) }; internal static bool isHQoLLoaded; public static BCMHQModule 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; if ((Object)(object)Instance == (Object)null) { Instance = this; } internalNames = ((BaseUnityPlugin)this).Config.Bind("General", "InternalEventNames", true, "Display the internal event names instead of the randomly selected event descriptions."); sdcMode = ((BaseUnityPlugin)this).Config.Bind("General", "SdcMode", false, "Set difficulty to 100 for Single Day Clear runs."); isHQoLLoaded = Chainloader.PluginInfos.ContainsKey("OreoM.HQoL.72") || Chainloader.PluginInfos.ContainsKey("OreoM.HQoL.73"); Patch(); Logger.LogInfo((object)"Tomatobird.BCMHQModule v1.5.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.BCMHQModule"); } foreach (PluginInfo value in Chainloader.PluginInfos.Values) { if (value.Metadata.GUID != "Drinkable.BrutalCompanyMinus") { continue; } Version version = value.Metadata.Version; bcmVersionString = version.ToString(); foreach (VersionDefinition versionDefinition in versionDefinitions) { if (bcmVersionString != versionDefinition.bcmVersion) { continue; } PatchType(versionDefinition.types); if (versionDefinition.version != Versions.v49) { PatchType(typeof(LockConfigurationPatcher)); if (isHQoLLoaded) { PatchType(typeof(ValueSynchronizer)); } } correctVersion = true; break; } if (!correctVersion) { Logger.LogWarning((object)$"Version {version} of BCM loaded was NOT contained in the internal version list. Make sure you're using one of the versions listed below!"); foreach (VersionDefinition versionDefinition2 in versionDefinitions) { Logger.LogWarning((object)$"{versionDefinition2.version}: {versionDefinition2.bcmVersion}"); } Logger.LogWarning((object)"Applying generic patches anyway assuming this is a newer version. Things may break."); } if (bcmVersionString != versionDefinitions[0].bcmVersion) { PatchType(typeof(MenuManagerPatcher)); } PatchType(new Type[2] { typeof(EndOfGamePatcher), typeof(QuotaRackupPatcher) }); break; } Logger.LogDebug((object)"Finished patching!"); } internal static void PatchType(Type[] typeArray) { foreach (Type type in typeArray) { PatchType(type); } } internal static void PatchType(Type type) { Logger.LogDebug((object)("Patching " + type.Name)); Harmony? harmony = Harmony; if (harmony != null) { harmony.PatchAll(type); } } internal static void EndOfGameBackupPatch() { Logger.LogWarning((object)"Failed to patch EndOfGamePatcher! Patching EndOfGamePatcherBackup as backup!"); PatchType(new Type[1] { typeof(EndOfGamePatcherBackup) }); } } internal class VersionDefinition(BCMHQModule.Versions version, string bcmVersion, Type[] types) { public BCMHQModule.Versions version = version; public string bcmVersion = bcmVersion; public Type[] types = types; } public static class MyPluginInfo { public const string PLUGIN_GUID = "Tomatobird.BCMHQModule"; public const string PLUGIN_NAME = "BCMHQModule"; public const string PLUGIN_VERSION = "1.5.0"; } } namespace BCMHQModule.Patches { [HarmonyPatch(/*Could not decode attribute arguments.*/)] public class DelayedExecutionPatcher { [HarmonyTranspiler] private static IEnumerable DelayedExcecutionTranspiler(IEnumerable instructions) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Expected O, but got Unknown //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Expected O, but got Unknown //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Expected O, but got Unknown //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Expected O, but got Unknown //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Expected O, but got Unknown //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Expected O, but got Unknown //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Expected O, but got Unknown //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Expected O, but got Unknown //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Expected O, but got Unknown //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Expected O, but got Unknown return new CodeMatcher(instructions, (ILGenerator)null).MatchForward(false, (CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.Newobj, (object)AccessTools.Constructor(typeof(WaitForSeconds), new Type[1] { typeof(float) }, false), (string)null) }).ThrowIfNotMatch("Could not match for WaitForSeconds(float) in DelayedExcecution", Array.Empty()).MatchForward(false, (CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.Call, (object)AccessTools.PropertyGetter(typeof(Net), "Instance"), (string)null) }) .ThrowIfNotMatch("Could not match for BrutalCompanyMinus.Net.Instance in DelayedExcecution", Array.Empty()) .Insert((CodeInstruction[])(object)new CodeInstruction[8] { new CodeInstruction(OpCodes.Call, (object)AccessTools.PropertyGetter(typeof(StartOfRound), "Instance")), new CodeInstruction(OpCodes.Ldfld, (object)AccessTools.Field(typeof(StartOfRound), "randomMapSeed")), new CodeInstruction(OpCodes.Ldc_I4_2, (object)null), new CodeInstruction(OpCodes.Add, (object)null), new CodeInstruction(OpCodes.Call, (object)AccessTools.PropertyGetter(typeof(Net), "Instance")), new CodeInstruction(OpCodes.Ldfld, (object)AccessTools.Field(typeof(Net), "_seed")), new CodeInstruction(OpCodes.Add, (object)null), new CodeInstruction(OpCodes.Stsfld, (object)AccessTools.Field(typeof(Spawn), "randomSeedValue")) }) .InstructionEnumeration(); } } [HarmonyPatch(/*Could not decode attribute arguments.*/)] public class DelayedExecutionPatcher_v49 { [HarmonyTranspiler] private static IEnumerable DelayedExcecutionTranspiler(IEnumerable instructions) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Expected O, but got Unknown //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Expected O, but got Unknown //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Expected O, but got Unknown //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Expected O, but got Unknown //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Expected O, but got Unknown //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Expected O, but got Unknown //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Expected O, but got Unknown return new CodeMatcher(instructions, (ILGenerator)null).MatchForward(false, (CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.Newobj, (object)AccessTools.Constructor(typeof(WaitForSeconds), new Type[1] { typeof(float) }, false), (string)null) }).ThrowIfNotMatch("Could not match for WaitForSeconds(float) in DelayedExcecution", Array.Empty()).MatchForward(false, (CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.Call, (object)AccessTools.PropertyGetter(typeof(Net), "Instance"), (string)null) }) .ThrowIfNotMatch("Could not match for BrutalCompanyMinus.Net.Instance in DelayedExcecution", Array.Empty()) .Insert((CodeInstruction[])(object)new CodeInstruction[5] { new CodeInstruction(OpCodes.Call, (object)AccessTools.PropertyGetter(typeof(StartOfRound), "Instance")), new CodeInstruction(OpCodes.Ldfld, (object)AccessTools.Field(typeof(StartOfRound), "randomMapSeed")), new CodeInstruction(OpCodes.Ldc_I4_2, (object)null), new CodeInstruction(OpCodes.Add, (object)null), new CodeInstruction(OpCodes.Stsfld, (object)AccessTools.Field(typeof(Spawn), "randomSeedValue")) }) .InstructionEnumeration(); } } [HarmonyPatch(typeof(StartOfRound))] public class EndOfGamePatcher { [HarmonyPatch(/*Could not decode attribute arguments.*/)] [HarmonyTranspiler] private static IEnumerable EndOfGameTranspiler(IEnumerable instructions, ILGenerator generator) { //IL_018a: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Expected O, but got Unknown //IL_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Expected O, but got Unknown //IL_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Expected O, but got Unknown //IL_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Expected O, but got Unknown //IL_01f4: Unknown result type (might be due to invalid IL or missing references) //IL_01fa: Expected O, but got Unknown //IL_0208: Unknown result type (might be due to invalid IL or missing references) //IL_020e: Expected O, but got Unknown //IL_0244: Unknown result type (might be due to invalid IL or missing references) //IL_024a: Expected O, but got Unknown //IL_0258: Unknown result type (might be due to invalid IL or missing references) //IL_025e: Expected O, but got Unknown //IL_026c: Unknown result type (might be due to invalid IL or missing references) //IL_0272: Expected O, but got Unknown //IL_0280: Unknown result type (might be due to invalid IL or missing references) //IL_0286: Expected O, but got Unknown //IL_0294: Unknown result type (might be due to invalid IL or missing references) //IL_029a: Expected O, but got Unknown //IL_02a8: Unknown result type (might be due to invalid IL or missing references) //IL_02ae: Expected O, but got Unknown //IL_02dd: Unknown result type (might be due to invalid IL or missing references) //IL_02e3: Expected O, but got Unknown //IL_02f7: Unknown result type (might be due to invalid IL or missing references) //IL_02fd: Expected O, but got Unknown //IL_0311: Unknown result type (might be due to invalid IL or missing references) //IL_0317: Expected O, but got Unknown //IL_0330: Unknown result type (might be due to invalid IL or missing references) //IL_0336: Expected O, but got Unknown //IL_034a: Unknown result type (might be due to invalid IL or missing references) //IL_0350: Expected O, but got Unknown //IL_0364: Unknown result type (might be due to invalid IL or missing references) //IL_036a: Expected O, but got Unknown //IL_037d: Unknown result type (might be due to invalid IL or missing references) //IL_0383: Expected O, but got Unknown //IL_039c: Unknown result type (might be due to invalid IL or missing references) //IL_03a2: Expected O, but got Unknown FieldInfo fieldInfo = null; foreach (CodeInstruction instruction in instructions) { FieldInfo obj = instruction.operand as FieldInfo; if ((object)obj != null && obj.Name?.Contains("") == true) { FieldInfo obj2 = instruction.operand as FieldInfo; if ((object)obj2 != null && obj2.ReflectedType?.Name.Contains("") == true) { fieldInfo = instruction.operand as FieldInfo; break; } } } if (fieldInfo == null) { BCMHQModule.Logger.LogWarning((object)"Could not find playersDead in EndOfGame."); BCMHQModule.EndOfGameBackupPatch(); return instructions; } IEnumerable result = instructions; FieldInfo fieldInfo2 = AccessTools.Field(typeof(StartOfRound), "gameStats"); FieldInfo fieldInfo3 = AccessTools.Field(typeof(EndOfGameStats), "daysSpent"); FieldInfo fieldInfo4 = AccessTools.Field(typeof(StartOfRound), "currentLevel"); FieldInfo fieldInfo5 = AccessTools.Field(typeof(SelectableLevel), "planetHasTime"); MethodInfo methodInfo = AccessTools.PropertyGetter(typeof(TimeOfDay), "Instance"); FieldInfo fieldInfo6 = AccessTools.Field(typeof(TimeOfDay), "daysUntilDeadline"); try { Label label = default(Label); Label label2 = default(Label); result = new CodeMatcher(instructions, generator).MatchForward(true, (CodeMatch[])(object)new CodeMatch[6] { new CodeMatch((OpCode?)OpCodes.Ldfld, (object)fieldInfo2, (string)null), new CodeMatch((OpCode?)OpCodes.Dup, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldfld, (object)fieldInfo3, (string)null), new CodeMatch((OpCode?)OpCodes.Ldc_I4_1, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Add, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Stfld, (object)fieldInfo3, (string)null) }).ThrowIfNotMatch("Couldnt match codes.", Array.Empty()).Advance(1) .CreateLabel(ref label) .MatchBack(false, (CodeMatch[])(object)new CodeMatch[6] { new CodeMatch((OpCode?)OpCodes.Ldfld, (object)fieldInfo2, (string)null), new CodeMatch((OpCode?)OpCodes.Dup, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldfld, (object)fieldInfo3, (string)null), new CodeMatch((OpCode?)OpCodes.Ldc_I4_1, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Add, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Stfld, (object)fieldInfo3, (string)null) }) .ThrowIfNotMatch("Failed to MatchBack.", Array.Empty()) .Advance(-1) .CreateLabel(ref label2) .InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { new CodeInstruction(OpCodes.Ldloc_1, (object)null) }) .InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { new CodeInstruction(OpCodes.Ldfld, (object)fieldInfo4) }) .InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { new CodeInstruction(OpCodes.Ldfld, (object)fieldInfo5) }) .InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { new CodeInstruction(OpCodes.Brtrue_S, (object)label2) }) .InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { new CodeInstruction(OpCodes.Call, (object)methodInfo) }) .InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { new CodeInstruction(OpCodes.Ldfld, (object)fieldInfo6) }) .InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { new CodeInstruction(OpCodes.Ldc_I4_1, (object)null) }) .InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { new CodeInstruction(OpCodes.Bge_S, (object)label) }) .InstructionEnumeration(); } catch (Exception arg) { BCMHQModule.Logger.LogWarning((object)$"Could not set new codeinstructions to EndOfGame. Exception {arg}"); BCMHQModule.EndOfGameBackupPatch(); } return result; } } [HarmonyPatch(typeof(StartOfRound))] public class EndOfGamePatcherBackup { [HarmonyPatch("EndOfGame")] [HarmonyPrefix] private static void EndOfGamePrefix(StartOfRound __instance) { if (!__instance.currentLevel.planetHasTime && TimeOfDay.Instance.daysUntilDeadline >= 1) { EndOfGameStats gameStats = __instance.gameStats; gameStats.daysSpent--; } } } [HarmonyPatch("BrutalCompanyMinus.Minus.Functions, BrutalCompanyMinus, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", "GetSafePosition")] public class GetSafePositionPatcher { [HarmonyTranspiler] public static IEnumerable GetSafePositionTranspiler(IEnumerable instructions) { //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Expected O, but got Unknown BCMHQModule.Logger.LogDebug((object)"Transpiler called for GetSafePosition"); List list = new List(instructions); MethodInfo methodInfo = AccessTools.Method(typeof(RoundManager), "GetRandomPositionInRadius", new Type[4] { typeof(Vector3), typeof(float), typeof(float), typeof(Random) }, (Type[])null); MethodInfo methodInfo2 = AccessTools.Method(typeof(GetSafePositionPatcher), "GetSafePosition_Replacement", (Type[])null, (Type[])null); if (methodInfo == null || methodInfo2 == null) { BCMHQModule.Logger.LogDebug((object)"OriginalMethod or ReplacementMethod were null."); return list; } for (int i = 0; i < list.Count; i++) { if (CodeInstructionExtensions.Calls(list[i], methodInfo)) { BCMHQModule.Logger.LogDebug((object)string.Format("Replacing call at index {0} with {1}.", i, "GetRandomNavMeshPositionInRadius")); list[i] = new CodeInstruction(OpCodes.Call, (object)methodInfo2); } } return list; } public static Vector3 GetSafePosition_Replacement(Vector3 vector, float minRadius, float radius, Random random) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) return RoundManager.Instance.GetRandomNavMeshPositionInRadius(vector, radius, default(NavMeshHit)); } } [HarmonyPatch(typeof(Configuration))] public class LockConfigurationPatcher { [HarmonyPatch("CreateConfig")] [HarmonyPostfix] public static void PostfixCreateConfig() { //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_01bc: Unknown result type (might be due to invalid IL or missing references) //IL_01c1: 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_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: Unknown result type (might be due to invalid IL or missing references) //IL_033e: Unknown result type (might be due to invalid IL or missing references) //IL_0343: Unknown result type (might be due to invalid IL or missing references) //IL_034d: Unknown result type (might be due to invalid IL or missing references) //IL_0352: Unknown result type (might be due to invalid IL or missing references) //IL_035c: Unknown result type (might be due to invalid IL or missing references) //IL_0361: Unknown result type (might be due to invalid IL or missing references) //IL_036b: Unknown result type (might be due to invalid IL or missing references) //IL_0370: Unknown result type (might be due to invalid IL or missing references) //IL_037a: Unknown result type (might be due to invalid IL or missing references) //IL_037f: Unknown result type (might be due to invalid IL or missing references) //IL_0389: Unknown result type (might be due to invalid IL or missing references) //IL_038e: Unknown result type (might be due to invalid IL or missing references) //IL_0398: Unknown result type (might be due to invalid IL or missing references) //IL_039d: Unknown result type (might be due to invalid IL or missing references) //IL_03a7: Unknown result type (might be due to invalid IL or missing references) //IL_03ac: Unknown result type (might be due to invalid IL or missing references) //IL_03b6: Unknown result type (might be due to invalid IL or missing references) //IL_03bb: Unknown result type (might be due to invalid IL or missing references) //IL_04db: Unknown result type (might be due to invalid IL or missing references) //IL_04e0: Unknown result type (might be due to invalid IL or missing references) //IL_04f0: Unknown result type (might be due to invalid IL or missing references) //IL_04f5: Unknown result type (might be due to invalid IL or missing references) //IL_0505: Unknown result type (might be due to invalid IL or missing references) //IL_050a: Unknown result type (might be due to invalid IL or missing references) //IL_051a: Unknown result type (might be due to invalid IL or missing references) //IL_051f: Unknown result type (might be due to invalid IL or missing references) //IL_052f: Unknown result type (might be due to invalid IL or missing references) //IL_0534: Unknown result type (might be due to invalid IL or missing references) //IL_0544: Unknown result type (might be due to invalid IL or missing references) //IL_0549: Unknown result type (might be due to invalid IL or missing references) //IL_0559: Unknown result type (might be due to invalid IL or missing references) //IL_055e: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Expected O, but got Unknown //IL_0588: Unknown result type (might be due to invalid IL or missing references) //IL_058d: Unknown result type (might be due to invalid IL or missing references) //IL_059e: Unknown result type (might be due to invalid IL or missing references) //IL_05a3: Unknown result type (might be due to invalid IL or missing references) //IL_05b4: Unknown result type (might be due to invalid IL or missing references) //IL_05b9: Unknown result type (might be due to invalid IL or missing references) //IL_05ca: Unknown result type (might be due to invalid IL or missing references) //IL_05cf: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_076a: Unknown result type (might be due to invalid IL or missing references) //IL_076f: Unknown result type (might be due to invalid IL or missing references) //IL_0771: Unknown result type (might be due to invalid IL or missing references) //IL_0773: Unknown result type (might be due to invalid IL or missing references) //IL_0775: Unknown result type (might be due to invalid IL or missing references) //IL_0794: Expected I4, but got Unknown for (int i = 0; i < EventManager.events.Count; i++) { MEvent val = EventManager.events[i]; if (val != null) { try { Type type = ((object)val).GetType(); MEvent val2 = (MEvent)Activator.CreateInstance(((object)val).GetType()); val2.Initalize(); type.GetField("Instance", BindingFlags.Static | BindingFlags.Public)?.SetValue(null, val); bool executed = val.Executed; val.Weight = val2.Weight; val.Enabled = val2.Enabled; val.ColorHex = val2.ColorHex; val.Type = val2.Type; val.Descriptions = val2.Descriptions.ToList(); val.EventsToRemove = val2.EventsToRemove.ToList(); val.EventsToSpawnWith = val2.EventsToSpawnWith.ToList(); val.ScaleList = new Dictionary(val2.ScaleList); val.monsterEvents = val2.monsterEvents.ToList(); val.scrapTransmutationEvent = val2.scrapTransmutationEvent; val.Executed = executed; } catch (Exception ex) { Debug.LogError((object)("Failed to force defaults on event " + val.Name() + ": " + ex.Message)); } } } Configuration.useCustomWeights.Value = false; Configuration.eventsToSpawn = Helper.getScale("2, 0.03, 2.0, 5.0"); Configuration.weightsForExtraEvents = Helper.ParseValuesFromString("40, 39, 15, 5, 1"); Configuration.showEventsInChat.Value = false; Configuration.eventTypeScales = (Scale[])(object)new Scale[6] { Helper.getScale("5, 0.25, 5, 30"), Helper.getScale("40, -0.15, 25, 40"), Helper.getScale("10, -0.05, 5, 10"), Helper.getScale("23, -0.1, 13, 23"), Helper.getScale("3, 0.14, 3, 17"), Helper.getScale("15, -0.05, 10, 15") }; Configuration.difficultyTransitions = Helper.GetDifficultyTransitionsFromString("Easy,00FF00,0|Medium,008000,15|Hard,FF0000,30|Very Hard,800000,50|Insane,140000,75"); Configuration.ignoreMaxCap.Value = false; Configuration.difficultyMaxCap.Value = 100f; Configuration.scaleByDaysPassed.Value = true; Configuration.daysPassedDifficultyMultiplier.Value = 1f; Configuration.daysPassedDifficultyCap.Value = 60f; Configuration.scaleByScrapInShip.Value = true; Configuration.scrapInShipDifficultyMultiplier.Value = 0.0025f; Configuration.scrapInShipDifficultyCap.Value = 30f; Configuration.scaleByQuota.Value = false; Configuration.quotaDifficultyMultiplier.Value = 0.005f; Configuration.quotaDifficultyCap.Value = 100f; Configuration.scaleByMoonGrade.Value = true; Configuration.gradeAdditives = Helper.GetMoonRiskFromString("D,-8|C,-8|B,-4|A,5|S,10|S+,15|S++,20|S+++,30|Other,10"); Configuration.scaleByWeather.Value = false; Configuration.weatherAdditives = new Dictionary { { (LevelWeatherType)(-1), 0f }, { (LevelWeatherType)1, 2f }, { (LevelWeatherType)0, 2f }, { (LevelWeatherType)4, 4f }, { (LevelWeatherType)3, 4f }, { (LevelWeatherType)2, 7f }, { (LevelWeatherType)5, 7f } }; Configuration.spawnChanceMultiplierScaling = Helper.getScale("1.0, 0.017, 1.0, 2.0"); Configuration.insideSpawnChanceAdditive = Helper.getScale("0.0, 0.0, 0.0, 0.0"); Configuration.outsideSpawnChanceAdditive = Helper.getScale("0.0, 0.0, 0.0, 0.0"); Configuration.spawnCapMultiplier = Helper.getScale("1.0, 0.017, 1.0, 2.0"); Configuration.insideEnemyMaxPowerCountScaling = Helper.getScale("0,0,0,0"); Configuration.outsideEnemyPowerCountScaling = Helper.getScale("0,0,0,0"); Configuration.enemyBonusHpScaling = Helper.getScale("0,0,0,0"); Configuration.scrapValueMultiplier = Helper.getScale("1.0, 0.003, 1.0, 1.3"); Configuration.scrapAmountMultiplier = Helper.getScale("1.0, 0.003, 1.0, 1.3"); Configuration.goodEventIncrementMultiplier.Value = 1f; Configuration.badEventIncrementMultiplier.Value = 1f; Configuration.nutSlayerLives.Value = 5; Configuration.nutSlayerHp.Value = 6; Configuration.nutSlayerMovementSpeed.Value = 9.5f; Configuration.nutSlayerImmortal.Value = true; Assets.grabbableTurret.maxValue = 75; Assets.grabbableTurret.minValue = 50; Assets.grabbableLandmine.maxValue = 150; Assets.grabbableLandmine.minValue = 100; Configuration.slayerShotgunMinValue.Value = 200; Configuration.slayerShotgunMaxValue.Value = 300; Configuration.useWeatherMultipliers.Value = true; Configuration.randomizeWeatherMultipliers.Value = false; Configuration.enableTerminalText.Value = true; Configuration.weatherRandomRandomMinInclusive.Value = 0.9f; Configuration.weatherRandomRandomMaxInclusive.Value = 1.2f; Configuration.enableQuotaChanges.Value = false; Configuration.enableAllEnemies.Value = false; Configuration.enableAllAllEnemies.Value = false; Configuration.noneMultiplier = createNewWeatherSettings((LevelWeatherType)(-1), 1f, 1f); Configuration.dustCloudMultiplier = createNewWeatherSettings((LevelWeatherType)0, 1.05f, 1f); Configuration.rainyMultiplier = createNewWeatherSettings((LevelWeatherType)1, 1.05f, 1f); Configuration.stormyMultiplier = createNewWeatherSettings((LevelWeatherType)2, 1.35f, 1.2f); Configuration.foggyMultiplier = createNewWeatherSettings((LevelWeatherType)3, 1.15f, 1.1f); Configuration.floodedMultiplier = createNewWeatherSettings((LevelWeatherType)4, 1.25f, 1.15f); Configuration.eclipsedMultiplier = createNewWeatherSettings((LevelWeatherType)5, 1.35f, 1.2f); foreach (KeyValuePair levelProperty in Configuration.levelProperties) { levelProperty.Value.minScrapAmount = Helper.getScale("1,0,1,1"); levelProperty.Value.maxScrapAmount = Helper.getScale("1,0,1,1"); levelProperty.Value.minScrapValue = Helper.getScale("1,0,1,1"); levelProperty.Value.maxScrapValue = Helper.getScale("1,0,1,1"); } FacilityGhost.actionCurrentTime = 15f; FacilityGhost.ghostCrazyActionInterval = 0.1f; FacilityGhost.ghostCrazyPeriod = 5f; FacilityGhost.crazyGhostChance = 0.1f; FacilityGhost.DoNothingWeight = 25; FacilityGhost.OpenCloseBigDoorsWeight = 20; FacilityGhost.MessWithLightsWeight = 16; FacilityGhost.MessWithBreakerWeight = 4; FacilityGhost.disableTurretsWeight = 5; FacilityGhost.disableLandminesWeight = 5; FacilityGhost.disableSpikeTrapsWeight = 5; FacilityGhost.turretRageWeight = 5; FacilityGhost.OpenCloseDoorsWeight = 9; FacilityGhost.lockUnlockDoorsWeight = 3; FacilityGhost.chanceToOpenCloseDoor = 0.3f; FacilityGhost.rageTurretsChance = 0.3f; RealityShift.normalScrapWeight = 85; RealityShift.grabbableLandmineWeight = 15; RealityShift.transmuteChance = 0.5f; RealityShift.enemyTeleportChance = 0.1f; DDay.bombardmentInterval = 100f; DDay.bombardmentTime = 15f; DDay.fireInterval = 1f; DDay.fireAmount = 8; DDay.displayWarning = true; DDay.volume = 0.3f; ArtilleryShell.speed = 100f; EventManager.disabledEvents.Clear(); EventManager.allVeryBad.Clear(); EventManager.allBad.Clear(); EventManager.allNeutral.Clear(); EventManager.allGood.Clear(); EventManager.allVeryGood.Clear(); EventManager.allRemove.Clear(); List list = new List(); foreach (MEvent @event in EventManager.events) { if (!@event.Enabled) { EventManager.disabledEvents.Add(@event); continue; } list.Add(@event); EventType type2 = @event.Type; EventType val3 = type2; switch ((int)val3) { case 0: EventManager.allVeryBad.Add(@event); break; case 1: EventManager.allBad.Add(@event); break; case 2: EventManager.allNeutral.Add(@event); break; case 3: EventManager.allGood.Add(@event); break; case 4: EventManager.allVeryGood.Add(@event); break; case 5: EventManager.allRemove.Add(@event); break; } } EventManager.events = list; EventManager.UpdateEventTypeCounts(); EventManager.UpdateAllEventWeights(); static Weather createNewWeatherSettings(LevelWeatherType levelWeatherType, float value, float amount) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) return new Weather(levelWeatherType, value, amount); } } } [HarmonyPatch] public class MenuManagerPatcher { private static TextMeshProUGUI? infoDisplay; [HarmonyPatch(typeof(MenuManager), "Start")] [HarmonyPostfix] public static void Start_Postfix(MenuManager __instance) { //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Expected O, but got Unknown //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)__instance.menuButtons == (Object)null || __instance.isInitScene) { return; } try { GameObject val = GameObject.Find("Canvas/MenuContainer/SettingsPanel/ControlsOptions/InvertYAxis"); if ((Object)(object)val == (Object)null) { BCMHQModule.Logger.LogWarning((object)"Failed to locate InvertYAxis."); return; } GameObject val2 = new GameObject("BCMHQModule_ButtonContainer", new Type[1] { typeof(RectTransform) }); val2.transform.SetParent(__instance.menuButtons.transform, false); RectTransform component = val2.GetComponent(); component.anchoredPosition = new Vector2(-70f, -120f); component.sizeDelta = new Vector2(360f, 60f); ((Transform)component).localScale = Vector3.one; VerticalLayoutGroup val3 = val2.AddComponent(); ((LayoutGroup)val3).childAlignment = (TextAnchor)1; ((HorizontalOrVerticalLayoutGroup)val3).spacing = 10f; ((HorizontalOrVerticalLayoutGroup)val3).childControlHeight = false; ((HorizontalOrVerticalLayoutGroup)val3).childControlWidth = false; CreateSimulatedToggle(val, val2.transform, "Internal Event Names", 0); CreateSimulatedToggle(val, val2.transform, "SDC Mode", 1); BCMHQModule.Logger.LogInfo((object)"Custom settings built and rendered successfully."); } catch (Exception ex) { BCMHQModule.Logger.LogError((object)("Failed to construct UI stack: " + ex.Message)); } } private static void CreateSimulatedToggle(GameObject template, Transform parent, string titleText, int id) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Expected O, but got Unknown //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_01f7: Unknown result type (might be due to invalid IL or missing references) //IL_020e: Unknown result type (might be due to invalid IL or missing references) //IL_0225: Unknown result type (might be due to invalid IL or missing references) //IL_0232: Unknown result type (might be due to invalid IL or missing references) //IL_02d9: Unknown result type (might be due to invalid IL or missing references) //IL_02f0: Unknown result type (might be due to invalid IL or missing references) //IL_0307: Unknown result type (might be due to invalid IL or missing references) //IL_031e: Unknown result type (might be due to invalid IL or missing references) //IL_0335: Unknown result type (might be due to invalid IL or missing references) //IL_0342: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject($"BCMHQModule_Row_{id}", new Type[1] { typeof(RectTransform) }); val.transform.SetParent(parent, false); RectTransform component = val.GetComponent(); component.sizeDelta = new Vector2(100f, 15f); ((Transform)component).localScale = Vector3.one; Image component2 = ((Component)template.transform.Find("Background")).GetComponent(); Sprite val2 = ((component2 != null) ? component2.sprite : null); if ((Object)(object)val2 == (Object)null) { BCMHQModule.Logger.LogWarning((object)"Block was null!"); } Sprite val3 = template.GetComponent()?.enabledImage; if ((Object)(object)val3 == (Object)null) { BCMHQModule.Logger.LogWarning((object)"Checkmark was null!"); } GameObject val4 = Object.Instantiate(template); ((Object)val4).name = $"BCMHQModule_ToggleButton_{id}"; val4.transform.SetParent(val.transform, false); Button component3 = val4.GetComponent