Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of WILDCARDStuff v1.2.11
BepInEx/plugins/WildCardMod/LCWildCardMod.dll
Decompiled 5 days ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; 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.Configuration; using BepInEx.Logging; using GameNetcodeStuff; using HarmonyLib; using LCWildCardMod.Config; using LCWildCardMod.Items; using LCWildCardMod.Items.Fyrus; using LCWildCardMod.NetcodePatcher; using LCWildCardMod.Patches; using LCWildCardMod.Utils; using LethalCompanyInputUtils.Api; using LethalLib.Modules; using Steamworks; using TMPro; using Unity.Netcode; using Unity.Netcode.Components; using UnityEngine; using UnityEngine.AI; using UnityEngine.InputSystem; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: IgnoresAccessChecksTo("LethalCompanyInputUtils")] [assembly: IgnoresAccessChecksTo("LethalLib")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.0.0.0")] [module: UnverifiableCode] [module: NetcodePatchedAssembly] namespace LCWildCardMod { [BepInPlugin("deB.WildCard", "WILDCARD Stuff", "1.2.11")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public class WildCardMod : BaseUnityPlugin { public const string modGUID = "deB.WildCard"; public const string modName = "WILDCARD Stuff"; public const string modVersion = "1.2.11"; public List<Item> scrapList = new List<Item>(); public List<Skin> skinList = new List<Skin>(); public List<MapObject> mapObjectsList = new List<MapObject>(); private readonly Harmony harmony = new Harmony("deB.WildCard"); internal ManualLogSource Log => ((BaseUnityPlugin)this).Logger; internal KeyBinds KeyBinds { get; private set; } = null; internal static WildCardMod Instance { get; private set; } internal WildCardConfig ModConfig { get; private set; } = null; private void Awake() { Instance = this; KeyBinds = new KeyBinds(); InitializeMethods(); LoadFromBundle(); ModConfig = new WildCardConfig(((BaseUnityPlugin)this).Config, scrapList, skinList, mapObjectsList); InitializeAssets(); HandleHarmony(); Log.LogInfo((object)"WILDCARD Stuff Successfully Loaded"); } private void InitializeMethods() { Type[] types = Assembly.GetExecutingAssembly().GetTypes(); for (int i = 0; i < types.Length; i++) { MethodInfo[] methods = types[i].GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic); for (int j = 0; j < methods.Length; j++) { object[] customAttributes = methods[j].GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false); if (customAttributes.Length != 0) { methods[j].Invoke(null, null); } } } } private void LoadFromBundle() { AssetBundle val = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "wildcardmod")); string[] allAssetNames = val.GetAllAssetNames(); for (int i = 0; i < allAssetNames.Length; i++) { switch (allAssetNames[i].Substring(0, allAssetNames[i].LastIndexOf('/'))) { case "assets/my creations/scrap items": scrapList.Add(val.LoadAsset<Item>(allAssetNames[i])); break; case "assets/my creations/skins": skinList.Add(val.LoadAsset<Skin>(allAssetNames[i])); break; case "assets/my creations/map objects": mapObjectsList.Add(val.LoadAsset<MapObject>(allAssetNames[i])); break; default: Log.LogWarning((object)("\"" + allAssetNames[i] + "\" is not a known asset path, skipping.")); break; } } } private void InitializeAssets() { InitializeScraps(); InitializeSkins(); InitializeMapObjects(); } private void InitializeScraps() { //IL_0123: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < scrapList.Count; i++) { Item val = scrapList[i]; string itemName = val.itemName; if (!ModConfig.isScrapEnabled[itemName].Value || (val.spawnPrefab.GetComponent<AdditionalInfo>().isBonus && !ModConfig.assortedScrap.Value)) { Log.LogInfo((object)("\"" + itemName + "\" scrap was disabled!")); scrapList.RemoveAt(i); i--; continue; } Dictionary<LevelTypes, int> dictionary = new Dictionary<LevelTypes, int>(); Dictionary<string, int> dictionary2 = new Dictionary<string, int>(); string[] array = ModConfig.scrapSpawnWeights[itemName].Value.Split(","); foreach (string text in array) { string[] array2 = text.Split(':'); if (array2.Length == 2 && int.TryParse(array2[1], out var result)) { string text2 = array2[0]; if (Enum.TryParse<LevelTypes>(text2, out LevelTypes result2)) { dictionary.Add(result2, result); } else { dictionary2.Add(text2, result); } } } NetworkPrefabs.RegisterNetworkPrefab(val.spawnPrefab); Utilities.FixMixerGroups(val.spawnPrefab); Items.RegisterScrap(val, dictionary, dictionary2); Log.LogDebug((object)("\"" + itemName + "\" scrap was loaded!")); } } private void InitializeSkins() { for (int i = 0; i < skinList.Count; i++) { Skin skin = skinList[i]; string skinName = skin.skinName; if (ModConfig.isSkinEnabled[skinName].Value) { Log.LogDebug((object)("\"" + skinName + "\" skin was loaded!")); continue; } Log.LogInfo((object)("\"" + skinName + "\" skin was disabled!")); skinList.RemoveAt(i); i--; } } private void InitializeMapObjects() { GrabbableObject val = default(GrabbableObject); for (int i = 0; i < mapObjectsList.Count; i++) { MapObject mapObject = mapObjectsList[i]; string mapObjectName = mapObject.mapObjectName; if (ModConfig.isMapObjectEnabled.TryGetValue(mapObjectName, out var value) && !value.Value) { Log.LogInfo((object)("\"" + mapObjectName + "\" map object was disabled!")); mapObjectsList.RemoveAt(i); i--; continue; } NetworkPrefabs.RegisterNetworkPrefab(mapObject.spawnableMapObject.prefabToSpawn); Utilities.FixMixerGroups(mapObject.spawnableMapObject.prefabToSpawn); if (mapObject.spawnableMapObject.prefabToSpawn.TryGetComponent<GrabbableObject>(ref val)) { Items.RegisterItem(val.itemProperties); } MapObjects.RegisterMapObject(mapObject.spawnableMapObject, (LevelTypes)(-1), mapObject.GetCurveFunc()); Log.LogDebug((object)("\"" + mapObjectName + "\" map object was loaded!")); } } private void HandleHarmony() { harmony.PatchAll(typeof(NecessaryPatches)); if (ModConfig.isSkinEnabled.Any((KeyValuePair<string, ConfigEntry<bool>> x) => x.Value.Value)) { harmony.PatchAll(typeof(SkinsPatches)); } if (ModConfig.isScrapEnabled.TryGetValue("Cojiro", out var value) && value.Value) { harmony.PatchAll(typeof(CojiroPatches)); } if ((ModConfig.isScrapEnabled.TryGetValue("Halo", out var value2) && value2.Value) || (ModConfig.isScrapEnabled.TryGetValue("Fyrus Star", out var value3) && value3.Value)) { harmony.PatchAll(typeof(EnemyAIFyrusOrHaloGraceSavePatch)); harmony.PatchAll(typeof(SavePatches)); } } } } namespace LCWildCardMod.Utils { internal static class HarmonyHelper { internal static MethodInfo toString = AccessTools.Method(typeof(object), "ToString", (Type[])null, (Type[])null); internal static MethodInfo stringConcat3 = AccessTools.Method(typeof(string), "Concat", new Type[3] { typeof(string), typeof(string), typeof(string) }, (Type[])null); internal static MethodInfo logString = AccessTools.Method(typeof(HarmonyHelper), "LogString", new Type[1] { typeof(string) }, (Type[])null); internal static MethodInfo inequality = AccessTools.Method(typeof(Object), "op_Inequality", new Type[2] { typeof(Object), typeof(Object) }, (Type[])null); internal static MethodInfo mathfClamp3Int = AccessTools.Method(typeof(Mathf), "Clamp", new Type[3] { typeof(int), typeof(int), typeof(int) }, (Type[])null); internal static MethodInfo collision = AccessTools.Method(typeof(EnemyAI), "MeetsStandardPlayerCollisionConditions", new Type[3] { typeof(Collider), typeof(bool), typeof(bool) }, (Type[])null); internal static MethodInfo onCollision = AccessTools.Method(typeof(EnemyAI), "OnCollideWithPlayer", new Type[1] { typeof(Collider) }, (Type[])null); internal static MethodInfo exitDriver = AccessTools.Method(typeof(VehicleController), "ExitDriverSideSeat", (Type[])null, (Type[])null); internal static MethodInfo exitPassenger = AccessTools.Method(typeof(VehicleController), "ExitPassengerSideSeat", (Type[])null, (Type[])null); internal static MethodInfo haloSave = AccessTools.Method(typeof(SaveHelper), "SaveIfHalo", new Type[1] { typeof(PlayerControllerB) }, (Type[])null); internal static MethodInfo anySave = AccessTools.Method(typeof(SaveHelper), "SaveIfAny", new Type[2] { typeof(PlayerControllerB), typeof(EnemyAI) }, (Type[])null); internal static MethodInfo wasFyrusOrHaloGraceSaved = AccessTools.Method(typeof(SaveHelper), "SaveIfFyrusOrHaloExhausting", new Type[2] { typeof(PlayerControllerB), typeof(EnemyAI) }, (Type[])null); internal static MethodInfo killPlayer = AccessTools.Method(typeof(PlayerControllerB), "KillPlayer", new Type[6] { typeof(Vector3), typeof(bool), typeof(CauseOfDeath), typeof(int), typeof(Vector3), typeof(bool) }, (Type[])null); internal static MethodInfo damagePlayer = AccessTools.Method(typeof(PlayerControllerB), "DamagePlayer", new Type[7] { typeof(int), typeof(bool), typeof(bool), typeof(CauseOfDeath), typeof(int), typeof(bool), typeof(Vector3) }, (Type[])null); internal static MethodInfo makeInjured = AccessTools.Method(typeof(PlayerControllerB), "MakeCriticallyInjured", new Type[1] { typeof(bool) }, (Type[])null); internal static MethodInfo updateHealth = AccessTools.Method(typeof(HUDManager), "UpdateHealthUI", new Type[2] { typeof(int), typeof(bool) }, (Type[])null); internal static MethodInfo switchBehaviour = AccessTools.Method(typeof(EnemyAI), "SwitchToBehaviourState", new Type[1] { typeof(int) }, (Type[])null); internal static MethodInfo switchBehaviourLocal = AccessTools.Method(typeof(EnemyAI), "SwitchToBehaviourStateOnLocalClient", new Type[1] { typeof(int) }, (Type[])null); internal static MethodInfo setSpeed = AccessTools.Method(typeof(NavMeshAgent), "set_speed", new Type[1] { typeof(float) }, (Type[])null); internal static MethodInfo allowDeath = AccessTools.Method(typeof(PlayerControllerB), "AllowPlayerDeath", (Type[])null, (Type[])null); internal static MethodInfo cancelSpecialAnim = AccessTools.Method(typeof(EnemyAI), "CancelSpecialAnimationWithPlayer", (Type[])null, (Type[])null); internal static MethodInfo beeKill = AccessTools.Method(typeof(RedLocustBees), "BeeKillPlayerOnLocalClient", new Type[1] { typeof(int) }, (Type[])null); internal static MethodInfo dogKill = AccessTools.Method(typeof(MouthDogAI), "KillPlayerServerRpc", new Type[1] { typeof(int) }, (Type[])null); internal static MethodInfo maskKill = AccessTools.Method(typeof(MaskedPlayerEnemy), "FinishKillAnimation", new Type[1] { typeof(bool) }, (Type[])null); internal static MethodInfo jesterKill = AccessTools.Method(typeof(JesterAI), "KillPlayerServerRpc", new Type[1] { typeof(int) }, (Type[])null); internal static MethodInfo dwellerKill = AccessTools.Method(typeof(CaveDwellerAI), "KillPlayerAnimationServerRpc", new Type[1] { typeof(int) }, (Type[])null); internal static MethodInfo bloomBurst = AccessTools.Method(typeof(CadaverBloomAI), "BurstForth", new Type[4] { typeof(PlayerControllerB), typeof(bool), typeof(Vector3), typeof(Vector3) }, (Type[])null); internal static MethodInfo gameNetworkInstance = AccessTools.Method(typeof(GameNetworkManager), "get_Instance", (Type[])null, (Type[])null); internal static MethodInfo foxCancelReel = AccessTools.Method(typeof(BushWolfEnemy), "CancelReelingPlayerIn", (Type[])null, (Type[])null); internal static MethodInfo cadaverCure = AccessTools.Method(typeof(CadaverGrowthAI), "CurePlayer", new Type[1] { typeof(int) }, (Type[])null); internal static MethodInfo cadaverCureRPC = AccessTools.Method(typeof(CadaverGrowthAI), "CurePlayerRpc", new Type[1] { typeof(int) }, (Type[])null); internal static MethodInfo giantStopKill = AccessTools.Method(typeof(ForestGiantAI), "StopKillAnimation", (Type[])null, (Type[])null); internal static MethodInfo ghostStopChase = AccessTools.Method(typeof(DressGirlAI), "StopChasing", (Type[])null, (Type[])null); internal static FieldInfo playerName = AccessTools.Field(typeof(PlayerControllerB), "playerUsername"); internal static FieldInfo playerClientId = AccessTools.Field(typeof(PlayerControllerB), "playerClientId"); internal static FieldInfo enemyType = AccessTools.Field(typeof(EnemyAI), "enemyType"); internal static FieldInfo enemyName = AccessTools.Field(typeof(EnemyType), "enemyName"); internal static FieldInfo foxInKill = AccessTools.Field(typeof(BushWolfEnemy), "inKillAnimation"); internal static FieldInfo foxDragging = AccessTools.Field(typeof(BushWolfEnemy), "dragging"); internal static FieldInfo hasBurst = AccessTools.Field(typeof(CadaverBloomAI), "hasBurst"); internal static FieldInfo clingPlayer = AccessTools.Field(typeof(CentipedeAI), "clingingToPlayer"); internal static FieldInfo timesSeenByPlayer = AccessTools.Field(typeof(DressGirlAI), "timesSeenByPlayer"); internal static FieldInfo timesStared = AccessTools.Field(typeof(DressGirlAI), "timesStared"); internal static FieldInfo couldNotStare = AccessTools.Field(typeof(DressGirlAI), "couldNotStareLastAttempt"); internal static FieldInfo hauntingPlayer = AccessTools.Field(typeof(DressGirlAI), "hauntingPlayer"); internal static FieldInfo maskHeldBy = AccessTools.Field(typeof(HauntedMaskItem), "previousPlayerHeldBy"); internal static FieldInfo specialAnim = AccessTools.Field(typeof(EnemyAI), "inSpecialAnimationWithPlayer"); internal static FieldInfo maskedLastPlayer = AccessTools.Field(typeof(MaskedPlayerEnemy), "lastPlayerKilled"); internal static FieldInfo playerSinking = AccessTools.Field(typeof(PlayerControllerB), "sinkingValue"); internal static FieldInfo playerCrouching = AccessTools.Field(typeof(PlayerControllerB), "isCrouching"); internal static FieldInfo playerHealth = AccessTools.Field(typeof(PlayerControllerB), "health"); internal static FieldInfo playerInjured = AccessTools.Field(typeof(PlayerControllerB), "criticallyInjured"); internal static FieldInfo playerID = AccessTools.Field(typeof(PlayerControllerB), "playerClientId"); internal static FieldInfo beeZapMode = AccessTools.Field(typeof(RedLocustBees), "beesZappingMode"); internal static FieldInfo giantPlayerStealth = AccessTools.Field(typeof(ForestGiantAI), "playerStealthMeters"); [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static void LogString(string toLog) { WildCardMod.Instance.Log.LogDebug((object)toLog); } internal static List<CodeInstruction> DebugString(string toLog, params Label[] labelsStart) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected O, but got Unknown //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Expected O, but got Unknown return new List<CodeInstruction> { CodeInstructionExtensions.WithLabels(new CodeInstruction(OpCodes.Ldstr, (object)toLog), labelsStart), new CodeInstruction(OpCodes.Call, (object)logString) }; } internal static List<CodeInstruction> DebugLoad<T>(string toLog, OpCode opcode, object operand = null, params Label[] labelsStart) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Expected O, but got Unknown //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Expected O, but got Unknown //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Expected O, but got Unknown //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Expected O, but got Unknown //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0073: 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_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Expected O, but got Unknown List<CodeInstruction> list = new List<CodeInstruction>(); list.Add(CodeInstructionExtensions.WithLabels(new CodeInstruction(OpCodes.Ldstr, (object)toLog), labelsStart)); list.Add(new CodeInstruction(OpCodes.Ldstr, (object)": ")); list.Add(new CodeInstruction(opcode, operand)); list.Add(new CodeInstruction(OpCodes.Box, (object)typeof(T))); list.Add(new CodeInstruction(OpCodes.Callvirt, (object)toString)); list.Add(new CodeInstruction(OpCodes.Call, (object)stringConcat3)); list.Add(new CodeInstruction(OpCodes.Call, (object)logString)); return list; } internal static List<CodeInstruction> DebugLoad<T>(string toLog, IEnumerable<CodeInstruction> loadInstructions, params Label[] labelsStart) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Expected O, but got Unknown //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Expected O, but got Unknown //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Expected O, but got Unknown //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Expected O, but got Unknown //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Expected O, but got Unknown //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Expected O, but got Unknown List<CodeInstruction> list = new List<CodeInstruction>(); list.Add(CodeInstructionExtensions.WithLabels(new CodeInstruction(OpCodes.Ldstr, (object)toLog), labelsStart)); list.Add(new CodeInstruction(OpCodes.Ldstr, (object)": ")); list.Add(new CodeInstruction(OpCodes.Box, (object)typeof(T))); list.Add(new CodeInstruction(OpCodes.Callvirt, (object)toString)); list.Add(new CodeInstruction(OpCodes.Call, (object)stringConcat3)); list.Add(new CodeInstruction(OpCodes.Call, (object)logString)); List<CodeInstruction> list2 = list; list2.InsertRange(2, loadInstructions); return list2; } internal static List<CodeInstruction> DebugLoadFromThis<T>(string toLog, IEnumerable<CodeInstruction> loadInstructions, params Label[] labelsStart) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Expected O, but got Unknown //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Expected O, but got Unknown //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Expected O, but got Unknown //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Expected O, but got Unknown //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Expected O, but got Unknown //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Expected O, but got Unknown //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Expected O, but got Unknown List<CodeInstruction> list = new List<CodeInstruction>(); list.Add(CodeInstructionExtensions.WithLabels(new CodeInstruction(OpCodes.Ldstr, (object)toLog), labelsStart)); list.Add(new CodeInstruction(OpCodes.Ldstr, (object)": ")); list.Add(new CodeInstruction(OpCodes.Ldarg, (object)0)); list.Add(new CodeInstruction(OpCodes.Box, (object)typeof(T))); list.Add(new CodeInstruction(OpCodes.Callvirt, (object)toString)); list.Add(new CodeInstruction(OpCodes.Call, (object)stringConcat3)); list.Add(new CodeInstruction(OpCodes.Call, (object)logString)); List<CodeInstruction> list2 = list; list2.InsertRange(3, loadInstructions); return list2; } internal static List<CodeInstruction> DebugLoadFromThis<T>(string toLog, OpCode opcode, object operand = null, params Label[] labelsStart) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Expected O, but got Unknown //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Expected O, but got Unknown //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Expected O, but got Unknown //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Expected O, but got Unknown //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Expected O, but got Unknown //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Expected O, but got Unknown //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Expected O, but got Unknown //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Expected O, but got Unknown List<CodeInstruction> list = new List<CodeInstruction>(); list.Add(CodeInstructionExtensions.WithLabels(new CodeInstruction(OpCodes.Ldstr, (object)toLog), labelsStart)); list.Add(new CodeInstruction(OpCodes.Ldstr, (object)": ")); list.Add(new CodeInstruction(OpCodes.Ldarg_S, (object)0)); list.Add(new CodeInstruction(opcode, operand)); list.Add(new CodeInstruction(OpCodes.Box, (object)typeof(T))); list.Add(new CodeInstruction(OpCodes.Callvirt, (object)toString)); list.Add(new CodeInstruction(OpCodes.Call, (object)stringConcat3)); list.Add(new CodeInstruction(OpCodes.Call, (object)logString)); return list; } internal static List<CodeInstruction> DebugThisEnemyName(params Label[] labelsStart) { return DebugEnemyName(OpCodes.Ldarg_S, 0, labelsStart); } internal static List<CodeInstruction> DebugEnemyName(OpCode loadEnemyOpcode, object loadEnemyOperand = null, params Label[] labelsStart) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected O, but got Unknown //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Expected O, but got Unknown //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Expected O, but got Unknown return DebugLoad<string>("Enemy", new List<CodeInstruction> { new CodeInstruction(loadEnemyOpcode, loadEnemyOperand), new CodeInstruction(OpCodes.Ldfld, (object)enemyType), new CodeInstruction(OpCodes.Ldfld, (object)enemyName) }, labelsStart); } internal static List<CodeInstruction> DebugEnemyName(IEnumerable<CodeInstruction> loadEnemyInstructions, params Label[] labelsStart) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Expected O, but got Unknown return DebugLoad<string>("Enemy", new List<CodeInstruction>(loadEnemyInstructions) { new CodeInstruction(OpCodes.Ldfld, (object)enemyType), new CodeInstruction(OpCodes.Ldfld, (object)enemyName) }, labelsStart); } internal static List<CodeInstruction> DebugThisPlayerName(params Label[] labelsStart) { return DebugPlayerName(OpCodes.Ldarg_S, 0, labelsStart); } internal static List<CodeInstruction> DebugPlayerName(OpCode loadPlayerOpcode, object loadPlayerOperand = null, params Label[] labelsStart) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected O, but got Unknown //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Expected O, but got Unknown return DebugLoad<string>("Player", new List<CodeInstruction> { new CodeInstruction(loadPlayerOpcode, loadPlayerOperand), new CodeInstruction(OpCodes.Ldfld, (object)playerName) }, labelsStart); } internal static List<CodeInstruction> DebugPlayerName(IEnumerable<CodeInstruction> loadPlayerInstructions, params Label[] labelsStart) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown return DebugLoad<string>("Player", new List<CodeInstruction>(loadPlayerInstructions) { new CodeInstruction(OpCodes.Ldfld, (object)playerName) }, labelsStart); } internal static CodeInstruction StoreToLoad(CodeInstruction store) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Expected O, but got Unknown //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Expected O, but got Unknown //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Expected O, but got Unknown //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0094: 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_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Expected O, but got Unknown //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Expected O, but got Unknown //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Expected O, but got Unknown //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Expected O, but got Unknown object operand = store.operand; CodeInstruction result = new CodeInstruction(OpCodes.Nop, (object)null); if (store.opcode == OpCodes.Stloc_0) { result = new CodeInstruction(OpCodes.Ldloc_S, (object)0); } else if (store.opcode == OpCodes.Stloc_1) { result = new CodeInstruction(OpCodes.Ldloc_S, (object)1); } else if (store.opcode == OpCodes.Stloc_2) { result = new CodeInstruction(OpCodes.Ldloc_S, (object)2); } else if (store.opcode == OpCodes.Stloc_3) { result = new CodeInstruction(OpCodes.Ldloc_S, (object)3); } else if (store.opcode == OpCodes.Stloc_S || store.opcode == OpCodes.Ldloc) { result = new CodeInstruction(OpCodes.Ldloc_S, operand); } else if (store.opcode == OpCodes.Starg_S || store.opcode == OpCodes.Starg) { result = new CodeInstruction(OpCodes.Ldarg_S, operand); } else if (store.opcode == OpCodes.Stfld || store.opcode == OpCodes.Stsfld) { result = new CodeInstruction(OpCodes.Ldfld, operand); } else if (store.opcode == OpCodes.Stobj) { result = new CodeInstruction(OpCodes.Ldobj, operand); } return result; } internal static CodeInstruction LoadToStore(CodeInstruction load) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Expected O, but got Unknown //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Expected O, but got Unknown //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Expected O, but got Unknown //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0094: 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_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Expected O, but got Unknown //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Expected O, but got Unknown //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Expected O, but got Unknown //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Expected O, but got Unknown //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Expected O, but got Unknown //IL_01f0: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: Expected O, but got Unknown //IL_0276: Unknown result type (might be due to invalid IL or missing references) //IL_027c: Expected O, but got Unknown //IL_024e: Unknown result type (might be due to invalid IL or missing references) //IL_0254: Expected O, but got Unknown //IL_023e: Unknown result type (might be due to invalid IL or missing references) //IL_0244: Expected O, but got Unknown object operand = load.operand; CodeInstruction result = new CodeInstruction(OpCodes.Nop, (object)null); if (load.opcode == OpCodes.Ldloc_0) { result = new CodeInstruction(OpCodes.Stloc_S, (object)0); } else if (load.opcode == OpCodes.Ldloc_1) { result = new CodeInstruction(OpCodes.Stloc_S, (object)1); } else if (load.opcode == OpCodes.Ldloc_2) { result = new CodeInstruction(OpCodes.Stloc_S, (object)2); } else if (load.opcode == OpCodes.Ldloc_3) { result = new CodeInstruction(OpCodes.Stloc_S, (object)3); } else if (load.opcode == OpCodes.Ldloc_S || load.opcode == OpCodes.Ldloc) { result = new CodeInstruction(OpCodes.Stloc_S, operand); } else if (load.opcode == OpCodes.Ldarg_0) { result = new CodeInstruction(OpCodes.Starg_S, (object)0); } else if (load.opcode == OpCodes.Ldarg_1) { result = new CodeInstruction(OpCodes.Starg_S, (object)1); } else if (load.opcode == OpCodes.Ldarg_2) { result = new CodeInstruction(OpCodes.Starg_S, (object)2); } else if (load.opcode == OpCodes.Ldarg_3) { result = new CodeInstruction(OpCodes.Starg_S, (object)3); } else if (load.opcode == OpCodes.Ldarg_S || load.opcode == OpCodes.Ldarg) { result = new CodeInstruction(OpCodes.Starg_S, operand); } else if (load.opcode == OpCodes.Ldfld) { FieldInfo fieldInfo = operand as FieldInfo; if (fieldInfo != null) { result = ((!fieldInfo.IsStatic) ? new CodeInstruction(OpCodes.Stfld, operand) : new CodeInstruction(OpCodes.Stsfld, operand)); } } else if (load.opcode == OpCodes.Ldobj) { result = new CodeInstruction(OpCodes.Stobj, operand); } return result; } internal static bool AreLoadEqual(CodeInstruction load1, CodeInstruction load2) { int? num = load1.operand as int?; int? num2 = load2.operand as int?; OpCode opcode = load1.opcode; OpCode opcode2 = load2.opcode; if (CodeInstructionExtensions.IsLdloc(load1, (LocalBuilder)null) && CodeInstructionExtensions.IsLdloc(load2, (LocalBuilder)null)) { if (opcode == opcode2 && CodeInstructionExtensions.OperandIs(load1, load2.operand)) { return true; } if (opcode == OpCodes.Ldloc || opcode == OpCodes.Ldloc_S) { return CodeInstructionExtensions.OperandIs(load1, load2.operand); } if (opcode == OpCodes.Ldloc_0) { return opcode2 == OpCodes.Ldloc_0 || (num2.HasValue && num2.Value == 0); } if (opcode == OpCodes.Ldloc_1) { return opcode2 == OpCodes.Ldloc_1 || (num2.HasValue && num2.Value == 1); } if (opcode == OpCodes.Ldloc_2) { return opcode2 == OpCodes.Ldloc_2 || (num2.HasValue && num2.Value == 2); } if (opcode == OpCodes.Ldloc_3) { return opcode2 == OpCodes.Ldloc_3 || (num2.HasValue && num2.Value == 3); } if ((opcode == OpCodes.Ldloca || opcode == OpCodes.Ldloca_S) && (opcode2 == OpCodes.Ldloca || opcode2 == OpCodes.Ldloca_S)) { return CodeInstructionExtensions.OperandIs(load1, load2.operand); } } else { if (CodeInstructionExtensions.IsLdarg(load1, (int?)null) && CodeInstructionExtensions.IsLdarg(load2, (int?)null)) { return (num2.HasValue && CodeInstructionExtensions.IsLdarg(load1, (int?)num2.Value)) || (num.HasValue && CodeInstructionExtensions.IsLdarg(load2, (int?)num.Value)); } if (CodeInstructionExtensions.IsLdarga(load1, (int?)null) && CodeInstructionExtensions.IsLdarga(load2, (int?)null)) { return CodeInstructionExtensions.OperandIs(load1, load2.operand); } } return opcode == opcode2 && CodeInstructionExtensions.OperandIs(load1, load2.operand); } } internal static class SaveHelper { internal static bool IsSaveable(PlayerControllerB player, out bool starSave, out SmithHalo halo, EnemyAI enemy = null) { halo = null; starSave = SaveIfFyrus(player, enemy); return starSave || (player.isHoldingObject && ((Component)player.currentlyHeldObjectServer).TryGetComponent<SmithHalo>(ref halo) && (((Object)(object)halo.savedPlayer == (Object)(object)player && halo.exhausting) || halo.isExhausted == 0)) || HasSavedHalo(player, out halo); } internal static bool SaveIfFyrus(PlayerControllerB player, EnemyAI enemy = null) { //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)player == (Object)null) { return false; } FyrusStar fyrusStar = null; for (int i = 0; i < FyrusStar.allSpawnedStars.Count; i++) { FyrusStar fyrusStar2 = FyrusStar.allSpawnedStars[i]; if (!((Object)(object)fyrusStar2.affectingPlayer != (Object)(object)player)) { fyrusStar = fyrusStar2; break; } } if ((Object)(object)fyrusStar == (Object)null) { return false; } WildCardMod.Instance.Log.LogDebug((object)("Fyrus star saved " + player.playerUsername + "!")); if ((Object)(object)enemy == (Object)null) { return true; } EnemyAICollisionDetect componentInChildren = ((Component)enemy).GetComponentInChildren<EnemyAICollisionDetect>(); if ((Object)(object)componentInChildren == (Object)null) { return true; } if (fyrusStar.hitCooldown <= 0f && (Object)(object)GameNetworkManager.Instance.localPlayerController == (Object)(object)player) { Vector3 val = ((Component)enemy).transform.position - ((Component)player).transform.position; ((IHittable)componentInChildren).Hit(1, ((Vector3)(ref val)).normalized * 2.5f, player, true, -1); fyrusStar.hitCooldown = fyrusStar.hitCooldownMax; } return true; } internal static bool SaveIfAny(PlayerControllerB player, EnemyAI enemy = null) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) if (IsSaveable(player, out var starSave, out var halo, enemy)) { if (!starSave) { halo.ExhaustLocal(player); } return true; } return false; } internal static bool SaveIfHalo(PlayerControllerB player) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) if (IsSaveable(player, out var starSave, out var halo) && !starSave && (Object)(object)halo.savedPlayer != (Object)(object)player) { halo.ExhaustLocal(player); return true; } return false; } internal static bool WasHaloSaved(PlayerControllerB player, out SmithHalo halo) { bool starSave; return IsSaveable(player, out starSave, out halo) && !starSave && (Object)(object)halo.savedPlayer == (Object)(object)player; } internal static bool SaveIfFyrusOrHaloExhausting(PlayerControllerB player, EnemyAI enemy = null) { SmithHalo halo; return SaveIfFyrus(player, enemy) || WasHaloSaved(player, out halo); } internal static bool HasSavedHalo(PlayerControllerB player, out SmithHalo halo) { halo = null; if ((Object)(object)player == (Object)null) { return false; } for (int i = 0; i < player.ItemSlots.Length; i++) { GrabbableObject val = player.ItemSlots[i]; if (!((Object)(object)val == (Object)null) && ((Component)val).TryGetComponent<SmithHalo>(ref halo) && !((Object)(object)halo.savedPlayer != (Object)(object)player) && halo.exhausting) { return true; } } return HasSavedHaloAnywhere(player, out halo); } internal static bool HasSavedHaloAnywhere(PlayerControllerB player, out SmithHalo halo) { halo = null; if ((Object)(object)player == (Object)null) { return false; } for (int i = 0; i < SmithHalo.allSpawnedHalos.Count; i++) { SmithHalo smithHalo = SmithHalo.allSpawnedHalos[i]; if (!((Object)(object)smithHalo.savedPlayer != (Object)(object)player) && smithHalo.exhausting) { halo = smithHalo; return true; } } return false; } } internal static class EventsClass { internal delegate void RoundStart(); internal delegate void RoundEnd(); internal static bool roundStarted; internal static event RoundStart OnRoundStart; internal static event RoundEnd OnRoundEnd; internal static void RoundStarted() { if (!roundStarted) { roundStarted = true; EventsClass.OnRoundStart?.Invoke(); } } internal static void RoundEnded() { if (roundStarted) { roundStarted = false; EventsClass.OnRoundEnd?.Invoke(); } } } internal class KeyBinds : LcInputActions { [InputAction("<Keyboard>/r", Name = "WildCardUse")] internal InputAction WildCardButton { get; set; } } public class AdditionalInfo : MonoBehaviour { public bool defaultEnabled; public string defaultRarities; public bool isBonus; } internal static class SkinsClass { private static ManualLogSource Log => WildCardMod.Instance.Log; internal static void SetSkin(EnemyAI enemy) { Skin randomSkin = GetRandomSkin(enemy.enemyType.enemyName, SkinType.Enemy); if (!((Object)(object)randomSkin == (Object)null)) { ScriptableObject target = randomSkin.target; string enemyName = ((EnemyType)((target is EnemyType) ? target : null)).enemyName; string text = enemyName; if (text == "Earth Leviathan") { Log.LogDebug((object)("Skin \"" + randomSkin.skinName + "\" is being applied!")); Transform val = ((Component)enemy).transform.Find("MeshContainer"); SkinnedMeshRenderer component = ((Component)val.Find("Renderer")).GetComponent<SkinnedMeshRenderer>(); component.sharedMesh = randomSkin.newMesh; ((Renderer)component).sharedMaterial = randomSkin.newMaterial; ((Component)val.Find("Armature").Find("Bone").Find("Bone.001") .Find("Bone.003") .Find("Bone.002") .Find("ScanNode")).GetComponent<ScanNodeProperties>().headerText = randomSkin.skinName; SandWormAI component2 = ((Component)((Component)enemy).transform).GetComponent<SandWormAI>(); component2.ambientRumbleSFX[0] = randomSkin.newAudioClips[0]; component2.ambientRumbleSFX[1] = randomSkin.newAudioClips[0]; component2.ambientRumbleSFX[2] = randomSkin.newAudioClips[0]; AudioSource creatureSFX = ((EnemyAI)component2).creatureSFX; creatureSFX.volume *= 1.5f; component2.roarSFX[0] = randomSkin.newAudioClips[1]; component2.roarSFX[1] = randomSkin.newAudioClips[2]; } else { Log.LogError((object)("\"" + randomSkin.skinName + "\" did not match any known enemy type!")); } } } internal static void SetSkin(GrabbableObject item) { //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) Skin randomSkin = GetRandomSkin(item.itemProperties.itemName, SkinType.Item); if (!((Object)(object)randomSkin == (Object)null)) { ScriptableObject target = randomSkin.target; string itemName = ((Item)((target is Item) ? target : null)).itemName; string text = itemName; if (text == "Clown horn") { Log.LogDebug((object)("Skin \"" + randomSkin.skinName + "\" is being applied!")); Item val = Object.Instantiate<Item>(item.itemProperties); val.itemName = randomSkin.skinName; val.isConductiveMetal = false; val.grabSFX = randomSkin.newAudioClips[0]; val.dropSFX = randomSkin.newAudioClips[1]; val.toolTips[0] = "Squeeze : [LMB]"; val.positionOffset = new Vector3(0.05f, 0.15f, -0.05f); item.useCooldown = 0.5f; MeshFilter component = val.spawnPrefab.GetComponent<MeshFilter>(); component.mesh = randomSkin.newMesh; component.sharedMesh = randomSkin.newMesh; MeshFilter component2 = ((Component)((Component)item).transform).GetComponent<MeshFilter>(); component2.mesh = randomSkin.newMesh; component2.sharedMesh = randomSkin.newMesh; MeshRenderer component3 = ((Component)((Component)item).transform).GetComponent<MeshRenderer>(); ((Renderer)component3).material = randomSkin.newMaterial; ((Renderer)component3).sharedMaterial = randomSkin.newMaterial; ((Component)((Component)item).transform.Find("ScanNode")).GetComponent<ScanNodeProperties>().headerText = randomSkin.skinName; Animator val2 = ((Component)item).gameObject.AddComponent<Animator>(); val2.runtimeAnimatorController = randomSkin.newAnimationController; ((Component)((Component)item).transform).GetComponent<NoisemakerProp>().triggerAnimator = val2; item.itemProperties = val; } else { Log.LogError((object)("\"" + randomSkin.skinName + "\" did not match any known item!")); } } } private static Skin GetRandomSkin(string target, SkinType type) { Random random = new Random(StartOfRound.Instance.randomMapSeed + 69); int num = 0; int num2 = 0; List<Skin> list = new List<Skin>(); for (int i = 0; i < WildCardMod.Instance.skinList.Count; i++) { Skin skin = WildCardMod.Instance.skinList[i]; switch (type) { case SkinType.Enemy: { ScriptableObject target3 = skin.target; EnemyType val2 = (EnemyType)(object)((target3 is EnemyType) ? target3 : null); if (val2 != null && val2.enemyName == target) { list.Add(skin); } break; } case SkinType.Item: { ScriptableObject target2 = skin.target; Item val = (Item)(object)((target2 is Item) ? target2 : null); if (val != null && val.itemName == target) { list.Add(skin); } break; } } } if (list.Count == 0) { return null; } for (int j = 0; j < list.Count; j++) { Skin skin2 = list[j]; string skinName = skin2.skinName; if (WildCardMod.Instance.ModConfig.skinApplyChance[skinName].Value <= 0) { Log.LogDebug((object)("Skin \"" + skinName + "\" was disabled!")); list.RemoveAt(j); j--; } else { Log.LogDebug((object)("Adding skin \"" + skinName + "\"'s chance weight!")); num2 += WildCardMod.Instance.ModConfig.skinApplyChance[skinName].Value; num += 100 - WildCardMod.Instance.ModConfig.skinApplyChance[skinName].Value; } } float num3 = (float)random.NextDouble(); Log.LogDebug((object)"Rolling to see if a skin will be applied!"); if ((float)num / (float)(num + num2) >= num3) { return null; } for (int num4 = list.Count - 1; num4 > 1; num4--) { int num5 = random.Next(num4 + 1); List<Skin> list2 = list; int index = num4; int index2 = num5; Skin value = list[num5]; Skin value2 = list[num4]; list2[index] = value; list[index2] = value2; } for (int k = 0; k < list.Count; k++) { Skin skin3 = list[k]; string skinName2 = skin3.skinName; Log.LogDebug((object)("Rolling to see if \"" + skinName2 + "\" is selected!")); if ((float)(WildCardMod.Instance.ModConfig.skinApplyChance[skinName2].Value / num2) >= num3) { Log.LogDebug((object)("Skin \"" + skinName2 + "\" was selected!")); return skin3; } } return null; } } [CreateAssetMenu(menuName = "WildCard/Skin", order = 1)] public class Skin : ScriptableObject { public string skinName; public bool skinEnabled; public int skinChance; public ScriptableObject target; public Mesh newMesh; public Material newMaterial; public AudioClip[] newAudioClips; public RuntimeAnimatorController newAnimationController; } [CreateAssetMenu(menuName = "WildCard/MapObject", order = 1)] public class MapObject : ScriptableObject { public string mapObjectName; public SpawnableMapObject spawnableMapObject; public List<LevelCurve> levelCurves; public bool autoHandle; internal Func<SelectableLevel, AnimationCurve> GetCurveFunc() { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: 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_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Expected O, but got Unknown AnimationCurve curve = new AnimationCurve((Keyframe[])(object)new Keyframe[2] { new Keyframe(0f, 0f), new Keyframe(0f, 0f) }); if (levelCurves != null && (autoHandle || WildCardMod.Instance.ModConfig.useDefaultMapObjectCurve[mapObjectName].Value)) { return delegate(SelectableLevel x) { for (int i = 0; i < levelCurves.Count; i++) { LevelCurve levelCurve = levelCurves[i]; string level = levelCurve.level; if (!(level != ((Object)x).name)) { curve = levelCurve.curve; break; } } return curve; }; } if (WildCardMod.Instance.ModConfig.mapObjectMinMax.TryGetValue(mapObjectName, out var value)) { ((Keyframe)(ref curve.keys[0])).value = value.Item1.Value; ((Keyframe)(ref curve.keys[1])).value = value.Item2.Value; } return (SelectableLevel x) => curve; } } [Serializable] public class LevelCurve { public string level; public AnimationCurve curve; } internal enum SkinType { Item, Enemy } [Serializable] public struct NameImagePair { public string name; public Texture2D image; internal static Dictionary<string, Texture2D> ConvertToDict(List<NameImagePair> pairs) { Dictionary<string, Texture2D> dictionary = new Dictionary<string, Texture2D>(); for (int i = 0; i < pairs.Count; i++) { NameImagePair nameImagePair = pairs[i]; if (!dictionary.TryAdd(nameImagePair.name, nameImagePair.image)) { WildCardMod.Instance.Log.LogDebug((object)("Name image pair of name \"" + nameImagePair.name + "\"")); } } return dictionary; } } } namespace LCWildCardMod.Patches { public static class CojiroPatches { private static ManualLogSource Log => WildCardMod.Instance.Log; [HarmonyPatch(typeof(PlayerControllerB), "PlayerHitGroundEffects")] [HarmonyWrapSafe] [HarmonyPrefix] public static bool PlayerControllerB_PreventFallDamage(PlayerControllerB __instance) { float fallValue = __instance.fallValue; float fallValueUncapped = __instance.fallValueUncapped; try { Cojiro cojiro = null; if (__instance.isHoldingObject && ((Component)__instance.currentlyHeldObjectServer).TryGetComponent<Cojiro>(ref cojiro) && cojiro.isFloating && __instance.fallValue >= -38f) { Log.LogDebug((object)"Cojiro Preventing Fall Damage"); __instance.fallValue = -10f; __instance.fallValueUncapped = -10f; cojiro.itemAnimator.Animator.SetBool("Floating", false); } else if ((Object)(object)cojiro == (Object)null && __instance.fallValue >= -38f) { for (int i = 0; i < __instance.ItemSlots.Length; i++) { if (!((Object)(object)__instance.ItemSlots[i] == (Object)null) && ((Component)__instance.ItemSlots[i]).TryGetComponent<Cojiro>(ref cojiro) && (Object)(object)cojiro.previousPlayer == (Object)(object)__instance && ((GrabbableObject)cojiro).currentUseCooldown > 0f) { Log.LogDebug((object)"Cojiro Preventing Fall Damage"); __instance.fallValue = -10f; __instance.fallValueUncapped = -10f; cojiro.itemAnimator.Animator.SetBool("Floating", false); } } } } catch (Exception ex) { __instance.fallValue = fallValue; __instance.fallValueUncapped = fallValueUncapped; Log.LogError((object)ex); } return true; } } public static class NecessaryPatches { private static ManualLogSource Log => WildCardMod.Instance.Log; [HarmonyPatch(typeof(StartOfRound), "ShipHasLeft")] [HarmonyWrapSafe] [HarmonyPrefix] public static bool StartOfRound_EndRoundInvoke() { try { EventsClass.RoundEnded(); } catch (Exception ex) { Log.LogError((object)ex); } return true; } [HarmonyPatch(typeof(GameNetworkManager), "StartDisconnect")] [HarmonyWrapSafe] [HarmonyPrefix] public static bool GameNetworkManager_EndRoundInvoke() { try { EventsClass.RoundEnded(); } catch (Exception ex) { Log.LogError((object)ex); } return true; } [HarmonyPatch(typeof(RoundManager), "waitForMainEntranceTeleportToSpawn")] [HarmonyWrapSafe] [HarmonyPostfix] public static void RoundManager_StartRoundInvoke() { try { EventsClass.RoundStarted(); } catch (Exception ex) { Log.LogError((object)ex); } } } public static class EnemyAIFyrusOrHaloGraceSavePatch { private static ManualLogSource Log => WildCardMod.Instance.Log; [HarmonyTargetMethods] public static IEnumerable<MethodBase> GetEachEnemyPlayerCollision() { Assembly assembly = Assembly.GetAssembly(typeof(EnemyAI)); Type[] types = assembly.GetTypes(); IEnumerable<Type> source = types.Where((Type type) => typeof(EnemyAI).IsAssignableFrom(type)); IEnumerable<MethodInfo> source2 = source.Select((Type x) => x.GetMethod("OnCollideWithPlayer")); return source2.Where((MethodInfo x) => x.DeclaringType != typeof(EnemyAI) && x.DeclaringType != typeof(DressGirlAI)); } [HarmonyWrapSafe] [HarmonyTranspiler] public static IEnumerable<CodeInstruction> FyrusOrHaloGraceSave(IEnumerable<CodeInstruction> instructions, ILGenerator generator, MethodBase original) { //IL_02e0: Unknown result type (might be due to invalid IL or missing references) //IL_02ea: Expected O, but got Unknown //IL_02f7: Unknown result type (might be due to invalid IL or missing references) //IL_0301: Expected O, but got Unknown //IL_0310: Unknown result type (might be due to invalid IL or missing references) //IL_031a: Expected O, but got Unknown //IL_0364: Unknown result type (might be due to invalid IL or missing references) //IL_036e: Expected O, but got Unknown //IL_037b: Unknown result type (might be due to invalid IL or missing references) //IL_0385: Expected O, but got Unknown //IL_0394: Unknown result type (might be due to invalid IL or missing references) //IL_039e: Expected O, but got Unknown //IL_03a7: Unknown result type (might be due to invalid IL or missing references) //IL_03b1: Expected O, but got Unknown //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Expected O, but got Unknown //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Expected O, but got Unknown //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Expected O, but got Unknown //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Expected O, but got Unknown List<CodeInstruction> list = new List<CodeInstruction>(instructions); bool flag = false; int num = -1; int num2 = HarmonyHelper.damagePlayer.GetParameters().Length; CodeInstruction val = null; Log.LogDebug((object)$"Patching {original.DeclaringType}.{original.Name}"); for (int i = 0; i < list.Count; i++) { if (val == null && CodeInstructionExtensions.Calls(list[i], HarmonyHelper.collision) && CodeInstructionExtensions.IsStloc(list[i + 1], (LocalBuilder)null)) { num = i; val = HarmonyHelper.StoreToLoad(list[i + 1]); } if (num == -1 || !CodeInstructionExtensions.Calls(list[i], HarmonyHelper.damagePlayer)) { continue; } flag = true; int num3 = -1; for (int num4 = i - num2; num4 >= 0; num4--) { if (HarmonyHelper.AreLoadEqual(list[num4], val)) { num3 = num4; break; } } if (num3 != -1) { Label label = generator.DefineLabel(); CodeInstruction val2 = new CodeInstruction(val); CodeInstructionExtensions.MoveLabelsTo(list[num3], val2); List<CodeInstruction> collection = new List<CodeInstruction> { val2, new CodeInstruction(OpCodes.Ldarg_S, (object)0), new CodeInstruction(OpCodes.Call, (object)HarmonyHelper.wasFyrusOrHaloGraceSaved), new CodeInstruction(OpCodes.Brtrue_S, (object)label) }; list[i + 1].labels.Add(label); list.InsertRange(num3, collection); } break; } if (num == -1) { return list; } int num5 = -1; bool flag2 = false; Label? label2 = default(Label?); for (int j = num; j < list.Count; j++) { if (!CodeInstructionExtensions.Branches(list[j], ref label2)) { continue; } for (int num6 = j; num6 > num; num6--) { if (CodeInstructionExtensions.Calls(list[num6], HarmonyHelper.inequality)) { if (list[list.Count - 1].labels.Contains(label2.Value)) { num5 = j + 1; } else if (list[j + 1].opcode.Equals(OpCodes.Ret)) { num5 = j + 2; } flag2 = true; break; } } break; } int index = num + 2; List<CodeInstruction> list2 = new List<CodeInstruction>(); if (!flag2) { Label label3 = generator.DefineLabel(); list2.Add(val); list2.Add(new CodeInstruction(OpCodes.Ldnull, (object)null)); list2.Add(new CodeInstruction(OpCodes.Call, (object)HarmonyHelper.inequality)); list2.Add(new CodeInstruction(OpCodes.Brfalse_S, (object)label3)); list[list.Count - 1].labels.Add(label3); } if (!flag) { Label label4 = generator.DefineLabel(); list2.Add(val); list2.Add(new CodeInstruction(OpCodes.Ldarg_S, (object)0)); list2.Add(new CodeInstruction(OpCodes.Call, (object)HarmonyHelper.wasFyrusOrHaloGraceSaved)); list2.Add(new CodeInstruction(OpCodes.Brfalse_S, (object)label4)); list2.Add(new CodeInstruction(OpCodes.Ret, (object)null)); if (num5 != -1 && list2.Count > 0) { index = num5; CodeInstructionExtensions.MoveLabelsTo(list[index], list2[0]); } list[index].labels.Add(label4); } list.InsertRange(index, list2); return list; } } public static class SavePatches { private static ManualLogSource Log => WildCardMod.Instance.Log; [HarmonyPatch(typeof(CadaverGrowthAI), "CurePlayer")] [HarmonyWrapSafe] [HarmonyPrefix] public static bool CadaverGrowthAI_CureMore(CadaverGrowthAI __instance) { if (__instance.playerInfections[(uint)GameNetworkManager.Instance.localPlayerController.playerClientId].infected) { __instance.numberOfInfected--; } HUDManager.Instance.cadaverFilter = 0f; SoundManager.Instance.alternateEarsRinging = false; SoundManager.Instance.earsRingingTimer = 0f; return true; } [HarmonyPatch(typeof(DepositItemsDesk), "CollisionDetect")] [HarmonyWrapSafe] [HarmonyPrefix] public static bool DepositItemsDesk_Save() { return !SaveHelper.SaveIfAny(GameNetworkManager.Instance.localPlayerController); } [HarmonyPatch(typeof(PlayerControllerB), "DamagePlayer")] [HarmonyWrapSafe] [HarmonyPrefix] public static bool PlayerControllerB_FyrusSaveDamage(PlayerControllerB __instance, ref Vector3 force) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) bool flag = SaveHelper.SaveIfFyrus(__instance); if (flag) { __instance.externalForceAutoFade += force; } return !flag; } [HarmonyPatch(typeof(PlayerControllerB), "KillPlayer")] [HarmonyWrapSafe] [HarmonyPrefix] public static bool PlayerControllerB_SaveKill(PlayerControllerB __instance, ref Vector3 bodyVelocity, ref bool spawnBody, ref CauseOfDeath causeOfDeath) { //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) if (!SaveHelper.IsSaveable(__instance, out var starSave, out var halo) || (int)causeOfDeath == 0 || !spawnBody) { return true; } if (starSave) { __instance.externalForceAutoFade += bodyVelocity; } else { Log.LogDebug((object)"Running Halo Exhaust from Kill"); halo.ExhaustLocal(__instance, bodyVelocity); } return false; } [HarmonyPatch(typeof(SandWormAI), "EatPlayer")] [HarmonyWrapSafe] [HarmonyPrefix] public static bool SandWormAI_Save(SandWormAI __instance, ref PlayerControllerB playerScript) { try { return !SaveHelper.SaveIfAny(playerScript, (EnemyAI)(object)__instance); } catch (Exception ex) { Log.LogError((object)ex); } return true; } [HarmonyPatch(typeof(BushWolfEnemy), "OnCollideWithPlayer")] [HarmonyWrapSafe] [HarmonyTranspiler] public static IEnumerable<CodeInstruction> BushWolfEnemy_Save(IEnumerable<CodeInstruction> instructions, ILGenerator generator) { //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Expected O, but got Unknown //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Expected O, but got Unknown //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Expected O, but got Unknown //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Expected O, but got Unknown //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Expected O, but got Unknown //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Expected O, but got Unknown //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: 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_02bd: Unknown result type (might be due to invalid IL or missing references) //IL_02c7: Expected O, but got Unknown //IL_02d4: Unknown result type (might be due to invalid IL or missing references) //IL_02de: Expected O, but got Unknown //IL_02ea: Unknown result type (might be due to invalid IL or missing references) //IL_02f4: Expected O, but got Unknown //IL_0302: Unknown result type (might be due to invalid IL or missing references) //IL_030c: Expected O, but got Unknown //IL_0319: Unknown result type (might be due to invalid IL or missing references) //IL_0323: Expected O, but got Unknown //IL_032f: Unknown result type (might be due to invalid IL or missing references) //IL_0339: Expected O, but got Unknown //IL_0346: Unknown result type (might be due to invalid IL or missing references) //IL_0350: Expected O, but got Unknown //IL_035d: Unknown result type (might be due to invalid IL or missing references) //IL_0367: Expected O, but got Unknown //IL_0373: Unknown result type (might be due to invalid IL or missing references) //IL_037d: Expected O, but got Unknown //IL_038b: Unknown result type (might be due to invalid IL or missing references) //IL_0395: Expected O, but got Unknown List<CodeInstruction> list = new List<CodeInstruction>(instructions); for (int i = 0; i < list.Count; i++) { if (!CodeInstructionExtensions.Calls(list[i], HarmonyHelper.onCollision)) { continue; } LocalBuilder localBuilder = generator.DeclareLocal(typeof(PlayerControllerB)); List<CodeInstruction> list2 = new List<CodeInstruction> { new CodeInstruction(OpCodes.Ldarg_S, (object)0), new CodeInstruction(OpCodes.Ldarg_S, (object)1), new CodeInstruction(OpCodes.Ldarg_S, (object)0), new CodeInstruction(OpCodes.Ldfld, (object)HarmonyHelper.foxInKill), new CodeInstruction(OpCodes.Ldc_I4_S, (object)0), new CodeInstruction(OpCodes.Call, (object)HarmonyHelper.collision), new CodeInstruction(OpCodes.Stloc_S, (object)localBuilder.LocalIndex) }; list.InsertRange(i + 1, list2); i += list2.Count + 1; for (int j = i; j < list.Count; j++) { if (!CodeInstructionExtensions.Calls(list[j], HarmonyHelper.collision)) { continue; } list[j] = new CodeInstruction(OpCodes.Ldloc_S, (object)localBuilder.LocalIndex); for (int num = j - 1; num >= 0; num--) { if (list[num].labels.Count != 0) { CodeInstructionExtensions.MoveLabelsTo(list[num], list[j]); int num2 = j - num; list.RemoveRange(num, num2); if (j < i) { i -= num2; } break; } } break; } for (int k = i; k < list.Count; k++) { if (!CodeInstructionExtensions.Calls(list[k], HarmonyHelper.killPlayer)) { continue; } int num3 = -1; Label? label = null; for (int num4 = k; num4 >= 0; num4--) { if (CodeInstructionExtensions.Branches(list[num4], ref label)) { num3 = num4; break; } } if (!label.HasValue) { return list; } Label label2 = generator.DefineLabel(); for (int l = k; l < list.Count; l++) { if (list[l].labels.Contains(label.Value)) { Label label3 = generator.DefineLabel(); List<CodeInstruction> collection = new List<CodeInstruction> { new CodeInstruction(OpCodes.Ldloc_S, (object)localBuilder.LocalIndex), new CodeInstruction(OpCodes.Ldarg_S, (object)0), new CodeInstruction(OpCodes.Call, (object)HarmonyHelper.anySave), new CodeInstruction(OpCodes.Brfalse_S, (object)label3), new CodeInstruction(OpCodes.Ldarg_S, (object)0), new CodeInstruction(OpCodes.Call, (object)HarmonyHelper.foxCancelReel), new CodeInstruction(OpCodes.Ldarg_S, (object)0), new CodeInstruction(OpCodes.Ldc_I4_S, (object)0), new CodeInstruction(OpCodes.Call, (object)HarmonyHelper.switchBehaviourLocal), new CodeInstruction(OpCodes.Br_S, (object)label2) }; list[l].labels.Add(label2); list[num3 + 1].labels.Add(label3); list.InsertRange(num3 + 1, collection); break; } } break; } break; } return list; } [HarmonyPatch(typeof(CadaverGrowthAI), "BurstFromPlayer")] [HarmonyWrapSafe] [HarmonyTranspiler] public static IEnumerable<CodeInstruction> CadaverGrowthAI_Save(IEnumerable<CodeInstruction> instructions, ILGenerator generator) { //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Expected O, but got Unknown //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Expected O, but got Unknown //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Expected O, but got Unknown //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Expected O, but got Unknown //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Expected O, but got Unknown //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Expected O, but got Unknown //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Expected O, but got Unknown //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Expected O, but got Unknown //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Expected O, but got Unknown //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Expected O, but got Unknown //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Expected O, but got Unknown //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Expected O, but got Unknown //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Expected O, but got Unknown //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_0196: 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 List<CodeInstruction> list = new List<CodeInstruction>(instructions); Label? label = default(Label?); for (int i = 0; i < list.Count; i++) { if (!CodeInstructionExtensions.Calls(list[i], HarmonyHelper.bloomBurst)) { continue; } for (int num = i; num >= 0; num--) { if (CodeInstructionExtensions.Branches(list[num], ref label)) { Label label2 = generator.DefineLabel(); Label label3 = generator.DefineLabel(); List<CodeInstruction> collection = new List<CodeInstruction> { new CodeInstruction(OpCodes.Ldarg_S, (object)1), new CodeInstruction(OpCodes.Ldnull, (object)null), new CodeInstruction(OpCodes.Call, (object)HarmonyHelper.anySave), new CodeInstruction(OpCodes.Brfalse_S, (object)label2), new CodeInstruction(OpCodes.Ldarg_S, (object)0), new CodeInstruction(OpCodes.Ldarg_S, (object)1), new CodeInstruction(OpCodes.Ldfld, (object)HarmonyHelper.playerClientId), new CodeInstruction(OpCodes.Conv_I4, (object)null), new CodeInstruction(OpCodes.Call, (object)HarmonyHelper.cadaverCure), new CodeInstruction(OpCodes.Ldarg_S, (object)0), new CodeInstruction(OpCodes.Ldarg_S, (object)1), new CodeInstruction(OpCodes.Ldfld, (object)HarmonyHelper.playerClientId), new CodeInstruction(OpCodes.Conv_I4, (object)null), new CodeInstruction(OpCodes.Call, (object)HarmonyHelper.cadaverCureRPC), new CodeInstruction(OpCodes.Br_S, (object)label3) }; list[num + 1].labels.Add(label2); list[i + 1].labels.Add(label3); list.InsertRange(num + 1, collection); break; } } break; } return list; } [HarmonyPatch(typeof(CaveDwellerAI), "OnCollideWithPlayer")] [HarmonyWrapSafe] [HarmonyTranspiler] public static IEnumerable<CodeInstruction> CaveDwellerAI_HaloSave(IEnumerable<CodeInstruction> instructions, ILGenerator generator, MethodBase original) { //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Expected O, but got Unknown //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Expected O, but got Unknown //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Expected O, but got Unknown List<CodeInstruction> list = new List<CodeInstruction>(instructions); Label? label2 = default(Label?); for (int num = list.Count - 1; num >= 0; num--) { if (CodeInstructionExtensions.Calls(list[num], HarmonyHelper.dwellerKill)) { Label? label = null; for (int i = num; i < list.Count; i++) { if (list[i].labels.Count != 0) { label = generator.DefineLabel(); list[i].labels.Add(label.Value); break; } } for (int num2 = num; num2 >= 0; num2--) { if (CodeInstructionExtensions.Branches(list[num2], ref label2)) { List<CodeInstruction> collection = new List<CodeInstruction> { new CodeInstruction(OpCodes.Ldloc_S, (object)0), new CodeInstruction(OpCodes.Call, (object)HarmonyHelper.haloSave), new CodeInstruction(OpCodes.Brtrue_S, (object)label.Value) }; list.InsertRange(num + 1, collection); break; } } break; } } return list; } [HarmonyPatch(typeof(CentipedeAI), "DamagePlayerOnIntervals")] [HarmonyWrapSafe] [HarmonyTranspiler] public static IEnumerable<CodeInstruction> CentipedeAI_FyrusSave(IEnumerable<CodeInstruction> instructions, ILGenerator generator) { //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Expected O, but got Unknown //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Expected O, but got Unknown //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Expected O, but got Unknown //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Expected O, but got Unknown //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Expected O, but got Unknown List<CodeInstruction> list = new List<CodeInstruction>(instructions); for (int num = list.Count - 1; num >= 0; num--) { if (CodeInstructionExtensions.Calls(list[num], HarmonyHelper.damagePlayer)) { for (int num2 = num; num2 >= 0; num2--) { if (list[num2].labels.Count != 0) { Label label = generator.DefineLabel(); CodeInstruction val = new CodeInstruction(OpCodes.Ldarg_S, (object)0); CodeInstructionExtensions.MoveLabelsTo(list[num2], val); List<CodeInstruction> collection = new List<CodeInstruction> { val, new CodeInstruction(OpCodes.Ldfld, (object)HarmonyHelper.clingPlayer), new CodeInstruction(OpCodes.Ldarg_S, (object)0), new CodeInstruction(OpCodes.Call, (object)HarmonyHelper.wasFyrusOrHaloGraceSaved), new CodeInstruction(OpCodes.Brtrue_S, (object)label) }; list[num + 1].labels.Add(label); list.InsertRange(num2, collection); break; } } break; } } return list; } [HarmonyPatch(typeof(DressGirlAI), "OnCollideWithPlayer")] [HarmonyWrapSafe] [HarmonyTranspiler] public static IEnumerable<CodeInstruction> DressGirlAI_Save(IEnumerable<CodeInstruction> instructions, ILGenerator generator) { //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Expected O, but got Unknown //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Expected O, but got Unknown //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Expected O, but got Unknown //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Expected O, but got Unknown //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Expected O, but got Unknown //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Expected O, but got Unknown //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Expected O, but got Unknown //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Expected O, but got Unknown //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: 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_01df: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Expected O, but got Unknown //IL_01f6: Unknown result type (might be due to invalid IL or missing references) //IL_0200: Expected O, but got Unknown //IL_020e: Unknown result type (might be due to invalid IL or missing references) //IL_0218: Expected O, but got Unknown //IL_0226: Unknown result type (might be due to invalid IL or missing references) //IL_0230: Expected O, but got Unknown //IL_023d: Unknown result type (might be due to invalid IL or missing references) //IL_0247: Expected O, but got Unknown List<CodeInstruction> list = new List<CodeInstruction>(instructions); Label? label2 = default(Label?); for (int num = list.Count - 1; num >= 0; num--) { if (CodeInstructionExtensions.Calls(list[num], HarmonyHelper.killPlayer)) { Label? label = null; for (int num2 = num; num2 >= 0; num2--) { if (CodeInstructionExtensions.Branches(list[num2], ref label2)) { label = generator.DefineLabel(); List<CodeInstruction> list2 = new List<CodeInstruction> { new CodeInstruction(OpCodes.Ldloc_S, (object)0), new CodeInstruction(OpCodes.Ldarg_S, (object)0), new CodeInstruction(OpCodes.Call, (object)HarmonyHelper.anySave), new CodeInstruction(OpCodes.Brtrue_S, (object)label.Value) }; list.InsertRange(num2 + 1, list2); num += list2.Count; break; } } if (!label.HasValue) { return list; } List<CodeInstruction> list3 = new List<CodeInstruction>(); list3.Add(CodeInstructionExtensions.WithLabels(new CodeInstruction(OpCodes.Ldarg_S, (object)0), new Label[1] { label.Value })); list3.Add(new CodeInstruction(OpCodes.Call, (object)HarmonyHelper.ghostStopChase)); list3.Add(new CodeInstruction(OpCodes.Ldarg_S, (object)0)); list3.Add(new CodeInstruction(OpCodes.Ldc_I4_S, (object)0)); list3.Add(new CodeInstruction(OpCodes.Stfld, (object)HarmonyHelper.timesStared)); list3.Add(new CodeInstruction(OpCodes.Ldarg_S, (object)0)); list3.Add(new CodeInstruction(OpCodes.Ldc_I4_S, (object)0)); list3.Add(new CodeInstruction(OpCodes.Stfld, (object)HarmonyHelper.timesSeenByPlayer)); list3.Add(new CodeInstruction(OpCodes.Ldarg_S, (object)0)); list3.Add(new CodeInstruction(OpCodes.Ldc_I4_S, (object)0)); list3.Add(new CodeInstruction(OpCodes.Stfld, (object)HarmonyHelper.couldNotStare)); List<CodeInstruction> collection = list3; list.InsertRange(num + 1, collection); break; } } return list; } [HarmonyPatch(typeof(DressGirlAI), "Update")] [HarmonyWrapSafe] [HarmonyTranspiler] public static IEnumerable<CodeInstruction> DressGirlAI_Switch(IEnumerable<CodeInstruction> instructions, ILGenerator generator) { //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Expected O, but got Unknown //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Expected O, but got Unknown //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Expected O, but got Unknown //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Expected O, but got Unknown //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Expected O, but got Unknown List<CodeInstruction> list = new List<CodeInstruction>(instructions); Label? label = default(Label?); Label? label3 = default(Label?); for (int i = 0; i < list.Count; i++) { if (!CodeInstructionExtensions.Branches(list[i], ref label)) { continue; } for (int j = i; j < list.Count; j++) { if (!list[j].labels.Contains(label.Value)) { continue; } Label label2 = generator.DefineLabel(); list[j].labels.Add(label2); for (int k = i + 1; k < list.Count; k++) { if (CodeInstructionExtensions.Branches(list[k], ref label3)) { list[k].opcode = OpCodes.Brfalse_S; for (int l = k; l < list.Count && !list[l].labels.Remove(label3.Value); l++) { } list[k + 1].labels.Add(label3.Value); List<CodeInstruction> collection = new List<CodeInstruction> { new CodeInstruction(OpCodes.Ldarg_S, (object)0), new CodeInstruction(OpCodes.Ldfld, (object)HarmonyHelper.hauntingPlayer), new CodeInstruction(OpCodes.Ldarg_S, (object)0), new CodeInstruction(OpCodes.Call, (object)HarmonyHelper.wasFyrusOrHaloGraceSaved), new CodeInstruction(OpCodes.Brfalse_S, (object)label2) }; list.InsertRange(k + 1, collection); break; } } break; } break; } return list; } [HarmonyPatch(/*Could not decode attribute arguments.*/)] [HarmonyWrapSafe] [HarmonyTranspiler] public static IEnumerable<CodeInstruction> FlowermanAI_HaloSave(IEnumerable<CodeInstruction> instructions, ILGenerator generator, MethodBase original) { //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Expected O, but got Unknown //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Expected O, but got Unknown //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Expected O, but got Unknown //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Expected O, but got Unknown List<CodeInstruction> list = new List<CodeInstruction>(instructions); Label? label = default(Label?); for (int num = list.Count - 1; num >= 0; num--) { if (CodeInstructionExtensions.Calls(list[num], HarmonyHelper.killPlayer)) { for (int num2 = num; num2 >= 0; num2--) { if (CodeInstructionExtensions.Branches(list[num2], ref label)) { Label label2 = generator.DefineLabel(); for (int i = num2; i < list.Count; i++) { if (list[i].labels.Contains(label.Value)) { list[i].labels.Add(label2); break; } } List<CodeInstruction> collection = new List<CodeInstruction> { new CodeInstruction(OpCodes.Ldloc_S, (object)1), new CodeInstruction(OpCodes.Ldfld, (object)HarmonyHelper.specialAnim), new CodeInstruction(OpCodes.Call, (object)HarmonyHelper.haloSave), new CodeInstruction(OpCodes.Brtrue_S, (object)label2) }; list.InsertRange(num2 + 1, collection); break; } } break; } } return list; } [HarmonyPatch(/*Could not decode attribute arguments.*/)] [HarmonyWrapSafe] [HarmonyTranspiler] public static IEnumerable<CodeInstruction> ForestGiantAI_HaloSave(IEnumerable<CodeInstruction> instructions, ILGenerator generator, MethodBase original) { //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Expected O, but got Unknown //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_009b: 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_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Expected O, but got Unknown //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Expected O, but got Unknown //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Expected O, but got Unknown //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Expected O, but got Unknown //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Expected O, but got Unknown //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_013a: 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_0158: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Expected O, but got Unknown //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Expected O, but got Unknown //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Expected O, but got Unknown //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Expected O, but got Unknown //IL_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Expected O, but got Unknown //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Expected O, but got Unknown //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Expected O, but got Unknown //IL_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_01fc: 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 List<CodeInstruction> list = new List<CodeInstruction>(instructions); FieldInfo field = original.DeclaringType.GetField("playerBeingEaten"); Label? label = default(Label?); for (int i = 0; i < list.Count; i++) { if (!CodeInstructionExtensions.Calls(list[i], HarmonyHelper.killPlayer)) { continue; } for (int num = i; num >= 0; num--) { if (CodeInstructionExtensions.Branches(list[num], ref label)) { Label label2 = generator.DefineLabel(); List<CodeInstruction> collection = new List<CodeInstruction> { new CodeInstruction(OpCodes.Ldarg_S, (object)0), new CodeInstruction(OpCodes.Ldfld, (object)field), new CodeInstruction(OpCodes.Call, (object)HarmonyHelper.haloSave), new CodeInstruction(OpCodes.Brfalse_S, (object)label2), new CodeInstruction(OpCodes.Ldloc_S, (object)1), new CodeInstruction(OpCodes.Call, (object)HarmonyHelper.giantStopKill), new CodeInstruction(OpCodes.Ldloc_S, (object)1), new CodeInstruction(OpCodes.Ldfld, (object)HarmonyHelper.giantPlayerStealth), new CodeInstruction(OpCodes.Ldarg_S, (object)0), new CodeInstruction(OpCodes.Ldfld, (object)field), new CodeInstruction(OpCodes.Ldfld, (object)HarmonyHelper.playerClientId), new CodeInstruction(OpCodes.Conv_I4, (object)null), new CodeInstruction(OpCodes.Ldc_R4, (object)0f), new CodeInstruction(OpCodes.Stelem_R4, (object)null), new CodeInstruction(OpCodes.Ldloc_S, (object)1), new CodeInstruction(OpCodes.Ldc_I4_S, (object)0), new CodeInstruction(OpCodes.Call, (object)HarmonyHelper.switchBehaviour), new CodeInstruction(OpCodes.Ldc_I4_S, (object)0), new CodeInstruction(OpCodes.Ret, (object)null) }; list[num + 1].labels.Add(label2); list.InsertRange(num + 1, collection); break; } } break; } return list; } [HarmonyPatch(typeof(HauntedMaskItem), "FinishAttaching")] [HarmonyWrapSafe] [HarmonyTranspiler] public static IEnumerable<CodeInstruction> HauntedMaskItem_Save(IEnumerable<CodeInstruction> instructions, ILGenerator generator) { //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Expected O, but got Unknown //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_013a: 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_0158: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Expected O, but got Unknown //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Expected O, but got Unknown List<CodeInstruction> list = new List<CodeInstruction>(instructions); Label? label = default(Label?); for (int i = 0; i < list.Count; i++) { if (!CodeInstructionExtensions.Calls(list[i], HarmonyHelper.allowDeath)) { continue; } for (int j = i; j < list.Count; j++) { if (!CodeInstructionExtensions.Branches(list[j], ref label)) { continue; } Label? label2 = null; for (int k = j; k < list.Count; k++) { if (list[k].labels.Contains(label.Value)) { label2 = generator.DefineLabel(); list[j].opcode = OpCodes.Brfalse_S; CodeInstructionExtensions.MoveLabelsTo(list[k], list[j + 1]); list[k].labels.Add(label2.Value); break; } } if (!label2.HasValue) { return list; } List<CodeInstruction> collection = new List<CodeInstruction> { new CodeInstruction(OpCodes.Ldarg_S, (object)0), new CodeInstruction(OpCodes.Ldfld, (object)HarmonyHelper.maskHeldBy), new CodeInstruction(OpCodes.Ldnull, (object)null), new CodeInstruction(OpCodes.Call, (object)HarmonyHelper.anySave), new CodeInstruction(OpCodes.Brfalse_S, (object)label2.Value) }; list.InsertRange(j + 1, collection); break; } break; } return list; } [HarmonyPatch(typeof(JesterAI), "OnCollideWithPlayer")] [HarmonyWrapSafe] [HarmonyTranspiler] public static IEnumerable<CodeInstruction> JesterAI_HaloSave(IEnumerable<CodeInstruction> instructions, ILGenerator generator) { //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Expected O, but got Unknown //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Expected O, but got Unknown //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: 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_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Expected O, but got Unknown //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Expected O, but got Unknown //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Expected O, but got Unknown List<CodeInstruction> list = new List<CodeInstruction>(instructions); for (int i = 0; i < list.Count; i++) { if (!CodeInstructionExtensions.Calls(list[i], HarmonyHelper.jesterKill)) { continue; } for (int num = i; num >= 0; num--) { if (list[num].opcode.Equals(OpCodes.Ret)) { Label label = generator.DefineLabel(); List<CodeInstruction> list2 = new List<CodeInstruction> { new CodeInstruction(OpCodes.Ldloc_S, (object)0), new CodeInstruction(OpCodes.Call, (object)HarmonyHelper.haloSave), new CodeInstruction(OpCodes.Brfalse_S, (object)label), new CodeInstruction(OpCodes.Ldarg_S, (object)0), new CodeInstruction(OpCodes.Ldc_I4_S, (object)0), new CodeInstruction(OpCodes.Call, (object)HarmonyHelper.switchBehaviour), new CodeInstruction(OpCodes.Ret, (object)null) }; CodeInstructionExtensions.MoveLabelsTo(list[num + 1], list2[0]); list[num + 1].labels.Add(label); list.InsertRange(num + 1, list2); break; } } break; } return list; } [HarmonyPatch(/*Could not decode attribute arguments.*/)] [HarmonyWrapSafe] [HarmonyTranspiler] public static IEnumerable<CodeInstruction> MaskedPlayerEnemy_HaloSave(IEnumerable<CodeInstruction> instructions, ILGenerator generator) { //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Expected O, but got Unknown //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Expected O, but got Unknown //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Expected O, but got Unknown //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Expected O, but got Unknown //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Expected O, but got Unknown //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Expected O, but got Unknown //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Expected O, but got Unknown //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Expected O, but got Unknown List<CodeInstruction> list = new List<CodeInstruction>(instructions); for (int i = 0; i < list.Count; i++) { if (!list[i].opcode.Equals(OpCodes.Switch) || !(list[i].operand is Label[] array) || array.Length < 5) { continue; } for (int j = i; j < list.Count; j++) { if (!list[j].labels.Contains(array[4])) { continue; } for (int k = j; k < list.Count; k++) { if (list[k].opcode.Equals(OpCodes.Stfld)) { Label label = generator.DefineLabel(); List<CodeInstruction> collection = new List<CodeInstruction> { new CodeInstruction(OpCodes.Ldloc_S, (object)1), new CodeInstruction(OpCodes.Ldfld, (object)HarmonyHelper.specialAnim), new CodeInstruction(OpCodes.Call, (object)HarmonyHelper.haloSave), new CodeInstruction(OpCodes.Brfalse_S, (object)label), new CodeInstruction(OpCodes.Ldloc_S, (object)1), new CodeInstruction(OpCodes.Callvirt, (object)HarmonyHelper.cancelSpecialAnim), new CodeInstruction(OpCodes.Ldc_I4_0, (object)null), new CodeInstruction(OpCodes.Ret, (object)null) }; list[k + 1].labels.Add(label); list.InsertRange(k + 1, collection); break; } } break; } break; } return list; } [HarmonyPatch(typeof(MouthDogAI), "OnCollideWithPlayer")] [HarmonyWrapSafe] [HarmonyTranspiler] public static IEnumerable<CodeInstruction> MouthDogAI_HaloSave(IEnumerable<CodeInstruction> instructions, ILGenerator generator) { //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Expected O, but got Unknown //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Expected O, but got Unknown //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Expected O, but got Unknown List<CodeInstruction> list = new List<CodeInstruction>(instructions); for (int i = 0; i < list.Count; i++) { if (!CodeInstructionExtensions.Calls(list[i], HarmonyHelper.dogKill)) { continue; } Label? label = null; int num = i; while (num >= 0 && !CodeInstructionExtensions.Branches(list[num], ref label)) { num--; } if (!label.HasValue) { return list; } Label label2 = generator.DefineLabel(); List<CodeInstruction> collection = new List<CodeInstruction> { new CodeInstruction(OpCodes.Ldloc_S, (object)0), new CodeInstruction(OpCodes.Call, (object)HarmonyHelper.haloSave), new CodeInstruction(OpCodes.Brtrue_S, (object)label2) }; for (int j = i; j < list.Count; j++) { if (list[j].labels.Contains(label.Value)) { list[list.Count - 1].labels.Add(label2); list.InsertRange(j, collection); break; } } break; } return list; } [HarmonyPatch(typeof(PlayerControllerB), "DamagePlayer")] [HarmonyWrapSafe] [HarmonyTranspiler] public static IEnumerable<CodeInstruction> PlayerControllerB_HaloSaveDamage(IEnumerable<CodeInstruction> instructions, ILGenerator generator) { //IL_031f: Unknown result type (might be due to invalid IL or missing references) //IL_0329: Expected O, but got Unknown //IL_033c: Unknown result type (might be due to invalid IL or missing references) //IL_0346: Expected O, but got Unknown //IL_0353: Unknown result type (might be due to invalid IL or missing references) //IL_035d: Expected O, but got Unknown //IL_036f: Unknown result type (might be due to invalid IL or missing references) //IL_0379: Expected O, but got Unknown //IL_03e6: Unknown result type (might be due to invalid IL or missing references) //IL_03ed: Expected O, but got Unknown //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Expected O, but got Unknown //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Expected O, but got Unknown //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Expected O, but got Unknown //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Expected O, but got Unknown //IL_01e8: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: 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 //IL_0484: Unknown result type (might be due to invalid IL or missing references) //IL_048e: Expected O, but got Unknown //IL_049c: Unknown result type (might be due to invalid IL or missing references) //IL_04a6: Expected O, but got Unknown //IL_04b3: Unknown result type (might be due to invalid IL or missing references) //IL_04bd: Expected O, but got Unknown //IL_04cb: Unknown result type (might be due to invalid IL or missing references) //IL_04d5: Expected O, but got Unknown //IL_04de: Unknown result type (might be due to invalid IL or missing references) //IL_04e8: Expected O, but got Unknown //IL_04fb: Unknown result type (might be due to invalid IL or missing references) //IL_0505: Expected O, but got Unknown //IL_053f: Unknown result type (might be due to invalid IL or missing references) //IL_0549: Expected O, but got Unknown //IL_0558: Unknown result type (might be due to invalid IL or missing references) //IL_0562: Expected O, but got Unknown //IL_0570: Unknown result type (might be due to invalid IL or missing references) //IL_057a: Expected O, but got Unknown //IL_058d: Unknown result type (might be due to invalid IL or missing references) //IL_0597: Expected O, but got Unknown //IL_05c1: Unknown result type (might be due to invalid IL or missing references) //IL_05e3: Expected O, but got Unknown //IL_05f7: Unknown result type (might be due to invalid IL or missing references) //IL_0601: Expected O, but got Unknown //IL_086a: Unknown result type (might be due to invalid IL or missing references) //IL_0874: Expected O, but got Unknown //IL_0882: Unknown result type (might be due to invalid IL or missing references) //IL_088c: Expected O, but got Unknown //IL_073e: Unknown result type (might be due to invalid IL or missing references) //IL_0748: Expected O, but got Unknown //IL_0754: Unknown result type (might be due to invalid IL or missing references) //IL_075e: Expected O, but got Unknown //IL_076c: Unknown result type (might be due to invalid IL or missing references) //IL_0776: Expected O, but got Unknown //IL_077e: Unknown result type (might be due to invalid IL or missing references) //IL_0788: Expected O, but got Unknown //IL_0795: Unknown result type (might be due to invalid IL or missing references) //IL_079f: Expected O, but got Unknown //IL_07a7: Unknown result type (might be due to invalid IL or missing references) //IL_07b1: Expected O, but got Unknown List<CodeInstruction> list = new List<CodeInstruction>(instructions); LocalBuilder localBuilder = null; LocalBuilder localBuilder2 = null; Label? label = null; Label? label2 = null; Label? label3 = null; Label? label4 = default(Label?); for (int i = 0; i < list.Count; i++) { if (i - 3 < 0 || i + 6 >= list.Count) { continue; } if (CodeInstructionExtensions.Calls(list[i], HarmonyHelper.allowDeath)) { Log.LogDebug((object)"Found PlayerControllerB.AllowPlayerDeath, replacing next branch with setting new locals"); for (int j = i; j < list.Count; j++) { if (!CodeInstructionExtensions.Branches(list[j - 1], ref label4) || !list[j].opcode.Equals(OpCodes.Ret)) { continue; } for (int k = j; k < list.Count; k++) { if (CodeInstructionExtensions.Branches(list[k], ref label)) { localBuilder = generator.DeclareLocal(typeof(bool)); localBuilder2 = generator.DeclareLocal(typeof(bool)); list[k] = new CodeInstruction(OpCodes.Cgt, (object)null); List<CodeInstruction> list2 = new List<CodeInstruction>(); list2.Add(new CodeInstruction(OpCodes.Ldc_I4_S, (object)0)); list2.Add(new CodeInstruction(OpCodes.Ceq, (object)null)); list2.Add(new CodeInstruction(OpCodes.Stloc_S, (object)localBuilder.LocalIndex)); list2.AddRange(HarmonyHelper.DebugLoadFromThis<int>("Starting health", OpCodes.Ldfld, HarmonyHelper.playerHealth, Array.Empty<Label>())); list2.AddRange(HarmonyHelper.DebugLoad<int>("Damage", OpCodes.Ldarg_S, 1, Array.Empty<Label>())); list2.AddRange(HarmonyHelper.DebugLoad<bool>("Is Overkill?", OpCodes.Ldloc_S, localBuilder.LocalIndex, Array.Empty<Label>())); list2.Add(new CodeInstruction(OpCodes.Ldc_I4_S, (object)0)); list2.Add(new CodeInstruction(OpCodes.Stloc_S, (object)localBuilder2.LocalIndex)); list.InsertRange(k + 1, list2); i = k + list2.Count + 1; break; } } if (localBuilder == null || !label.HasValue) { Log.LogWarning((object)"Unable to apply transpiler to PlayerControllerB.DamagePlayer! Halo save will not work properly!"); return list; } break; } } if (localBuilder == null || !label.HasValue) { continue; } if (!label2.HasValue) { CodeInstructionExtensions.Branches(list[i], ref label2); } else if (!label3.HasValue && CodeInstructionExtensions.Branches(list[i], ref label3)) { Log.LogDebug((object)"Successfully set locals, adding overkill checks"); List<CodeInstruction> list3 = new List<CodeInstruction> { new CodeInstruction(OpCodes.Ldloc_S, (object)localBuilder.LocalIndex), new CodeInstruction(OpCodes.Brfalse_S, (object)label.Value), new CodeInstruction(OpCodes.Ldc_I4_S, (object)1), new CodeInstruction(OpCodes.Stloc_S, (object)localBuilder2.LocalIndex) }; list3.AddRange(HarmonyHelper.DebugLoad<bool>("Vanilla critical injury, setting health override to", OpCodes.Ldloc_S, localBuilder2.LocalIndex, Array.Empty<Label>())); list.InsertRange(i + 1, list3); i += list3.Count + 1; Label label5 = generator.DefineLabel(); Label label6 = generator.DefineLabel(); Label label7 = generator.DefineLabel(); CodeInstruction val = new CodeInstruction(OpCodes.Ldloc_S, (object)localBuilder.LocalIndex); for (int l = i; l < list.Count; l++) { if (CodeInstructionExtensions.Branches(list[l], ref label4)) { i = l; } if (list[l].labels.Count >= 3) { Log.LogDebug((object)"Moving first if statement's branch destinations to the new else if statement"); CodeInstructionExtensions.MoveLabelsTo(list[l], val); break; } } List<CodeInstruction> list4 = new List<CodeInstruction>(); list4.Add(val); list4.Add(new CodeInstruction(OpCodes.Brfalse_S, (object)label5)); list4.Add(new CodeInstruction(OpCodes.Ldarg_S, (object)0)); list4.Add(new CodeInstruction(OpCodes.Call, (object)HarmonyHelper.haloSave)); list4.Add(new CodeInstruction(OpCodes.Ldc_I4_S, (object)0)); list4.Add(new CodeInstruction(OpCodes.Ceq, (object)null)); list4.Add(new CodeInstruction(OpCodes.Stloc_S, (object