using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using Extensions; using HarmonyLib; using Items_Mod_For_Gamble.ModdedItem; using Mirror; using TryConnect; using UnityEngine; using UnityEngine.SceneManagement; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyVersion("0.0.0.0")] [HarmonyPatch] public static class NetworkManagerRegistrationPatch { private static FieldInfo assetIdField = typeof(NetworkIdentity).GetField("_assetId", BindingFlags.Instance | BindingFlags.NonPublic); private static List registeredPrefabs = new List(); [HarmonyPrefix] [HarmonyPatch(typeof(CustomNetworkManager), "OnStopServer")] public static void OnStopServer(CustomNetworkManager __instance) { Debug.Log((object)"[Armory] OnStopServer - Clearing custom prefabs from NetworkManager"); for (int num = ((NetworkManager)__instance).spawnPrefabs.Count - 1; num >= 0; num--) { if (registeredPrefabs.Contains(((NetworkManager)__instance).spawnPrefabs[num])) { ((NetworkManager)__instance).spawnPrefabs.RemoveAt(num); } } registeredPrefabs.Clear(); } [HarmonyPrefix] [HarmonyPatch(typeof(CustomNetworkManager), "OnStopClient")] public static void OnStopClient(CustomNetworkManager __instance) { Debug.Log((object)"[Armory] OnStopClient - Clearing custom prefabs from NetworkManager"); for (int num = ((NetworkManager)__instance).spawnPrefabs.Count - 1; num >= 0; num--) { if (registeredPrefabs.Contains(((NetworkManager)__instance).spawnPrefabs[num])) { ((NetworkManager)__instance).spawnPrefabs.RemoveAt(num); } } registeredPrefabs.Clear(); } [HarmonyPrefix] [HarmonyPatch(typeof(CustomNetworkManager), "OnStartServer")] public static void OnStartServer(CustomNetworkManager __instance) { RegisterAllCustomPrefabs(__instance); } [HarmonyPrefix] [HarmonyPatch(typeof(CustomNetworkManager), "OnClientConnect")] public static void OnClientConnect(CustomNetworkManager __instance) { RegisterAllCustomPrefabs(__instance); } [HarmonyPrefix] [HarmonyPatch(typeof(NetworkManager), "StartHost")] public static void OnStartHost(NetworkManager __instance) { CustomNetworkManager val = (CustomNetworkManager)(object)((__instance is CustomNetworkManager) ? __instance : null); if (val != null) { RegisterAllCustomPrefabs(val); } } private static void RegisterAllCustomPrefabs(CustomNetworkManager networkManager) { if ((Object)(object)networkManager == (Object)null) { return; } Debug.Log((object)"[Armory] Registering custom prefabs with NetworkManager"); for (int num = ((NetworkManager)networkManager).spawnPrefabs.Count - 1; num >= 0; num--) { if ((Object)(object)((NetworkManager)networkManager).spawnPrefabs[num] == (Object)null) { ((NetworkManager)networkManager).spawnPrefabs.RemoveAt(num); } } TryConnectRegisteredItemInfo[] registeredItems = TryConnectApi.GetRegisteredItems(); int num2 = 0; TryConnectRegisteredItemInfo[] array = registeredItems; SpawnableSO val2 = default(SpawnableSO); foreach (TryConnectRegisteredItemInfo val in array) { if (TryConnectApi.TryGetCustomSpawnable(val.SpawnableId, ref val2) && (Object)(object)val2 != (Object)null && (Object)(object)val2.prefab != (Object)null) { uint num3 = ArmoryPlugin.GenerateDeterministicAssetId(val.OwnerGuid, val.Key); NetworkIdentity component = val2.prefab.GetComponent(); if ((Object)(object)component != (Object)null && assetIdField != null && (uint)assetIdField.GetValue(component) == 0) { assetIdField.SetValue(component, num3); Debug.Log((object)$"[Armory] Set assetId for {val.Key} to {num3}"); } if (!((NetworkManager)networkManager).spawnPrefabs.Contains(val2.prefab)) { ((NetworkManager)networkManager).spawnPrefabs.Add(val2.prefab); registeredPrefabs.Add(val2.prefab); Debug.Log((object)("[Armory] Added " + val.Key + " to NetworkManager spawnPrefabs")); num2++; } NetworkClient.RegisterPrefab(val2.prefab, num3); } } if (num2 > 0) { Debug.Log((object)$"[Armory] Registered {num2} custom prefabs with NetworkManager (total: {((NetworkManager)networkManager).spawnPrefabs.Count})"); } } } [HarmonyPatch(typeof(Coordinator), "ServerThrow")] public static class CoordinatorThrowPatch { [HarmonyPostfix] private static void Postfix(Coordinator __instance) { string text = ((Object)((Component)__instance).gameObject).name.ToLower(); if (text.Contains("voodoo doll")) { AccessTools.Field(typeof(Coordinator), "_isBreakable").SetValue(__instance, false); } } } [HarmonyPatch(typeof(Drink), "ServerThrow")] public static class DrinkThrowPatch { [HarmonyPostfix] private static void Postfix(Drink __instance) { string text = ((Object)((Component)__instance).gameObject).name.ToLower(); if (text.Contains("blind luck")) { AccessTools.Field(typeof(Drink), "_isBreakable").SetValue(__instance, false); } } } [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInPlugin("Armory-Mod", "Armory", "0.3.2")] public sealed class ArmoryPlugin : BaseUnityPlugin { [HarmonyPatch] public static class BlockTicketFizzFromShopPatch { [HarmonyPostfix] [HarmonyPatch] public static void Postfix(GameObject fallbackPrefab, ref GameObject __result) { if ((Object)(object)__result != (Object)null && ((Object)__result).name.Contains("Ticket Fizz")) { Debug.Log((object)"[Armory] Blocked Ticket Fizz from shop"); __result = fallbackPrefab; } } private static MethodBase TargetMethod() { Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); foreach (Assembly assembly in assemblies) { if (assembly.GetName().Name.Contains("TryConnect")) { Type type = assembly.GetType("TryConnect.RuntimeItemRegistry"); if (type != null) { return AccessTools.Method(type, "GetShopReplacement", (Type[])null, (Type[])null); } } } return null; } } [HarmonyPatch] public static class BlockLoadedChipFromShopPatch { [HarmonyPostfix] [HarmonyPatch] public static void Postfix(GameObject fallbackPrefab, ref GameObject __result) { if ((Object)(object)__result != (Object)null && ((Object)__result).name.Contains("Loaded Chip")) { Debug.Log((object)"[Armory] Blocked Loaded Chip from shop"); __result = fallbackPrefab; } } private static MethodBase TargetMethod() { Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); foreach (Assembly assembly in assemblies) { if (assembly.GetName().Name.Contains("TryConnect")) { Type type = assembly.GetType("TryConnect.RuntimeItemRegistry"); if (type != null) { return AccessTools.Method(type, "GetShopReplacement", (Type[])null, (Type[])null); } } } return null; } } [HarmonyPatch] public static class BlockTicketFizzAndLoadedChipSpawnPatch { [HarmonyPrefix] [HarmonyPatch] public static bool Prefix(GameObject prefab, ref bool __result) { if ((Object)(object)prefab != (Object)null && (((Object)prefab).name.Contains("Ticket Fizz") || ((Object)prefab).name.Contains("Loaded Chip"))) { Debug.Log((object)("[Armory] Blocked spawning of " + ((Object)prefab).name)); __result = false; return false; } return true; } private static MethodBase TargetMethod() { Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); foreach (Assembly assembly in assemblies) { if (assembly.GetName().Name.Contains("TryConnect")) { Type type = assembly.GetType("TryConnect.RuntimeItemRegistry"); if (type != null) { return AccessTools.Method(type, "TrySpawnRegisteredPrefab", (Type[])null, (Type[])null); } } } return null; } } internal static ConfigEntry enableCursedCoin; internal static ConfigEntry enablePills; internal static ConfigEntry enableBlind; internal static ConfigEntry enableDoll; internal static ConfigEntry enableTaxes; internal static ConfigEntry enableEnergy; internal static ConfigEntry enableScroll; internal static ConfigEntry enableKey; internal static uint GenerateDeterministicAssetId(string ownerGuid, string key) { string text = ownerGuid + ":" + key; uint num = 5381u; string text2 = text; foreach (char c in text2) { num = (num << 5) + num + c; } return (num == 0) ? 1u : num; } private void Awake() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected O, but got Unknown //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: Unknown result type (might be due to invalid IL or missing references) //IL_01cb: Expected O, but got Unknown //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_0209: Unknown result type (might be due to invalid IL or missing references) //IL_0215: Unknown result type (might be due to invalid IL or missing references) //IL_0221: Unknown result type (might be due to invalid IL or missing references) //IL_022d: Unknown result type (might be due to invalid IL or missing references) //IL_0239: Unknown result type (might be due to invalid IL or missing references) //IL_0245: Unknown result type (might be due to invalid IL or missing references) //IL_0246: Unknown result type (might be due to invalid IL or missing references) //IL_0250: Unknown result type (might be due to invalid IL or missing references) //IL_025b: Unknown result type (might be due to invalid IL or missing references) //IL_026b: Unknown result type (might be due to invalid IL or missing references) //IL_0276: Unknown result type (might be due to invalid IL or missing references) //IL_027e: Unknown result type (might be due to invalid IL or missing references) //IL_0286: Unknown result type (might be due to invalid IL or missing references) //IL_028e: Unknown result type (might be due to invalid IL or missing references) //IL_0297: Unknown result type (might be due to invalid IL or missing references) //IL_029f: Unknown result type (might be due to invalid IL or missing references) //IL_02a9: Expected O, but got Unknown //IL_02ac: Unknown result type (might be due to invalid IL or missing references) //IL_02b1: Unknown result type (might be due to invalid IL or missing references) //IL_02be: Unknown result type (might be due to invalid IL or missing references) //IL_02e5: Unknown result type (might be due to invalid IL or missing references) //IL_02ea: Unknown result type (might be due to invalid IL or missing references) //IL_02f6: Unknown result type (might be due to invalid IL or missing references) //IL_0302: Unknown result type (might be due to invalid IL or missing references) //IL_030e: Unknown result type (might be due to invalid IL or missing references) //IL_031a: Unknown result type (might be due to invalid IL or missing references) //IL_0326: Unknown result type (might be due to invalid IL or missing references) //IL_0327: Unknown result type (might be due to invalid IL or missing references) //IL_0331: Unknown result type (might be due to invalid IL or missing references) //IL_033c: Unknown result type (might be due to invalid IL or missing references) //IL_034c: Unknown result type (might be due to invalid IL or missing references) //IL_0357: Unknown result type (might be due to invalid IL or missing references) //IL_035f: Unknown result type (might be due to invalid IL or missing references) //IL_0367: Unknown result type (might be due to invalid IL or missing references) //IL_036f: Unknown result type (might be due to invalid IL or missing references) //IL_0378: Unknown result type (might be due to invalid IL or missing references) //IL_0381: Unknown result type (might be due to invalid IL or missing references) //IL_038b: Expected O, but got Unknown //IL_038e: Unknown result type (might be due to invalid IL or missing references) //IL_0393: Unknown result type (might be due to invalid IL or missing references) //IL_03a0: Unknown result type (might be due to invalid IL or missing references) //IL_03c7: Unknown result type (might be due to invalid IL or missing references) //IL_03cc: Unknown result type (might be due to invalid IL or missing references) //IL_03d8: Unknown result type (might be due to invalid IL or missing references) //IL_03e4: Unknown result type (might be due to invalid IL or missing references) //IL_03f0: Unknown result type (might be due to invalid IL or missing references) //IL_03fc: Unknown result type (might be due to invalid IL or missing references) //IL_0408: Unknown result type (might be due to invalid IL or missing references) //IL_0409: Unknown result type (might be due to invalid IL or missing references) //IL_0413: Unknown result type (might be due to invalid IL or missing references) //IL_041e: Unknown result type (might be due to invalid IL or missing references) //IL_042e: Unknown result type (might be due to invalid IL or missing references) //IL_0439: Unknown result type (might be due to invalid IL or missing references) //IL_0441: Unknown result type (might be due to invalid IL or missing references) //IL_0449: Unknown result type (might be due to invalid IL or missing references) //IL_0451: Unknown result type (might be due to invalid IL or missing references) //IL_045a: Unknown result type (might be due to invalid IL or missing references) //IL_0463: Unknown result type (might be due to invalid IL or missing references) //IL_046d: Expected O, but got Unknown //IL_0470: Unknown result type (might be due to invalid IL or missing references) //IL_0475: Unknown result type (might be due to invalid IL or missing references) //IL_0482: Unknown result type (might be due to invalid IL or missing references) //IL_04a9: Unknown result type (might be due to invalid IL or missing references) //IL_04ae: Unknown result type (might be due to invalid IL or missing references) //IL_04ba: Unknown result type (might be due to invalid IL or missing references) //IL_04c6: Unknown result type (might be due to invalid IL or missing references) //IL_04d2: Unknown result type (might be due to invalid IL or missing references) //IL_04de: Unknown result type (might be due to invalid IL or missing references) //IL_04ea: Unknown result type (might be due to invalid IL or missing references) //IL_04eb: Unknown result type (might be due to invalid IL or missing references) //IL_04f5: Unknown result type (might be due to invalid IL or missing references) //IL_0500: Unknown result type (might be due to invalid IL or missing references) //IL_0510: Unknown result type (might be due to invalid IL or missing references) //IL_051b: Unknown result type (might be due to invalid IL or missing references) //IL_0523: Unknown result type (might be due to invalid IL or missing references) //IL_052b: Unknown result type (might be due to invalid IL or missing references) //IL_0533: Unknown result type (might be due to invalid IL or missing references) //IL_053c: Unknown result type (might be due to invalid IL or missing references) //IL_0544: Unknown result type (might be due to invalid IL or missing references) //IL_054e: Expected O, but got Unknown //IL_0551: Unknown result type (might be due to invalid IL or missing references) //IL_0556: Unknown result type (might be due to invalid IL or missing references) //IL_0563: Unknown result type (might be due to invalid IL or missing references) //IL_058a: Unknown result type (might be due to invalid IL or missing references) //IL_058f: Unknown result type (might be due to invalid IL or missing references) //IL_059b: Unknown result type (might be due to invalid IL or missing references) //IL_05a7: Unknown result type (might be due to invalid IL or missing references) //IL_05b3: Unknown result type (might be due to invalid IL or missing references) //IL_05bf: Unknown result type (might be due to invalid IL or missing references) //IL_05cb: Unknown result type (might be due to invalid IL or missing references) //IL_05cc: Unknown result type (might be due to invalid IL or missing references) //IL_05d6: Unknown result type (might be due to invalid IL or missing references) //IL_05e1: Unknown result type (might be due to invalid IL or missing references) //IL_05f1: Unknown result type (might be due to invalid IL or missing references) //IL_05fc: Unknown result type (might be due to invalid IL or missing references) //IL_060c: Unknown result type (might be due to invalid IL or missing references) //IL_0617: Unknown result type (might be due to invalid IL or missing references) //IL_061f: Unknown result type (might be due to invalid IL or missing references) //IL_0627: Unknown result type (might be due to invalid IL or missing references) //IL_062f: Unknown result type (might be due to invalid IL or missing references) //IL_0638: Unknown result type (might be due to invalid IL or missing references) //IL_0641: Unknown result type (might be due to invalid IL or missing references) //IL_064b: Expected O, but got Unknown //IL_064e: Unknown result type (might be due to invalid IL or missing references) //IL_0653: Unknown result type (might be due to invalid IL or missing references) //IL_0660: Unknown result type (might be due to invalid IL or missing references) //IL_0687: Unknown result type (might be due to invalid IL or missing references) //IL_068c: Unknown result type (might be due to invalid IL or missing references) //IL_0698: Unknown result type (might be due to invalid IL or missing references) //IL_06a4: Unknown result type (might be due to invalid IL or missing references) //IL_06b0: Unknown result type (might be due to invalid IL or missing references) //IL_06bc: Unknown result type (might be due to invalid IL or missing references) //IL_06c8: Unknown result type (might be due to invalid IL or missing references) //IL_06d8: Unknown result type (might be due to invalid IL or missing references) //IL_06e3: Unknown result type (might be due to invalid IL or missing references) //IL_06eb: Unknown result type (might be due to invalid IL or missing references) //IL_06f3: Unknown result type (might be due to invalid IL or missing references) //IL_06fb: Unknown result type (might be due to invalid IL or missing references) //IL_0704: Unknown result type (might be due to invalid IL or missing references) //IL_070c: Unknown result type (might be due to invalid IL or missing references) //IL_0716: Expected O, but got Unknown //IL_0719: Unknown result type (might be due to invalid IL or missing references) //IL_071e: Unknown result type (might be due to invalid IL or missing references) //IL_072b: Unknown result type (might be due to invalid IL or missing references) //IL_0752: Unknown result type (might be due to invalid IL or missing references) //IL_0757: Unknown result type (might be due to invalid IL or missing references) //IL_0763: Unknown result type (might be due to invalid IL or missing references) //IL_076f: Unknown result type (might be due to invalid IL or missing references) //IL_077b: Unknown result type (might be due to invalid IL or missing references) //IL_0787: Unknown result type (might be due to invalid IL or missing references) //IL_0793: Unknown result type (might be due to invalid IL or missing references) //IL_0794: Unknown result type (might be due to invalid IL or missing references) //IL_079e: Unknown result type (might be due to invalid IL or missing references) //IL_07a9: Unknown result type (might be due to invalid IL or missing references) //IL_07b9: Unknown result type (might be due to invalid IL or missing references) //IL_07c4: Unknown result type (might be due to invalid IL or missing references) //IL_07cc: Unknown result type (might be due to invalid IL or missing references) //IL_07d4: Unknown result type (might be due to invalid IL or missing references) //IL_07dc: Unknown result type (might be due to invalid IL or missing references) //IL_07e5: Unknown result type (might be due to invalid IL or missing references) //IL_07ed: Unknown result type (might be due to invalid IL or missing references) //IL_07f7: Expected O, but got Unknown //IL_07fa: Unknown result type (might be due to invalid IL or missing references) //IL_07ff: Unknown result type (might be due to invalid IL or missing references) //IL_080c: Unknown result type (might be due to invalid IL or missing references) Debug.Log((object)"[Armory] Loading Items"); DisableUnwantedTryConnectItems(); Harmony val = new Harmony("armory.mod"); val.PatchAll(); Debug.Log((object)"[Armory] Harmony patches applied"); enableCursedCoin = ((BaseUnityPlugin)this).Config.Bind("Custom Items", "Cursed Coin", true, "Enable \"cursed coin\" to show up in shop"); enablePills = ((BaseUnityPlugin)this).Config.Bind("Custom Items", "Experimental Pills", true, "Enable \"experimental pills\" to show up in the shop"); enableBlind = ((BaseUnityPlugin)this).Config.Bind("Custom Items", "Blind Luck", true, "Enable \"Blind Luck\" to show up in the shop"); enableDoll = ((BaseUnityPlugin)this).Config.Bind("Custom Items", "Voodoo Doll", true, "Enable \"Voodoo Doll\" to show up in the shop"); enableTaxes = ((BaseUnityPlugin)this).Config.Bind("Custom Items", "Tax Fraud", true, "Enable \"Tax Fraud\" to show up in the shop"); enableEnergy = ((BaseUnityPlugin)this).Config.Bind("Custom Items", "Energy Drink", true, "Enable \"Energy Drink\" to show up in the shop"); enableScroll = ((BaseUnityPlugin)this).Config.Bind("Custom Items", "Debt Contract", true, "Enable \"Debt Contract\" to show up in the shop"); enableKey = ((BaseUnityPlugin)this).Config.Bind("Custom Items", "R Key", true, "Enable \"R Key\" to show up in the shop"); if (enableCursedCoin.Value) { TryConnectBundledItemRegistration val2 = new TryConnectBundledItemRegistration { Key = "cursed_coin", DisplayName = "Cursed Coin", Description = "Works like a golden chip but with a 25% chance to lose 1.5x max bet\n3 Uses", BundlePath = "armory.cursed_coin", VisualPrefabName = "cursed_coin", VisualLocalScale = Vector3.one * 7.5f, ApplyVisualColor = false, ApplyTint = false, ReplaceColliders = true, ReplacementChancePercent = 40, ExtraBasePrice = 1, ExtraFloorPrice = 1 }; TryConnectRegistrationResult val3 = TryConnectApi.RegisterBundledCustomItem((BaseUnityPlugin)(object)this, val2); ((BaseUnityPlugin)this).Logger.LogInfo((object)$"TryConnect register result for cursed_coin: {val3}"); } if (enablePills.Value) { TryConnectBundledItemRegistration val4 = new TryConnectBundledItemRegistration { Key = "exp_pills", DisplayName = "Experimental Pills", Description = "70% to gain a body part\n30% to lose a body part", BundlePath = "armory.pills", VisualPrefabName = "pills", VisualLocalScale = Vector3.one * 0.32f, VisualLocalEulerAngles = new Vector3(0f, -180f, 0f), ApplyVisualColor = false, ApplyTint = false, ReplaceColliders = true, ReplacementChancePercent = 25, ExtraBasePrice = 4, ExtraFloorPrice = -1 }; TryConnectRegistrationResult val5 = TryConnectApi.RegisterBundledCustomItem((BaseUnityPlugin)(object)this, val4); ((BaseUnityPlugin)this).Logger.LogInfo((object)$"TryConnect register result for exp_pills: {val5}"); } if (enableBlind.Value) { TryConnectBundledItemRegistration val6 = new TryConnectBundledItemRegistration { Key = "blind_eyes", DisplayName = "Blind Luck", Description = "Lose both your eyes\nGain bonus income for the day", BundlePath = "armory.scooper", VisualPrefabName = "scooper", VisualLocalScale = Vector3.one * 0.13f, VisualLocalEulerAngles = new Vector3(-90f, 0f, 180f), ApplyVisualColor = false, ApplyTint = false, ReplaceColliders = true, ReplacementChancePercent = 35, ExtraBasePrice = -3, ExtraFloorPrice = 0 }; TryConnectRegistrationResult val7 = TryConnectApi.RegisterBundledCustomItem((BaseUnityPlugin)(object)this, val6); ((BaseUnityPlugin)this).Logger.LogInfo((object)$"TryConnect register result for blind_eyes: {val7}"); } if (enableDoll.Value) { TryConnectBundledItemRegistration val8 = new TryConnectBundledItemRegistration { Key = "voodoo_doll", DisplayName = "Voodoo Doll", Description = "80% to lose all body parts\n20% to earn quota", BundlePath = "armory.doll", VisualPrefabName = "doll", VisualLocalScale = Vector3.one * 0.15f, VisualLocalEulerAngles = new Vector3(0f, -90f, 0f), ApplyVisualColor = false, ApplyTint = false, ReplaceColliders = true, ReplacementChancePercent = 45, ExtraBasePrice = -3, ExtraFloorPrice = -1 }; TryConnectRegistrationResult val9 = TryConnectApi.RegisterBundledCustomItem((BaseUnityPlugin)(object)this, val8); ((BaseUnityPlugin)this).Logger.LogInfo((object)$"TryConnect register result for voodoo_doll: {val9}"); } if (enableTaxes.Value) { TryConnectBundledItemRegistration val10 = new TryConnectBundledItemRegistration { Key = "taxes", DisplayName = "Tax Fraud", Description = "Decrease quota by 20%\n5% chance to get audited", BundlePath = "armory.taxes", VisualPrefabName = "taxes", VisualLocalScale = Vector3.one * 0.015f, VisualLocalEulerAngles = new Vector3(50f, 180f, -180f), ApplyVisualColor = false, ApplyTint = false, ReplaceColliders = true, ReplacementChancePercent = 25, ExtraBasePrice = 1, ExtraFloorPrice = 3 }; TryConnectRegistrationResult val11 = TryConnectApi.RegisterBundledCustomItem((BaseUnityPlugin)(object)this, val10); ((BaseUnityPlugin)this).Logger.LogInfo((object)$"TryConnect register result for taxes: {val11}"); } if (enableTaxes.Value) { TryConnectBundledItemRegistration val12 = new TryConnectBundledItemRegistration { Key = "energy_drink", DisplayName = "Energy Drink", Description = "Makes wheels on the floor spin 3x as fast for 90 seconds", BundlePath = "armory.energy_drink", VisualPrefabName = "energy_drink", VisualLocalScale = Vector3.one * 0.18f, VisualLocalEulerAngles = new Vector3(-90f, -90f, 0f), VisualLocalPosition = new Vector3(0f, -0.3f, 0f), ApplyVisualColor = false, ApplyTint = false, ReplaceColliders = true, ReplacementChancePercent = 45, ExtraBasePrice = -2, ExtraFloorPrice = -1 }; TryConnectRegistrationResult val13 = TryConnectApi.RegisterBundledCustomItem((BaseUnityPlugin)(object)this, val12); ((BaseUnityPlugin)this).Logger.LogInfo((object)$"TryConnect register result for energy drink: {val13}"); } if (enableScroll.Value) { TryConnectBundledItemRegistration val14 = new TryConnectBundledItemRegistration { Key = "scroll", DisplayName = "Debt Contract", Description = "Instantly earn 25% of quota\nPay it back tomorrow with interest", BundlePath = "armory.scroll", VisualPrefabName = "scroll", VisualLocalScale = new Vector3(0.8f, 0.8f, 1.15f), ApplyVisualColor = false, ApplyTint = false, ReplaceColliders = true, ReplacementChancePercent = 35, ExtraBasePrice = -1, ExtraFloorPrice = 0 }; TryConnectRegistrationResult val15 = TryConnectApi.RegisterBundledCustomItem((BaseUnityPlugin)(object)this, val14); ((BaseUnityPlugin)this).Logger.LogInfo((object)$"TryConnect register result for debt contract: {val15}"); } if (enableKey.Value) { TryConnectBundledItemRegistration val16 = new TryConnectBundledItemRegistration { Key = "r_key", DisplayName = "R Key", Description = "Restart the day with\n20% less\nCash and Tickets", BundlePath = "armory.r_key", VisualPrefabName = "rKey", VisualLocalScale = Vector3.one * 1.25f, VisualLocalEulerAngles = new Vector3(-40f, -180f, 0f), ApplyVisualColor = false, ApplyTint = false, ReplaceColliders = true, ReplacementChancePercent = 20, ExtraBasePrice = -1, ExtraFloorPrice = 2 }; TryConnectRegistrationResult val17 = TryConnectApi.RegisterBundledCustomItem((BaseUnityPlugin)(object)this, val16); ((BaseUnityPlugin)this).Logger.LogInfo((object)$"TryConnect register result for r key: {val17}"); } } private void DisableUnwantedTryConnectItems() { try { string path = Path.Combine(Paths.ConfigPath, "com.Try-4646.TryConnect.cfg"); if (!File.Exists(path)) { return; } Debug.Log((object)"[Armory] Found TryConnect config file, ensuring Ticket Fizz and Loaded Chip are disabled"); string[] array = File.ReadAllLines(path); bool flag = false; for (int i = 0; i < array.Length; i++) { if (array[i].StartsWith("TicketFizzReplacementChance =")) { string text = array[i]; array[i] = "TicketFizzReplacementChance = 0"; if (text != array[i]) { flag = true; Debug.Log((object)"[Armory] Set TicketFizzReplacementChance to 0"); } } if (array[i].StartsWith("LoadedChipReplacementChance =")) { string text2 = array[i]; array[i] = "LoadedChipReplacementChance = 0"; if (text2 != array[i]) { flag = true; Debug.Log((object)"[Armory] Set LoadedChipReplacementChance to 0"); } } } if (flag) { File.WriteAllLines(path, array); Debug.Log((object)"[Armory] Successfully disabled unwanted TryConnect items"); } else { Debug.Log((object)"[Armory] TryConnect items already disabled"); } } catch (Exception ex) { Debug.LogError((object)("[Armory] Failed to modify TryConnect config: " + ex.Message)); } } } namespace Items_Mod_For_Gamble.Patches { [HarmonyPatch(typeof(AngelsReel), "OnUseItem")] public static class RKeyUse { [CompilerGenerated] private sealed class d__2 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public AngelsReel rKey; private SaveManager 5__1; private MoneyManager 5__2; private long 5__3; private long 5__4; private long 5__5; private long 5__6; private long 5__7; private long 5__8; private int 5__9; private Type 5__10; private FieldInfo 5__11; private SaveData 5__12; private MethodInfo 5__13; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__2(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { 5__1 = null; 5__2 = null; 5__10 = null; 5__11 = null; 5__12 = null; 5__13 = null; <>1__state = -2; } private bool MoveNext() { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Expected O, but got Unknown //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_02bf: Unknown result type (might be due to invalid IL or missing references) //IL_02c9: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = (object)new WaitForSeconds(0.01f); <>1__state = 1; return true; case 1: { <>1__state = -1; if (!NetworkServer.active) { return false; } Scene activeScene = SceneManager.GetActiveScene(); if (((Scene)(ref activeScene)).name == "HomeScene") { ((ConsumableItem)rKey).DestroyItem(); return false; } 5__1 = NetworkSingleton.Instance; 5__2 = NetworkSingleton.Instance; if ((Object)(object)5__1 == (Object)null || (Object)(object)5__2 == (Object)null) { Debug.LogError((object)"[RKey] Required managers not found!"); ((ConsumableItem)rKey).DestroyItem(); return false; } 5__3 = 5__2.balance; 5__4 = 5__2.ticketBalance; 5__5 = (long)((float)5__3 * 0.2f); 5__6 = (long)((float)5__4 * 0.2f); 5__7 = 5__3 - 5__5; 5__8 = 5__4 - 5__6; if (5__7 < 0) { 5__7 = 0L; } if (5__8 < 0) { 5__8 = 0L; } 5__2.SetBalance(5__7, (PlayerProfile)null, (ChangeType)2); 5__2.TrySetTicketBalance(5__8); 5__9 = Random.Range(int.MinValue, int.MaxValue); 5__10 = typeof(SaveManager); 5__11 = 5__10.GetField("currentSaveData", BindingFlags.Instance | BindingFlags.NonPublic); if (5__11 != null) { ref SaveData reference = ref 5__12; object? value = 5__11.GetValue(5__1); reference = (SaveData)((value is SaveData) ? value : null); if (5__12 != null) { 5__12.seed = 5__9; 5__12.money = 5__7; 5__12.tickets = 5__8; 5__13 = 5__10.GetMethod("SaveGame", BindingFlags.Instance | BindingFlags.Public); 5__13?.Invoke(5__1, null); if ((Object)(object)NetworkSingleton.Instance != (Object)null) { NetworkSingleton.Instance.InitializeSeed(5__9); } 5__13 = null; } 5__12 = null; } <>2__current = (object)new WaitForSeconds(0.01f); <>1__state = 2; return true; } case 2: <>1__state = -1; if ((Object)(object)NetworkManager.singleton != (Object)null) { NetworkManager.singleton.ServerChangeScene("HomeScene"); } else { Debug.LogError((object)"[RKey] NetworkManager.singleton is null!"); } return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } private const float PENALTY_PERCENTAGE = 0.2f; [HarmonyPrefix] public static bool Prefix(AngelsReel __instance, bool isPressed) { string text = ((Object)((Component)__instance).gameObject).name.ToLower(); if (text.Contains("r key")) { ((MonoBehaviour)__instance).StartCoroutine(UseRKey(__instance)); return false; } return true; } [IteratorStateMachine(typeof(d__2))] private static IEnumerator UseRKey(AngelsReel rKey) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__2(0) { rKey = rKey }; } } [HarmonyPatch(typeof(Coordinator), "OnUseItem")] public static class VoodooDollUse { [CompilerGenerated] private sealed class d__1 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public Coordinator doll; private PlayerOrgans 5__1; private PlayerProfile 5__2; private bool 5__3; private bool 5__4; private bool 5__5; private bool 5__6; private OrganManager 5__7; private float 5__8; private float 5__9; private long 5__10; private MoneyManager 5__11; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__1(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { 5__1 = null; 5__2 = null; 5__7 = null; 5__11 = null; <>1__state = -2; } private bool MoveNext() { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = (object)new WaitForSeconds(0.5f); <>1__state = 1; return true; case 1: { <>1__state = -1; if (!NetworkServer.active) { return false; } Scene activeScene = SceneManager.GetActiveScene(); if (((Scene)(ref activeScene)).name == "HomeScene") { ((ConsumableItem)doll).DestroyItem(); return false; } PlayerInventory networkHolder = ((Item)doll).NetworkHolder; 5__1 = ((networkHolder != null) ? ((Component)networkHolder).GetComponent() : null); PlayerInventory networkHolder2 = ((Item)doll).NetworkHolder; 5__2 = ((networkHolder2 != null) ? ((Component)networkHolder2).GetComponent() : null); if ((Object)(object)5__1 == (Object)null || (Object)(object)5__2 == (Object)null) { return false; } 5__3 = PillsUse.GetField(5__1, "_localLeftEye"); 5__4 = PillsUse.GetField(5__1, "_localRightEye"); 5__5 = PillsUse.GetField(5__1, "_localBody"); 5__6 = PillsUse.GetField(5__1, "_localMouth"); if (!5__3 && !5__4 && !5__5 && !5__6) { return false; } 5__7 = NetworkSingleton.Instance; 5__8 = Random.value; if (5__8 <= 0.8f) { 5__7.ServerToggleOrgan(5__1, (OrganType)0, false); 5__7.ServerToggleOrgan(5__1, (OrganType)1, false); 5__7.ServerToggleOrgan(5__1, (OrganType)2, false); 5__7.ServerToggleOrgan(5__1, (OrganType)3, false); } else { 5__9 = NetworkSingleton.Instance.GetUpgradeData(5__2.steamId, (PlayerUpgradeType)2); 5__10 = (long)((float)NetworkSingleton.Instance.currentQuota * 5__9); 5__11 = NetworkSingleton.Instance; if ((Object)(object)5__11 != (Object)null) { 5__11.TryChangeBalance(5__10, 5__2, (ChangeType)4); } 5__11 = null; } ((ConsumableItem)doll).DestroyItem(); return false; } } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [HarmonyPrefix] public static bool Prefix(Coordinator __instance, bool isPressed) { string text = ((Object)((Component)__instance).gameObject).name.ToLower(); if (text.Contains("voodoo doll")) { ((MonoBehaviour)__instance).StartCoroutine(DollRoutine(__instance)); return false; } return true; } [IteratorStateMachine(typeof(d__1))] private static IEnumerator DollRoutine(Coordinator doll) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__1(0) { doll = doll }; } } [HarmonyPatch(typeof(Drink), "OnUseItem")] public static class BlindLuckUse { [CompilerGenerated] private sealed class d__5 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public Drink drink; private PlayerOrgans 5__1; private OrganManager 5__2; private PlayerProfile 5__3; private PlayerBuff 5__4; private float 5__5; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__5(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { 5__1 = null; 5__2 = null; 5__3 = null; 5__4 = null; <>1__state = -2; } private bool MoveNext() { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = (object)new WaitForSeconds(1f); <>1__state = 1; return true; case 1: { <>1__state = -1; if (!NetworkServer.active) { return false; } PlayerInventory networkHolder = ((Item)drink).NetworkHolder; 5__1 = ((networkHolder != null) ? ((Component)networkHolder).GetComponent() : null); if ((Object)(object)5__1 == (Object)null) { return false; } NetworkSingleton.Instance.ServerToggleOrgan(5__1, (OrganType)0, false); NetworkSingleton.Instance.ServerToggleOrgan(5__1, (OrganType)1, false); 5__2 = NetworkSingleton.Instance; 5__2.ServerToggleOrgan(5__1, (OrganType)0, false); 5__2.ServerToggleOrgan(5__1, (OrganType)1, false); PlayerInventory networkHolder2 = ((Item)drink).NetworkHolder; 5__3 = ((networkHolder2 != null) ? ((Component)networkHolder2).GetComponent() : null); PlayerInventory networkHolder3 = ((Item)drink).NetworkHolder; 5__4 = ((networkHolder3 != null) ? ((Component)networkHolder3).GetComponent() : null); if ((Object)(object)5__3 != (Object)null && (Object)(object)5__4 != (Object)null) { 5__5 = NetworkSingleton.Instance.GetUpgradeData(5__3.steamId, (PlayerUpgradeType)2); 5__4.ApplyBuff((PlayerBuffType)0, 1.5f * 5__5, 9999f); } ((ConsumableItem)drink).DestroyItem(); return false; } } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } private static readonly FieldRef AnimRef = AccessTools.FieldRefAccess("anim"); private static readonly FieldRef CantDrinkSfxRef = AccessTools.FieldRefAccess("cantDrinkSfx"); private static readonly FieldRef DrinkRoutineRef = AccessTools.FieldRefAccess("_drinkRoutine"); [HarmonyPrefix] public static bool Prefix(Drink __instance, bool isPressed) { string text = ((Object)((Component)__instance).gameObject).name.ToLower(); if (text.Contains("blind luck")) { BlindUse(__instance, isPressed); return false; } return true; } private static void BlindUse(Drink drink, bool isPressed) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) Scene activeScene = SceneManager.GetActiveScene(); if (((Scene)(ref activeScene)).name == "HomeScene") { ((ConsumableItem)drink).DestroyItem(); return; } PlayerInventory networkHolder = ((Item)drink).NetworkHolder; PlayerOrgans val = ((networkHolder != null) ? ((Component)networkHolder).GetComponent() : null); if ((Object)(object)val == (Object)null) { return; } bool field = PillsUse.GetField(val, "_localLeftEye"); bool field2 = PillsUse.GetField(val, "_localRightEye"); if (!field || !field2) { SFXComponent obj = CantDrinkSfxRef.Invoke(drink); if (obj != null) { obj.PlayOneShotAttached(); } return; } AnimRef.Invoke(drink).SetBool("IsDrinking", isPressed); if (NetworkServer.active) { Coroutine val2 = DrinkRoutineRef.Invoke(drink); if (val2 != null) { ((MonoBehaviour)drink).StopCoroutine(val2); } if (isPressed) { Coroutine val3 = ((MonoBehaviour)drink).StartCoroutine(BlindRoutine(drink)); DrinkRoutineRef.Invoke(drink) = val3; } } } [IteratorStateMachine(typeof(d__5))] private static IEnumerator BlindRoutine(Drink drink) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__5(0) { drink = drink }; } } [HarmonyPatch(typeof(Microphone), "OnUseItem")] public static class EnergyDrinkUse { [HarmonyPatch(typeof(Microphone), "OnPickedUp")] public static class MicrophonePickupPatch { [HarmonyPrefix] public static bool Prefix(Microphone __instance, PlayerInventory playerInventory) { string text = ((Object)((Component)__instance).gameObject).name.ToLower(); if (text.Contains("energy drink")) { return false; } return true; } } [CompilerGenerated] private sealed class d__5 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public float stakeholderMultiplier; private float 5__1; private float 5__2; private float 5__3; private Dictionary 5__4; private Dictionary 5__5; private Dictionary 5__6; private Dictionary 5__7; private Slots[] 5__8; private Wheel[] 5__9; private RouletteWheel[] 5__10; private float 5__11; private Slots[] <>s__12; private int <>s__13; private Slots 5__14; private FieldInfo 5__15; private FieldInfo 5__16; private float 5__17; private int 5__18; private float 5__19; private int 5__20; private Wheel[] <>s__21; private int <>s__22; private Wheel 5__23; private FieldInfo 5__24; private float 5__25; private float 5__26; private RouletteWheel[] <>s__27; private int <>s__28; private RouletteWheel 5__29; private FieldInfo 5__30; private FieldInfo 5__31; private float 5__32; private float 5__33; private float 5__34; private float 5__35; private Dictionary.Enumerator <>s__36; private KeyValuePair 5__37; private FieldInfo 5__38; private FieldInfo 5__39; private Dictionary.Enumerator <>s__40; private KeyValuePair 5__41; private FieldInfo 5__42; private Dictionary.Enumerator <>s__43; private KeyValuePair 5__44; private FieldInfo 5__45; private Dictionary.Enumerator <>s__46; private KeyValuePair 5__47; private FieldInfo 5__48; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__5(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { 5__4 = null; 5__5 = null; 5__6 = null; 5__7 = null; 5__8 = null; 5__9 = null; 5__10 = null; <>s__12 = null; 5__14 = null; 5__15 = null; 5__16 = null; <>s__21 = null; 5__23 = null; 5__24 = null; <>s__27 = null; 5__29 = null; 5__30 = null; 5__31 = null; <>s__36 = default(Dictionary.Enumerator); 5__37 = default(KeyValuePair); 5__38 = null; 5__39 = null; <>s__40 = default(Dictionary.Enumerator); 5__41 = default(KeyValuePair); 5__42 = null; <>s__43 = default(Dictionary.Enumerator); 5__44 = default(KeyValuePair); 5__45 = null; <>s__46 = default(Dictionary.Enumerator); 5__47 = default(KeyValuePair); 5__48 = null; <>1__state = -2; } private bool MoveNext() { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Expected O, but got Unknown //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_05f1: Unknown result type (might be due to invalid IL or missing references) //IL_05fb: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = (object)new WaitForSeconds(0.1f); <>1__state = 1; return true; case 1: { <>1__state = -1; Scene activeScene = SceneManager.GetActiveScene(); if (((Scene)(ref activeScene)).name == "HomeScene") { return false; } 5__1 = _speedMultiplier * stakeholderMultiplier; 5__2 = _boostDuration; 5__3 = 5__1; 5__4 = new Dictionary(); 5__5 = new Dictionary(); 5__6 = new Dictionary(); 5__7 = new Dictionary(); 5__8 = Object.FindObjectsByType((FindObjectsSortMode)0); <>s__12 = 5__8; for (<>s__13 = 0; <>s__13 < <>s__12.Length; <>s__13++) { 5__14 = <>s__12[<>s__13]; if ((Object)(object)5__14 != (Object)null) { 5__15 = typeof(Slots).GetField("spinDuration", BindingFlags.Instance | BindingFlags.NonPublic); 5__16 = typeof(Slots).GetField("spinCount", BindingFlags.Instance | BindingFlags.NonPublic); if (5__15 != null && 5__16 != null) { 5__17 = (float)5__15.GetValue(5__14); 5__18 = (int)5__16.GetValue(5__14); 5__4[5__14] = (5__17, 5__18); 5__19 = 5__17 / 5__3; 5__20 = Mathf.RoundToInt((float)5__18 * 5__3); 5__19 = Mathf.Clamp(5__19, 0.5f, 10f); 5__20 = Mathf.Clamp(5__20, 5, 100); 5__15.SetValue(5__14, 5__19); 5__16.SetValue(5__14, 5__20); } 5__15 = null; 5__16 = null; } 5__14 = null; } <>s__12 = null; 5__9 = Object.FindObjectsByType((FindObjectsSortMode)0); <>s__21 = 5__9; for (<>s__22 = 0; <>s__22 < <>s__21.Length; <>s__22++) { 5__23 = <>s__21[<>s__22]; if ((Object)(object)5__23 != (Object)null && !(5__23 is RouletteWheel)) { 5__24 = typeof(Wheel).GetField("spinDuration", BindingFlags.Instance | BindingFlags.NonPublic); if (5__24 != null) { 5__25 = (float)5__24.GetValue(5__23); 5__5[5__23] = 5__25; 5__26 = 5__25 / 5__3; 5__26 = Mathf.Clamp(5__26, 1f, 10f); 5__24.SetValue(5__23, 5__26); } 5__24 = null; } 5__23 = null; } <>s__21 = null; 5__10 = Object.FindObjectsByType((FindObjectsSortMode)0); <>s__27 = 5__10; for (<>s__28 = 0; <>s__28 < <>s__27.Length; <>s__28++) { 5__29 = <>s__27[<>s__28]; if ((Object)(object)5__29 != (Object)null) { 5__30 = typeof(Wheel).GetField("spinDuration", BindingFlags.Instance | BindingFlags.NonPublic); 5__31 = typeof(RouletteWheel).GetField("ballDropDuration", BindingFlags.Instance | BindingFlags.NonPublic); if (5__30 != null) { 5__32 = (float)5__30.GetValue(5__29); 5__6[5__29] = 5__32; 5__33 = 5__32 / 5__3; 5__33 = Mathf.Clamp(5__33, 1f, 15f); 5__30.SetValue(5__29, 5__33); } if (5__31 != null) { 5__34 = (float)5__31.GetValue(5__29); 5__7[5__29] = 5__34; 5__35 = 5__34 / 5__3; 5__35 = Mathf.Clamp(5__35, 0.3f, 3f); 5__31.SetValue(5__29, 5__35); } 5__30 = null; 5__31 = null; } 5__29 = null; } <>s__27 = null; 5__11 = Time.time; break; } case 2: <>1__state = -1; break; } if (Time.time - 5__11 < 5__2) { <>2__current = (object)new WaitForSeconds(1f); <>1__state = 2; return true; } <>s__36 = 5__4.GetEnumerator(); try { while (<>s__36.MoveNext()) { 5__37 = <>s__36.Current; if ((Object)(object)5__37.Key != (Object)null) { 5__38 = typeof(Slots).GetField("spinDuration", BindingFlags.Instance | BindingFlags.NonPublic); 5__39 = typeof(Slots).GetField("spinCount", BindingFlags.Instance | BindingFlags.NonPublic); if (5__38 != null && 5__39 != null) { 5__38.SetValue(5__37.Key, 5__37.Value.duration); 5__39.SetValue(5__37.Key, 5__37.Value.count); } 5__38 = null; 5__39 = null; } 5__37 = default(KeyValuePair); } } finally { ((IDisposable)<>s__36).Dispose(); } <>s__36 = default(Dictionary.Enumerator); <>s__40 = 5__5.GetEnumerator(); try { while (<>s__40.MoveNext()) { 5__41 = <>s__40.Current; if ((Object)(object)5__41.Key != (Object)null) { 5__42 = typeof(Wheel).GetField("spinDuration", BindingFlags.Instance | BindingFlags.NonPublic); if (5__42 != null) { 5__42.SetValue(5__41.Key, 5__41.Value); } 5__42 = null; } 5__41 = default(KeyValuePair); } } finally { ((IDisposable)<>s__40).Dispose(); } <>s__40 = default(Dictionary.Enumerator); <>s__43 = 5__6.GetEnumerator(); try { while (<>s__43.MoveNext()) { 5__44 = <>s__43.Current; if ((Object)(object)5__44.Key != (Object)null) { 5__45 = typeof(Wheel).GetField("spinDuration", BindingFlags.Instance | BindingFlags.NonPublic); if (5__45 != null) { 5__45.SetValue(5__44.Key, 5__44.Value); } 5__45 = null; } 5__44 = default(KeyValuePair); } } finally { ((IDisposable)<>s__43).Dispose(); } <>s__43 = default(Dictionary.Enumerator); <>s__46 = 5__7.GetEnumerator(); try { while (<>s__46.MoveNext()) { 5__47 = <>s__46.Current; if ((Object)(object)5__47.Key != (Object)null) { 5__48 = typeof(RouletteWheel).GetField("ballDropDuration", BindingFlags.Instance | BindingFlags.NonPublic); if (5__48 != null) { 5__48.SetValue(5__47.Key, 5__47.Value); } 5__48 = null; } 5__47 = default(KeyValuePair); } } finally { ((IDisposable)<>s__46).Dispose(); } <>s__46 = default(Dictionary.Enumerator); _activeBoostCoroutine = null; return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } private static float _speedMultiplier = 3f; private static float _boostDuration = 90f; private static Coroutine _activeBoostCoroutine = null; [HarmonyPrefix] public static bool Prefix(Microphone __instance, bool isPressed) { string text = ((Object)((Component)__instance).gameObject).name.ToLower(); if (text.Contains("energy drink")) { if (isPressed && NetworkServer.active) { PlayerInventory networkHolder = ((Item)__instance).NetworkHolder; PlayerProfile val = ((networkHolder != null) ? ((Component)networkHolder).GetComponent() : null); float stakeholderMultiplier = 1f; if ((Object)(object)val != (Object)null) { stakeholderMultiplier = NetworkSingleton.Instance.GetUpgradeData(val.steamId, (PlayerUpgradeType)2); } if (_activeBoostCoroutine != null) { GameManager instance = NetworkSingleton.Instance; if (instance != null) { ((MonoBehaviour)instance).StopCoroutine(_activeBoostCoroutine); } } GameManager instance2 = NetworkSingleton.Instance; _activeBoostCoroutine = ((instance2 != null) ? ((MonoBehaviour)instance2).StartCoroutine(EnergyDrinkRoutine(stakeholderMultiplier)) : null); ((ConsumableItem)__instance).DestroyItem(); } return false; } return true; } [IteratorStateMachine(typeof(d__5))] private static IEnumerator EnergyDrinkRoutine(float stakeholderMultiplier) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__5(0) { stakeholderMultiplier = stakeholderMultiplier }; } } [HarmonyPatch(typeof(MysteryBox), "GetRandomSpawnableByWeight")] public static class MysteryBoxIncludeModdedItemsPatch { private class ModdedItemWeight { public string ItemName { get; } public float Weight { get; } public ModdedItemWeight(string itemName, float weight) { ItemName = itemName; Weight = weight; } } private static List _cachedModdedItems; private static MethodInfo _getSeededRandomMethod; private static readonly ModdedItemWeight[] CUSTOM_WEIGHTS; static MysteryBoxIncludeModdedItemsPatch() { CUSTOM_WEIGHTS = new ModdedItemWeight[8] { new ModdedItemWeight("Cursed Coin", 2.5f), new ModdedItemWeight("R Key", 0.5f), new ModdedItemWeight("Experimental Pills", 1.2f), new ModdedItemWeight("Tax Fraud", 1.2f), new ModdedItemWeight("Voodoo Doll", 1.5f), new ModdedItemWeight("Debt Contract", 1f), new ModdedItemWeight("Energy Drink", 2f), new ModdedItemWeight("Blind Luck", 0.9f) }; CacheModdedSpawnables(); _getSeededRandomMethod = AccessTools.Method(typeof(MysteryBox), "GetSeededRandom", (Type[])null, (Type[])null); } private static void CacheModdedSpawnables() { _cachedModdedItems = new List(); Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); foreach (Assembly assembly in assemblies) { if (!assembly.GetName().Name.Contains("TryConnect")) { continue; } Type type = assembly.GetType("TryConnect.RuntimeItemRegistry"); if (!(type != null)) { continue; } MethodInfo methodInfo = AccessTools.Method(type, "GetRegisteredItemInfos", (Type[])null, (Type[])null); if (!(methodInfo != null) || !(methodInfo.Invoke(null, null) is Array array)) { break; } { foreach (object item in array) { PropertyInfo property = item.GetType().GetProperty("Spawnable"); PropertyInfo property2 = item.GetType().GetProperty("IsRegistered"); if (!(property != null) || !(property2 != null)) { continue; } bool flag = (bool)property2.GetValue(item); object? value = property.GetValue(item); SpawnableSO val = (SpawnableSO)((value is SpawnableSO) ? value : null); if (flag && (Object)(object)val != (Object)null && !val.spawnableName.Contains("Ticket Fizz") && !val.spawnableName.Contains("Loaded Chip")) { float customWeight = GetCustomWeight(val.spawnableName); if (customWeight > 0f) { _cachedModdedItems.Add(new ModdedItemWeight(val.spawnableName, customWeight)); } else { Debug.Log((object)("[Armory] Skipped " + val.spawnableName + " - no custom weight defined")); } } } break; } } } private static float GetCustomWeight(string itemName) { return CUSTOM_WEIGHTS.FirstOrDefault((ModdedItemWeight w) => w.ItemName == itemName)?.Weight ?? (-1f); } [HarmonyPrefix] public static bool Prefix(MysteryBox __instance, ref SpawnableSO __result) { //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) FieldInfo fieldInfo = AccessTools.Field(typeof(MysteryBox), "spawnableList"); if (!(fieldInfo.GetValue(__instance) is List list) || list.Count == 0) { return true; } if (_cachedModdedItems != null && _cachedModdedItems.Count > 0) { List list2 = new List(); list2.AddRange(list); foreach (ModdedItemWeight cachedModdedItem in _cachedModdedItems) { SpawnableSO val = FindSpawnableByName(cachedModdedItem.ItemName); if ((Object)(object)val != (Object)null) { list2.Add(new SpawnableEntry { spawnable = val, chanceWeight = cachedModdedItem.Weight }); } } float num = list2.Sum((SpawnableEntry e) => e.chanceWeight); Random random = _getSeededRandomMethod.Invoke(__instance, null) as Random; float num2 = (float)random.NextDouble() * num; foreach (SpawnableEntry item in list2) { num2 -= item.chanceWeight; if (num2 <= 0f) { __result = item.spawnable; return false; } } } return true; } private static SpawnableSO FindSpawnableByName(string name) { Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); foreach (Assembly assembly in assemblies) { if (!assembly.GetName().Name.Contains("TryConnect")) { continue; } Type type = assembly.GetType("TryConnect.RuntimeItemRegistry"); if (!(type != null)) { continue; } MethodInfo methodInfo = AccessTools.Method(type, "GetRegisteredItemInfos", (Type[])null, (Type[])null); if (!(methodInfo != null) || !(methodInfo.Invoke(null, null) is Array array)) { continue; } foreach (object item in array) { object? obj = item.GetType().GetProperty("Spawnable")?.GetValue(item); SpawnableSO val = (SpawnableSO)((obj is SpawnableSO) ? obj : null); if ((Object)(object)val != (Object)null && val.spawnableName == name) { return val; } } } return null; } } [HarmonyPatch(typeof(Taser), "OnUseItem")] public static class TaxFraudUse { [CompilerGenerated] private sealed class d__1 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public Taser taxes; private PlayerProfile 5__1; private float 5__2; private float 5__3; private long 5__4; private MoneyManager 5__5; private GameManager 5__6; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__1(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { 5__1 = null; 5__5 = null; 5__6 = null; <>1__state = -2; } private bool MoveNext() { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = (object)new WaitForSeconds(0.1f); <>1__state = 1; return true; case 1: { <>1__state = -1; if (!NetworkServer.active) { return false; } Scene activeScene = SceneManager.GetActiveScene(); if (((Scene)(ref activeScene)).name == "HomeScene") { ((ConsumableItem)taxes).DestroyItem(); return false; } PlayerInventory networkHolder = ((Item)taxes).NetworkHolder; 5__1 = ((networkHolder != null) ? ((Component)networkHolder).GetComponent() : null); 5__2 = Random.value; 5__3 = NetworkSingleton.Instance.GetUpgradeData(5__1.steamId, (PlayerUpgradeType)2); 5__4 = (long)((float)NetworkSingleton.Instance.currentQuota * Mathf.Clamp(5__3 * 0.2f, 0.2f, 0.75f)); 5__5 = NetworkSingleton.Instance; 5__6 = NetworkSingleton.Instance; 5__6.NetworkcurrentQuota = Math.Max(0L, 5__6.NetworkcurrentQuota - 5__4); if ((double)5__2 <= 0.05) { 5__5.TryChangeBalance(-NetworkSingleton.Instance.balance, 5__1, (ChangeType)4); } RefreshAllKeypadMinMaxBetTexts(); ((ConsumableItem)taxes).DestroyItem(); return false; } } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [HarmonyPrefix] public static bool Prefix(Taser __instance, bool isPressed) { string text = ((Object)((Component)__instance).gameObject).name.ToLower(); if (text.Contains("tax fraud")) { ((MonoBehaviour)__instance).StartCoroutine(TaxesRoutine(__instance)); return false; } return true; } [IteratorStateMachine(typeof(d__1))] private static IEnumerator TaxesRoutine(Taser taxes) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__1(0) { taxes = taxes }; } private static void RefreshAllKeypadMinMaxBetTexts() { Keypad[] array = Object.FindObjectsByType((FindObjectsSortMode)0); Keypad[] array2 = array; foreach (Keypad val in array2) { if ((Object)(object)val != (Object)null && ((Behaviour)val).isActiveAndEnabled && (Object)(object)val.NetworkcasinoGame != (Object)null) { long minBet = val.NetworkcasinoGame.MinBet; long maxBet = val.NetworkcasinoGame.MaxBet; val.ServerUpdateMinMaxBetText(minBet, maxBet); } } } } [HarmonyPatch(typeof(TimeMachine), "OnUseItem")] public static class DebtContractUse { [HarmonyPatch(typeof(GameManager), "ProgressNextQuota")] private class Patch_ProgressNextQuota { private static void Postfix() { MoneyManager instance = NetworkSingleton.Instance; instance.TryChangeBalance(-(long)((float)ToPay * 1.5f), (PlayerProfile)null, (ChangeType)4); ToPay = 0L; } } [CompilerGenerated] private sealed class d__2 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public TimeMachine debt; private PlayerProfile 5__1; private float 5__2; private long 5__3; private MoneyManager 5__4; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__2(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { 5__1 = null; 5__4 = null; <>1__state = -2; } private bool MoveNext() { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = (object)new WaitForSeconds(0.1f); <>1__state = 1; return true; case 1: { <>1__state = -1; if (!NetworkServer.active) { return false; } Scene activeScene = SceneManager.GetActiveScene(); if (((Scene)(ref activeScene)).name == "HomeScene") { ((ConsumableItem)debt).DestroyItem(); return false; } PlayerInventory networkHolder = ((Item)debt).NetworkHolder; 5__1 = ((networkHolder != null) ? ((Component)networkHolder).GetComponent() : null); 5__2 = NetworkSingleton.Instance.GetUpgradeData(5__1.steamId, (PlayerUpgradeType)2); 5__3 = (long)((float)(NetworkSingleton.Instance.currentQuota / 100 * 25) * 5__2); 5__4 = NetworkSingleton.Instance; if ((Object)(object)5__4 != (Object)null) { 5__4.TryChangeBalance(5__3, 5__1, (ChangeType)4); ToPay += 5__3; } ((ConsumableItem)debt).DestroyItem(); return false; } } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } private static long ToPay; [HarmonyPrefix] public static bool Prefix(TimeMachine __instance, bool isPressed) { string text = ((Object)((Component)__instance).gameObject).name.ToLower(); if (text.Contains("debt contract")) { ((MonoBehaviour)__instance).StartCoroutine(debtRoutine(__instance)); return false; } return true; } [IteratorStateMachine(typeof(d__2))] private static IEnumerator debtRoutine(TimeMachine debt) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__2(0) { debt = debt }; } } [HarmonyPatch(typeof(Upgrade), "UseRoutine")] public static class PillsUse { [CompilerGenerated] private sealed class d__1 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public Upgrade item; private PlayerOrgans 5__1; private PlayerOrganData 5__2; private bool 5__3; private float 5__4; private OrganManager 5__5; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__1(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { 5__1 = null; 5__2 = null; 5__5 = null; <>1__state = -2; } private bool MoveNext() { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = (object)new WaitForSecondsRealtime(0.05f); <>1__state = 1; return true; case 1: { <>1__state = -1; Scene activeScene = SceneManager.GetActiveScene(); if (((Scene)(ref activeScene)).name == "HomeScene") { ((ConsumableItem)item).DestroyItem(); return false; } if (!NetworkServer.active) { return false; } PlayerInventory networkHolder = ((Item)item).NetworkHolder; 5__1 = ((networkHolder != null) ? ((Component)networkHolder).GetComponent() : null); if ((Object)(object)5__1 == (Object)null) { return false; } 5__2 = GetCurrentState(5__1); 5__3 = !5__2.leftEye || !5__2.rightEye || !5__2.body || !5__2.mouth; if (!5__3) { return false; } 5__4 = Random.value; if (5__4 < 0.7f) { Repair(5__2); } else { Remove(5__2); } 5__1.ServerSetBodyParts(5__2); 5__5 = NetworkSingleton.Instance; 5__5.ServerToggleOrgan(5__1, (OrganType)0, 5__2.leftEye); 5__5.ServerToggleOrgan(5__1, (OrganType)1, 5__2.rightEye); 5__5.ServerToggleOrgan(5__1, (OrganType)2, 5__2.body); 5__5.ServerToggleOrgan(5__1, (OrganType)3, 5__2.mouth); ((ConsumableItem)item).DestroyItem(); return false; } } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [HarmonyPrefix] public static bool Prefix(Upgrade __instance, ref IEnumerator __result) { string text = ((Object)((Component)__instance).gameObject).name.ToLower(); if (text.Contains("experimental pills")) { __result = PillsRoutine(__instance); return false; } return true; } [IteratorStateMachine(typeof(d__1))] private static IEnumerator PillsRoutine(Upgrade item) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__1(0) { item = item }; } public static bool GetField(PlayerOrgans obj, string field) { FieldInfo field2 = typeof(PlayerOrgans).GetField(field, BindingFlags.Instance | BindingFlags.NonPublic); return (bool)field2.GetValue(obj); } private static PlayerOrganData GetCurrentState(PlayerOrgans organs) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: 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_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Expected O, but got Unknown return new PlayerOrganData { leftEye = GetField(organs, "_localLeftEye"), rightEye = GetField(organs, "_localRightEye"), body = GetField(organs, "_localBody"), mouth = GetField(organs, "_localMouth") }; } private static void Repair(PlayerOrganData d) { List list = new List(); if (!d.mouth) { list.Add(delegate { d.mouth = true; }); } if (!d.body) { list.Add(delegate { d.body = true; }); } if (!d.leftEye) { list.Add(delegate { d.leftEye = true; }); } if (!d.rightEye) { list.Add(delegate { d.rightEye = true; }); } if (list.Count != 0) { list[Random.Range(0, list.Count)](); } } private static void Remove(PlayerOrganData d) { List list = new List(); bool flag = d.leftEye || d.rightEye; bool flag2 = d.mouth || d.body; if (d.mouth) { list.Add(delegate { d.mouth = false; }); } if (d.body) { list.Add(delegate { d.body = false; }); } if (flag) { if (d.leftEye && d.rightEye) { list.Add(delegate { if (Random.value < 0.5f) { d.leftEye = false; } else { d.rightEye = false; } }); } else if (!flag2) { if (d.leftEye) { list.Add(delegate { d.leftEye = false; }); } if (d.rightEye) { list.Add(delegate { d.rightEye = false; }); } } } if (list.Count != 0) { list[Random.Range(0, list.Count)](); } } } [HarmonyPatch(typeof(GoldenChip), "ApplyChipRoutine")] public static class CursedCoinUse { [CompilerGenerated] private sealed class d__3 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public GoldenChip chip; private GameBase 5__1; private int 5__2; private bool 5__3; private long 5__4; private MoneyManager 5__5; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__3(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { 5__1 = null; 5__5 = null; <>1__state = -2; } private bool MoveNext() { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = (object)new WaitForSeconds(1f); <>1__state = 1; return true; case 1: <>1__state = -1; 5__1 = chip.Network_targetGame; if ((Object)(object)5__1 == (Object)null) { return false; } if (!CursedUses.ContainsKey(chip)) { CursedUses[chip] = 3; } 5__2 = CursedUses[chip]; 5__2--; CursedUses[chip] = 5__2; 5__3 = Random.value <= 0.25f; if (5__3) { 5__4 = (long)((float)5__1.MaxBet * 1.5f * NetworkSingleton.Instance.GetUpgradeData(((Component)((Item)chip).NetworkHolder).GetComponent().steamId, (PlayerUpgradeType)2)); 5__5 = NetworkSingleton.Instance; if ((Object)(object)5__5 != (Object)null && (Object)(object)((Item)chip).NetworkHolder != (Object)null) { 5__5.TryChangeBalance(-5__4, ((Component)((Item)chip).NetworkHolder).GetComponent(), (ChangeType)4); } ((ConsumableItem)chip).DestroyItem(); 5__5 = null; } else { 5__1.ServerSetBet(5__1.MaxBet); 5__1.ApplyGoldenChip(NetworkSingleton.Instance.GetUpgradeData(((Component)((Item)chip).NetworkHolder).GetComponent().steamId, (PlayerUpgradeType)2)); } ((InteractableBase)chip).TooltipMessage = $"{5__2} Uses Left"; if (5__2 <= 0) { CursedUses.Remove(chip); ((ConsumableItem)chip).DestroyItem(); } return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } private static readonly Dictionary CursedUses = new Dictionary(); private const int CursedMaxUses = 3; [HarmonyPrefix] public static bool Prefix(GoldenChip __instance, ref IEnumerator __result) { string text = ((Object)((Component)__instance).gameObject).name.ToLower(); if (text.Contains("cursed coin")) { __result = CursedRoutine(__instance); return false; } return true; } [IteratorStateMachine(typeof(d__3))] private static IEnumerator CursedRoutine(GoldenChip chip) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__3(0) { chip = chip }; } } [HarmonyPatch(typeof(InteractableBase), "get_InteractableName")] public static class InteractableNamePatch { public static bool Prefix(InteractableBase __instance, ref string __result) { string text = ((Object)((Component)__instance).gameObject).name.ToLower(); if (text.Contains("cursed coin")) { __result = "Cursed Coin"; return false; } if (text.Contains("experimental pills")) { __result = "Experimental Pills"; return false; } if (text.Contains("blind luck")) { __result = "Blind Luck"; return false; } if (text.Contains("voodoo doll")) { __result = "Voodoo Doll"; return false; } if (text.Contains("tax fraud")) { __result = "Tax Fraud"; return false; } if (text.Contains("energy drink")) { __result = "Energy Drink"; return false; } if (text.Contains("debt contract")) { __result = "Debt Contract"; return false; } if (text.Contains("r key")) { __result = "R Key"; return false; } if (text.Contains("microphone")) { __result = "Microphone"; return false; } return true; } } } namespace Items_Mod_For_Gamble.ModdedItem { public sealed class RKey : AngelsReel { } [HarmonyPatch(typeof(Item), "OnAwake")] public static class rKeyAwakePatch { [HarmonyPostfix] private static void Postfix(Item __instance) { AngelsReel val = (AngelsReel)(object)((__instance is AngelsReel) ? __instance : null); if (!((Object)(object)val == (Object)null)) { string text = ((Object)((Component)val).gameObject).name.ToLower(); if (text.Contains("r key") && ((Item)val).itemActions != null && ((Item)val).itemActions.Count > 0) { ((Item)val).itemActions.First().actionName = "Restart"; } } } } public sealed class EnergyDrink : Microphone { } [HarmonyPatch(typeof(Item), "OnAwake")] public static class EnergyDrinkAwakePatch { [HarmonyPostfix] private static void Postfix(Item __instance) { Microphone val = (Microphone)(object)((__instance is Microphone) ? __instance : null); if (!((Object)(object)val == (Object)null)) { string text = ((Object)((Component)val).gameObject).name.ToLower(); if (text.Contains("energy drink") && ((Item)val).itemActions != null && ((Item)val).itemActions.Count > 0) { ((Item)val).itemActions.First().actionName = "Consume"; } } } } internal sealed class BlindLuck : Drink { } [HarmonyPatch(typeof(Item), "OnAwake")] public static class BlindAwakePatch { [HarmonyPostfix] private static void Postfix(Item __instance) { Drink val = (Drink)(object)((__instance is Drink) ? __instance : null); if ((Object)(object)val == (Object)null) { return; } string text = ((Object)((Component)val).gameObject).name.ToLower(); if (text.Contains("blind luck")) { ((InteractableBase)val).TooltipMessage = "Only works if you have both eyes"; if (((Item)val).itemActions != null && ((Item)val).itemActions.Count > 0) { ((Item)val).itemActions.First().actionName = "Scoop your eyes"; } AccessTools.Field(typeof(Drink), "_canDrink").SetValue(val, true); AccessTools.Field(typeof(Drink), "_isBreakable").SetValue(val, false); } } } public sealed class CursedCoin : GoldenChip { } internal sealed class Experimental_Pills : Upgrade { } [HarmonyPatch(typeof(Item), "OnAwake")] public static class PillAwakePatch { [HarmonyPostfix] private static void Postfix(Item __instance) { Upgrade val = (Upgrade)(object)((__instance is Upgrade) ? __instance : null); if ((Object)(object)val == (Object)null) { return; } string text = ((Object)((Component)val).gameObject).name.ToLower(); if (text.Contains("experimental pills")) { ((InteractableBase)val).TooltipMessage = "Only works if you are missing body parts"; if (((Item)val).itemActions != null && ((Item)val).itemActions.Count > 0) { ((Item)val).itemActions.First().actionName = "Take a pill"; } } } } internal sealed class TaxFraud : Taser { } [HarmonyPatch(typeof(Item), "OnAwake")] public static class TaxAwakePatch { [HarmonyPostfix] private static void Postfix(Item __instance) { Taser val = (Taser)(object)((__instance is Taser) ? __instance : null); if ((Object)(object)val == (Object)null) { return; } string text = ((Object)((Component)val).gameObject).name.ToLower(); if (text.Contains("tax fraud")) { ((InteractableBase)val).TooltipMessage = "Lose all cash when audited"; if (((Item)val).itemActions != null && ((Item)val).itemActions.Count > 0) { ((Item)val).itemActions.First().actionName = "Falsify Taxes"; } } } } internal sealed class DebtContract : TimeMachine { } [HarmonyPatch(typeof(Item), "OnAwake")] public static class DebtContractPatch { [HarmonyPostfix] private static void Postfix(Item __instance) { TimeMachine val = (TimeMachine)(object)((__instance is TimeMachine) ? __instance : null); if (!((Object)(object)val == (Object)null)) { string text = ((Object)((Component)val).gameObject).name.ToLower(); ((InteractableBase)val).TooltipMessage = "Interest is 50%"; if (text.Contains("debt contract") && ((Item)val).itemActions != null && ((Item)val).itemActions.Count > 0) { ((Item)val).itemActions.First().actionName = "Sign"; } } } } internal sealed class VoodooDoll : Coordinator { } [HarmonyPatch(typeof(Item), "OnAwake")] public static class DollAwakePatch { [HarmonyPostfix] private static void Postfix(Item __instance) { Coordinator val = (Coordinator)(object)((__instance is Coordinator) ? __instance : null); if ((Object)(object)val == (Object)null) { return; } string text = ((Object)((Component)val).gameObject).name.ToLower(); if (text.Contains("voodoo doll")) { ((InteractableBase)val).TooltipMessage = "Only works if you have body parts to lose"; if (((Item)val).itemActions != null && ((Item)val).itemActions.Count > 0) { ((Item)val).itemActions.First().actionName = "Poke"; ((Item)val).itemActions.Last().actionName = "Throw"; ((Item)val).itemActions.RemoveAt(1); } AccessTools.Field(typeof(Coordinator), "_isBreakable").SetValue(val, false); } } } } namespace TimeMachineOrganPatch { [HarmonyPatch(typeof(TimeMachine))] public static class TimeMachineOrganPatch { public static class CoroutineHelper { private class CoroutineRunner : MonoBehaviour { } private static MonoBehaviour _coroutineRunner; public static void Initialize() { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown if ((Object)(object)_coroutineRunner == (Object)null) { GameObject val = new GameObject("TimeMachineCoroutineRunner"); Object.DontDestroyOnLoad((Object)(object)val); _coroutineRunner = (MonoBehaviour)(object)val.AddComponent(); Debug.Log((object)"[TimeMachine] CoroutineHelper initialized"); } } public static void RunCoroutine(IEnumerator coroutine) { if ((Object)(object)_coroutineRunner == (Object)null) { Debug.LogError((object)"[TimeMachine] CoroutineRunner is null! Cannot run coroutine."); } else { _coroutineRunner.StartCoroutine(coroutine); } } } [CompilerGenerated] private sealed class d__9 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public float rollbackSeconds; private PlayerBuff[] 5__1; private bool 5__2; private PlayerBuff[] <>s__3; private int <>s__4; private PlayerBuff 5__5; private BuffHistoryTracker 5__6; private float 5__7; private List<(float timestamp, Dictionary state)> 5__8; private Dictionary 5__9; private Dictionary.Enumerator <>s__10; private KeyValuePair 5__11; private float 5__12; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__9(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { 5__1 = null; <>s__3 = null; 5__5 = null; 5__6 = null; 5__8 = null; 5__9 = null; <>s__10 = default(Dictionary.Enumerator); <>1__state = -2; } private bool MoveNext() { //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Unknown result type (might be due to invalid IL or missing references) switch (<>1__state) { default: return false; case 0: <>1__state = -1; 5__1 = Object.FindObjectsByType((FindObjectsSortMode)0); Debug.Log((object)$"[TimeMachine] Found {5__1.Length} PlayerBuff components in scene"); if (5__1.Length == 0) { Debug.LogWarning((object)"[TimeMachine] No PlayerBuff components found!"); return false; } 5__2 = false; <>s__3 = 5__1; for (<>s__4 = 0; <>s__4 < <>s__3.Length; <>s__4++) { 5__5 = <>s__3[<>s__4]; 5__6 = ((Component)5__5).GetComponent(); if (!((Object)(object)5__6 == (Object)null) && 5__6.IsTracking) { 5__7 = Time.time - rollbackSeconds; 5__8 = 5__6.GetSnapshotsSince(5__7); if (5__8 != null && 5__8.Count != 0) { 5__9 = 5__8[0].state; <>s__10 = 5__9.GetEnumerator(); try { while (<>s__10.MoveNext()) { 5__11 = <>s__10.Current; 5__12 = GetBuffValue(5__5, 5__11.Key); if (Mathf.Abs(5__12 - 5__11.Value) > 0.01f) { Debug.Log((object)$"[TimeMachine] ROLLING BACK buff {5__11.Key} from {5__12} to {5__11.Value}"); 5__2 = true; SetBuffValue(5__5, 5__11.Key, 5__11.Value); } } } finally { ((IDisposable)<>s__10).Dispose(); } <>s__10 = default(Dictionary.Enumerator); 5__6 = null; 5__8 = null; 5__9 = null; 5__5 = null; } } } <>s__3 = null; if (!5__2) { Debug.Log((object)"[TimeMachine] No buff rollbacks were performed"); } <>2__current = null; <>1__state = 1; return true; case 1: <>1__state = -1; return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__8 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public float rollbackSeconds; private OrganManager 5__1; private PlayerOrgans[] 5__2; private bool 5__3; private PlayerOrgans[] <>s__4; private int <>s__5; private PlayerOrgans 5__6; private OrganHistoryTracker 5__7; private float 5__8; private List<(float timestamp, PlayerOrganData state)> 5__9; private PlayerOrganData 5__10; private PlayerOrganData 5__11; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__8(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { 5__1 = null; 5__2 = null; <>s__4 = null; 5__6 = null; 5__7 = null; 5__9 = null; 5__10 = null; 5__11 = null; <>1__state = -2; } private bool MoveNext() { //IL_0248: Unknown result type (might be due to invalid IL or missing references) //IL_0252: Expected O, but got Unknown int num = <>1__state; if (num != 0) { if (num != 1) { return false; } <>1__state = -1; goto IL_0263; } <>1__state = -1; 5__1 = NetworkSingleton.Instance; if ((Object)(object)5__1 == (Object)null) { Debug.LogError((object)"[TimeMachine] OrganManager is null! Cannot rollback organs."); return false; } 5__2 = Object.FindObjectsByType((FindObjectsSortMode)0); Debug.Log((object)$"[TimeMachine] Found {5__2.Length} PlayerOrgans in scene"); if (5__2.Length == 0) { Debug.LogWarning((object)"[TimeMachine] No PlayerOrgans found!"); return false; } 5__3 = false; <>s__4 = 5__2; <>s__5 = 0; goto IL_0295; IL_0263: 5__7 = null; 5__9 = null; 5__10 = null; 5__11 = null; 5__6 = null; goto IL_0287; IL_0295: if (<>s__5 < <>s__4.Length) { 5__6 = <>s__4[<>s__5]; 5__7 = ((Component)5__6).GetComponent(); if (!((Object)(object)5__7 == (Object)null) && 5__7.IsTracking) { 5__8 = Time.time - rollbackSeconds; 5__9 = 5__7.GetSnapshotsSince(5__8); if (5__9 != null && 5__9.Count != 0) { 5__10 = 5__9[0].state; 5__11 = GetCurrentOrganState(5__6); if (!StatesEqual(5__11, 5__10)) { Debug.Log((object)("[TimeMachine] ROLLING BACK organs for " + ((Object)5__6).name + "!")); 5__3 = true; 5__6.ServerSetBodyParts(5__10); 5__1.ServerToggleOrgan(5__6, (OrganType)0, 5__10.leftEye); 5__1.ServerToggleOrgan(5__6, (OrganType)1, 5__10.rightEye); 5__1.ServerToggleOrgan(5__6, (OrganType)2, 5__10.body); 5__1.ServerToggleOrgan(5__6, (OrganType)3, 5__10.mouth); <>2__current = (object)new WaitForSeconds(0.05f); <>1__state = 1; return true; } goto IL_0263; } } goto IL_0287; } <>s__4 = null; if (!5__3) { Debug.Log((object)"[TimeMachine] No organ rollbacks were performed"); } return false; IL_0287: <>s__5++; goto IL_0295; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__7 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public float rollbackSeconds; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__7(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; if (!NetworkServer.active) { Debug.LogWarning((object)"[TimeMachine] RollbackRoutine - NetworkServer not active!"); return false; } Debug.Log((object)$"[TimeMachine] RollbackRoutine STARTED - rollbackSeconds: {rollbackSeconds}, Time.time: {Time.time:F2}"); <>2__current = (object)new WaitForSeconds(0.2f); <>1__state = 1; return true; case 1: <>1__state = -1; Debug.Log((object)$"[TimeMachine] After wait - Time.time: {Time.time:F2}"); <>2__current = RollbackOrgans(rollbackSeconds); <>1__state = 2; return true; case 2: <>1__state = -1; <>2__current = RollbackBuffs(rollbackSeconds); <>1__state = 3; return true; case 3: <>1__state = -1; Debug.Log((object)"[TimeMachine] RollbackRoutine COMPLETED"); return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__6 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public TimeMachine timeMachine; public IEnumerator originalRoutine; private float 5__1; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__6(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; break; case 1: <>1__state = -1; break; } if (originalRoutine.MoveNext()) { <>2__current = originalRoutine.Current; <>1__state = 1; return true; } if (NetworkServer.active) { 5__1 = (float)_rollbackSecondsField.GetValue(timeMachine); Debug.Log((object)$"[TimeMachine] Starting rollback for {5__1} seconds"); CoroutineHelper.RunCoroutine(RollbackRoutine(5__1)); } return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } private static FieldInfo _rollbackSecondsField; private static bool _coroutineHelperInitialized; static TimeMachineOrganPatch() { _coroutineHelperInitialized = false; _rollbackSecondsField = typeof(TimeMachine).GetField("rollbackSeconds", BindingFlags.Instance | BindingFlags.NonPublic); InitializeCoroutineHelper(); } private static void InitializeCoroutineHelper() { if (!_coroutineHelperInitialized) { CoroutineHelper.Initialize(); _coroutineHelperInitialized = true; } } [HarmonyPostfix] [HarmonyPatch("RollbackRoutine")] public static void Postfix_RollbackRoutine(TimeMachine __instance, ref IEnumerator __result) { __result = WrappedRollbackRoutine(__instance, __result); } [IteratorStateMachine(typeof(d__6))] private static IEnumerator WrappedRollbackRoutine(TimeMachine timeMachine, IEnumerator originalRoutine) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__6(0) { timeMachine = timeMachine, originalRoutine = originalRoutine }; } [IteratorStateMachine(typeof(d__7))] private static IEnumerator RollbackRoutine(float rollbackSeconds) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__7(0) { rollbackSeconds = rollbackSeconds }; } [IteratorStateMachine(typeof(d__8))] private static IEnumerator RollbackOrgans(float rollbackSeconds) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__8(0) { rollbackSeconds = rollbackSeconds }; } [IteratorStateMachine(typeof(d__9))] private static IEnumerator RollbackBuffs(float rollbackSeconds) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__9(0) { rollbackSeconds = rollbackSeconds }; } private static float GetBuffValue(PlayerBuff playerBuff, PlayerBuffType buffType) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) MethodInfo method = typeof(PlayerBuff).GetMethod("GetValue", BindingFlags.Instance | BindingFlags.Public); if (method != null) { return (float)method.Invoke(playerBuff, new object[1] { buffType }); } return 0f; } private static void SetBuffValue(PlayerBuff playerBuff, PlayerBuffType buffType, float value) { //IL_006e: Unknown result type (might be due to invalid IL or missing references) FieldInfo field = typeof(PlayerBuff).GetField("_buffs", BindingFlags.Instance | BindingFlags.NonPublic); if (field != null) { object value2 = field.GetValue(playerBuff); PropertyInfo property = value2.GetType().GetProperty("Item", new Type[1] { typeof(PlayerBuffType) }); if (property != null) { property.SetValue(value2, value, new object[1] { buffType }); } } } private static PlayerOrganData GetCurrentOrganState(PlayerOrgans organs) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown PlayerOrganData val = new PlayerOrganData(); FieldInfo field = typeof(PlayerOrgans).GetField("_localLeftEye", BindingFlags.Instance | BindingFlags.NonPublic); FieldInfo field2 = typeof(PlayerOrgans).GetField("_localRightEye", BindingFlags.Instance | BindingFlags.NonPublic); FieldInfo field3 = typeof(PlayerOrgans).GetField("_localBody", BindingFlags.Instance | BindingFlags.NonPublic); FieldInfo field4 = typeof(PlayerOrgans).GetField("_localMouth", BindingFlags.Instance | BindingFlags.NonPublic); if (field != null) { val.leftEye = (bool)field.GetValue(organs); } if (field2 != null) { val.rightEye = (bool)field2.GetValue(organs); } if (field3 != null) { val.body = (bool)field3.GetValue(organs); } if (field4 != null) { val.mouth = (bool)field4.GetValue(organs); } return val; } private static bool StatesEqual(PlayerOrganData a, PlayerOrganData b) { return a.leftEye == b.leftEye && a.rightEye == b.rightEye && a.body == b.body && a.mouth == b.mouth; } } [HarmonyPatch(typeof(PlayerOrgans), "Awake")] public static class PlayerOrgansAwakePatch { [HarmonyPostfix] public static void Postfix(PlayerOrgans __instance) { if (NetworkServer.active && (Object)(object)((Component)__instance).GetComponent() == (Object)null) { ((Component)__instance).gameObject.AddComponent(); Debug.Log((object)("[TimeMachine] Added OrganHistoryTracker to " + ((Object)__instance).name)); } } } [HarmonyPatch(typeof(PlayerBuff), "Awake")] public static class PlayerBuffAwakePatch { [HarmonyPostfix] public static void Postfix(PlayerBuff __instance) { if (NetworkServer.active && (Object)(object)((Component)__instance).GetComponent() == (Object)null) { ((Component)__instance).gameObject.AddComponent(); Debug.Log((object)("[TimeMachine] Added BuffHistoryTracker to " + ((Object)__instance).name)); } } } [HarmonyPatch(typeof(GameManager), "GameInitializeRoutine")] public static class GameManagerGameInitializePatch { [HarmonyPostfix] public static void Postfix(GameManager __instance) { if (!NetworkServer.active) { return; } OrganHistoryTracker[] array = Object.FindObjectsByType((FindObjectsSortMode)0); BuffHistoryTracker[] array2 = Object.FindObjectsByType((FindObjectsSortMode)0); OrganHistoryTracker[] array3 = array; foreach (OrganHistoryTracker organHistoryTracker in array3) { if (!organHistoryTracker.IsTracking) { organHistoryTracker.StartTracking(); } } BuffHistoryTracker[] array4 = array2; foreach (BuffHistoryTracker buffHistoryTracker in array4) { if (!buffHistoryTracker.IsTracking) { buffHistoryTracker.StartTracking(); } } } } [HarmonyPatch(typeof(OrganManager), "ServerApplyAllOrganSettings")] public static class OrganManagerApplySettingsPatch { [HarmonyPostfix] public static void Postfix(OrganManager __instance) { if (!NetworkServer.active) { return; } OrganHistoryTracker[] array = Object.FindObjectsByType((FindObjectsSortMode)0); OrganHistoryTracker[] array2 = array; foreach (OrganHistoryTracker organHistoryTracker in array2) { if (organHistoryTracker.IsTracking) { organHistoryTracker.ResetAndRecordInitialState(); } } } } [HarmonyPatch(typeof(GameManager), "ServerSetSceneRoutine")] public static class GameManagerSceneChangePatch { [HarmonyPrefix] public static void Prefix(GameManager __instance, GameState newState) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Invalid comparison between Unknown and I4 //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Invalid comparison between Unknown and I4 if (NetworkServer.active && (int)__instance.state == 1 && (int)newState != 1) { OrganHistoryTracker[] array = Object.FindObjectsByType((FindObjectsSortMode)0); BuffHistoryTracker[] array2 = Object.FindObjectsByType((FindObjectsSortMode)0); OrganHistoryTracker[] array3 = array; foreach (OrganHistoryTracker organHistoryTracker in array3) { organHistoryTracker.StopTracking(); } BuffHistoryTracker[] array4 = array2; foreach (BuffHistoryTracker buffHistoryTracker in array4) { buffHistoryTracker.StopTracking(); } } } } public class OrganHistoryTracker : MonoBehaviour { public class OrganStateRecord { public float timestamp; public PlayerOrganData state; } private List _history = new List(); private float _recordInterval = 1f; private float _lastRecordTime; private PlayerOrgans _organs; private bool _isTracking = false; private float _gameStartTime = 0f; private int _recordCount = 0; public bool IsTracking => _isTracking; private void Awake() { _organs = ((Component)this).GetComponent(); } public void StartTracking() { if (NetworkServer.active && !_isTracking) { _isTracking = true; _gameStartTime = Time.time; _lastRecordTime = Time.time; _recordCount = 0; } } public void ResetAndRecordInitialState() { if (_isTracking && !((Object)(object)_organs == (Object)null)) { _history.Clear(); _recordCount = 0; RecordCurrentState(); } } private void Update() { if (_isTracking && NetworkServer.active && !((Object)(object)_organs == (Object)null) && Time.time - _lastRecordTime >= _recordInterval) { RecordCurrentState(); _lastRecordTime = Time.time; if (_history.Count > 300) { _history.RemoveAt(0); } } } private void RecordCurrentState() { if (!((Object)(object)_organs == (Object)null)) { PlayerOrganData currentState = GetCurrentState(); _history.Add(new OrganStateRecord { timestamp = Time.time, state = currentState }); _recordCount++; } } private PlayerOrganData GetCurrentState() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown PlayerOrganData val = new PlayerOrganData(); FieldInfo field = typeof(PlayerOrgans).GetField("_localLeftEye", BindingFlags.Instance | BindingFlags.NonPublic); FieldInfo field2 = typeof(PlayerOrgans).GetField("_localRightEye", BindingFlags.Instance | BindingFlags.NonPublic); FieldInfo field3 = typeof(PlayerOrgans).GetField("_localBody", BindingFlags.Instance | BindingFlags.NonPublic); FieldInfo field4 = typeof(PlayerOrgans).GetField("_localMouth", BindingFlags.Instance | BindingFlags.NonPublic); if (field != null) { val.leftEye = (bool)field.GetValue(_organs); } if (field2 != null) { val.rightEye = (bool)field2.GetValue(_organs); } if (field3 != null) { val.body = (bool)field3.GetValue(_organs); } if (field4 != null) { val.mouth = (bool)field4.GetValue(_organs); } return val; } public List<(float timestamp, PlayerOrganData state)> GetSnapshotsSince(float cutoffTime) { List<(float, PlayerOrganData)> list = new List<(float, PlayerOrganData)>(); if (!_isTracking || _history.Count == 0) { return list; } if (cutoffTime < _gameStartTime) { cutoffTime = _gameStartTime; } for (int num = _history.Count - 1; num >= 0; num--) { if (_history[num].timestamp <= cutoffTime) { list.Add((_history[num].timestamp, _history[num].state)); break; } } if (list.Count == 0 && _history.Count > 0) { list.Add((_history[0].timestamp, _history[0].state)); } return list; } public void StopTracking() { _isTracking = false; } private void OnDestroy() { StopTracking(); } } public class BuffHistoryTracker : MonoBehaviour { public class BuffStateRecord { public float timestamp; public Dictionary state; } private List _history = new List(); private float _recordInterval = 1f; private float _lastRecordTime; private PlayerBuff _playerBuff; private bool _isTracking = false; private float _gameStartTime = 0f; private int _recordCount = 0; public bool IsTracking => _isTracking; private void Awake() { _playerBuff = ((Component)this).GetComponent(); } public void StartTracking() { if (NetworkServer.active && !_isTracking) { _isTracking = true; _gameStartTime = Time.time; _lastRecordTime = Time.time; _recordCount = 0; } } private void Update() { if (_isTracking && NetworkServer.active && !((Object)(object)_playerBuff == (Object)null) && Time.time - _lastRecordTime >= _recordInterval) { RecordCurrentState(); _lastRecordTime = Time.time; if (_history.Count > 300) { _history.RemoveAt(0); } } } private void RecordCurrentState() { if (!((Object)(object)_playerBuff == (Object)null)) { Dictionary currentBuffState = GetCurrentBuffState(); if (currentBuffState != null && currentBuffState.Count > 0) { _history.Add(new BuffStateRecord { timestamp = Time.time, state = currentBuffState }); _recordCount++; } } } private Dictionary GetCurrentBuffState() { //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) Dictionary dictionary = new Dictionary(); try { FieldInfo field = typeof(PlayerBuff).GetField("_buffs", BindingFlags.Instance | BindingFlags.NonPublic); if (field != null) { object value = field.GetValue(_playerBuff); if (value != null) { MethodInfo method = value.GetType().GetMethod("get_Keys"); if (method != null) { IEnumerable enumerable = (IEnumerable)method.Invoke(value, null); foreach (PlayerBuffType item in enumerable) { MethodInfo method2 = value.GetType().GetMethod("get_Item", new Type[1] { typeof(PlayerBuffType) }); if (method2 != null) { object obj = method2.Invoke(value, new object[1] { item }); dictionary[item] = (float)obj; } } } } } } catch (Exception ex) { Debug.LogError((object)("[TimeMachine] Error getting buff state: " + ex.Message)); } return dictionary; } public List<(float timestamp, Dictionary state)> GetSnapshotsSince(float cutoffTime) { List<(float, Dictionary)> list = new List<(float, Dictionary)>(); if (!_isTracking || _history.Count == 0) { return list; } if (cutoffTime < _gameStartTime) { cutoffTime = _gameStartTime; } for (int num = _history.Count - 1; num >= 0; num--) { if (_history[num].timestamp <= cutoffTime) { list.Add((_history[num].timestamp, _history[num].state)); break; } } if (list.Count == 0 && _history.Count > 0) { list.Add((_history[0].timestamp, _history[0].state)); } return list; } public void ForceRecord() { if (NetworkServer.active && _isTracking) { RecordCurrentState(); } } public void StopTracking() { _isTracking = false; } private void OnDestroy() { StopTracking(); } } }