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(typeof(ElevatorGuy))] public static class ElevatorGuyDebugPatch { private static FieldInfo assetIdField = typeof(NetworkIdentity).GetField("_assetId", BindingFlags.Instance | BindingFlags.NonPublic); private static FieldInfo hasSpawnedField = typeof(ElevatorGuy).GetField("_hasSpawned", BindingFlags.Instance | BindingFlags.NonPublic); private static FieldInfo isSpawningField = typeof(ElevatorGuy).GetField("_isSpawning", BindingFlags.Instance | BindingFlags.NonPublic); [HarmonyPrefix] [HarmonyPatch("ItemInitializeRoutine")] public static void Prefix_ItemInitializeRoutine(ElevatorGuy __instance) { Debug.Log((object)"[ElevatorGuy] ========== ITEM INITIALIZE ROUTINE STARTING =========="); ItemManager instance = NetworkSingleton.Instance; if ((Object)(object)instance != (Object)null && instance.currentItems != null) { Debug.Log((object)$"[ElevatorGuy] ItemManager.currentItems contains {instance.currentItems.Count} items:"); int num = 0; { SpawnableSO val = default(SpawnableSO); foreach (SpawnableSO currentItem in instance.currentItems) { if ((Object)(object)currentItem == (Object)null) { Debug.Log((object)$"[ElevatorGuy] [{num}] NULL item"); num++; continue; } bool flag = TryConnectApi.TryGetCustomSpawnable(currentItem.spawnableID, ref val); GameObject prefab = currentItem.prefab; uint num2 = 0u; string text = "NULL"; if ((Object)(object)prefab != (Object)null) { text = ((Object)prefab).name; NetworkIdentity component = prefab.GetComponent(); if ((Object)(object)component != (Object)null && assetIdField != null) { num2 = (uint)assetIdField.GetValue(component); } } Debug.Log((object)$"[ElevatorGuy] [{num}] Item: {currentItem.spawnableName}"); Debug.Log((object)$"[ElevatorGuy] ID: {currentItem.spawnableID}"); Debug.Log((object)$"[ElevatorGuy] Is Custom: {flag}"); Debug.Log((object)("[ElevatorGuy] Prefab: " + text)); Debug.Log((object)$"[ElevatorGuy] AssetId: {num2}"); Debug.Log((object)"[ElevatorGuy] ---"); num++; } return; } } Debug.Log((object)"[ElevatorGuy] ItemManager is null or has no currentItems!"); } [HarmonyPostfix] [HarmonyPatch("ItemInitializeRoutine")] public static void Postfix_ItemInitializeRoutine(ElevatorGuy __instance) { bool flag = hasSpawnedField != null && (bool)hasSpawnedField.GetValue(__instance); bool flag2 = isSpawningField != null && (bool)isSpawningField.GetValue(__instance); Debug.Log((object)$"[ElevatorGuy] ========== ITEM INITIALIZE ROUTINE FINISHED ========== HasSpawned: {flag}, IsSpawning: {flag2}"); } [HarmonyPrefix] [HarmonyPatch("ItemSpawnRoutine")] public static void Prefix_ItemSpawnRoutine(ElevatorGuy __instance) { Debug.Log((object)"[ElevatorGuy] ========== ITEM SPAWN ROUTINE STARTING =========="); ItemManager instance = NetworkSingleton.Instance; if ((Object)(object)instance != (Object)null && instance.spawnedItemInstances != null) { Debug.Log((object)$"[ElevatorGuy] spawnedItemInstances contains {instance.spawnedItemInstances.Count} items"); } } [HarmonyPostfix] [HarmonyPatch("ItemSpawnRoutine")] public static void Postfix_ItemSpawnRoutine(ElevatorGuy __instance) { bool flag = isSpawningField != null && (bool)isSpawningField.GetValue(__instance); Debug.Log((object)$"[ElevatorGuy] ========== ITEM SPAWN ROUTINE FINISHED ========== IsSpawning: {flag}"); } } [HarmonyPatch(typeof(Object), "Instantiate", new Type[] { typeof(GameObject), typeof(Vector3), typeof(Quaternion) })] public static class InstantiateDebugPatch { private static FieldInfo assetIdField = typeof(NetworkIdentity).GetField("_assetId", BindingFlags.Instance | BindingFlags.NonPublic); [HarmonyPostfix] public static void Postfix_Instantiate(GameObject original, Vector3 position, Quaternion rotation, ref Object __result) { //IL_014b: Unknown result type (might be due to invalid IL or missing references) StackTrace stackTrace = new StackTrace(); bool flag = false; StackFrame[] frames = stackTrace.GetFrames(); foreach (StackFrame stackFrame in frames) { if (stackFrame.GetMethod().DeclaringType == typeof(ElevatorGuy)) { flag = true; break; } } if (!flag || !(__result != (Object)null)) { return; } Object obj = __result; GameObject val = (GameObject)(object)((obj is GameObject) ? obj : null); if ((Object)(object)val != (Object)null) { NetworkIdentity component = val.GetComponent(); uint num = 0u; if ((Object)(object)component != (Object)null && assetIdField != null) { num = (uint)assetIdField.GetValue(component); } Item component2 = val.GetComponent(); string text = (((Object)(object)component2 != (Object)null && (Object)(object)component2.spawnableSo != (Object)null) ? component2.spawnableSo.spawnableName : ((Object)val).name); Debug.Log((object)("[ElevatorGuy] INSTANTIATED: " + text)); Debug.Log((object)("[ElevatorGuy] - From prefab: " + (((Object)(object)original != (Object)null) ? ((Object)original).name : "NULL"))); Debug.Log((object)$"[ElevatorGuy] - AssetId on instantiated object: {num}"); Debug.Log((object)$"[ElevatorGuy] - Position: {position}"); } } } [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.2.0")] 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 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_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_0143: 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_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Expected O, but got Unknown //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: Unknown result type (might be due to invalid IL or missing references) //IL_01ed: Unknown result type (might be due to invalid IL or missing references) //IL_01f9: Unknown result type (might be due to invalid IL or missing references) //IL_0205: Unknown result type (might be due to invalid IL or missing references) //IL_0206: Unknown result type (might be due to invalid IL or missing references) //IL_0210: Unknown result type (might be due to invalid IL or missing references) //IL_021b: Unknown result type (might be due to invalid IL or missing references) //IL_0223: Unknown result type (might be due to invalid IL or missing references) //IL_022b: Unknown result type (might be due to invalid IL or missing references) //IL_0233: Unknown result type (might be due to invalid IL or missing references) //IL_023c: Unknown result type (might be due to invalid IL or missing references) //IL_0244: Unknown result type (might be due to invalid IL or missing references) //IL_024e: Expected O, but got Unknown //IL_0251: Unknown result type (might be due to invalid IL or missing references) //IL_0256: Unknown result type (might be due to invalid IL or missing references) //IL_0263: Unknown result type (might be due to invalid IL or missing references) //IL_028a: Unknown result type (might be due to invalid IL or missing references) //IL_028f: Unknown result type (might be due to invalid IL or missing references) //IL_029b: Unknown result type (might be due to invalid IL or missing references) //IL_02a7: Unknown result type (might be due to invalid IL or missing references) //IL_02b3: 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_02cb: Unknown result type (might be due to invalid IL or missing references) //IL_02cc: Unknown result type (might be due to invalid IL or missing references) //IL_02d6: Unknown result type (might be due to invalid IL or missing references) //IL_02e1: Unknown result type (might be due to invalid IL or missing references) //IL_02f1: Unknown result type (might be due to invalid IL or missing references) //IL_02fc: Unknown result type (might be due to invalid IL or missing references) //IL_0304: Unknown result type (might be due to invalid IL or missing references) //IL_030c: Unknown result type (might be due to invalid IL or missing references) //IL_0314: Unknown result type (might be due to invalid IL or missing references) //IL_031d: 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_0330: Expected O, but got Unknown //IL_0333: Unknown result type (might be due to invalid IL or missing references) //IL_0338: Unknown result type (might be due to invalid IL or missing references) //IL_0345: Unknown result type (might be due to invalid IL or missing references) //IL_036c: Unknown result type (might be due to invalid IL or missing references) //IL_0371: Unknown result type (might be due to invalid IL or missing references) //IL_037d: Unknown result type (might be due to invalid IL or missing references) //IL_0389: Unknown result type (might be due to invalid IL or missing references) //IL_0395: Unknown result type (might be due to invalid IL or missing references) //IL_03a1: Unknown result type (might be due to invalid IL or missing references) //IL_03ad: Unknown result type (might be due to invalid IL or missing references) //IL_03ae: Unknown result type (might be due to invalid IL or missing references) //IL_03b8: Unknown result type (might be due to invalid IL or missing references) //IL_03c3: Unknown result type (might be due to invalid IL or missing references) //IL_03d3: Unknown result type (might be due to invalid IL or missing references) //IL_03de: Unknown result type (might be due to invalid IL or missing references) //IL_03e6: Unknown result type (might be due to invalid IL or missing references) //IL_03ee: Unknown result type (might be due to invalid IL or missing references) //IL_03f6: Unknown result type (might be due to invalid IL or missing references) //IL_03ff: 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_0412: Expected O, but got Unknown //IL_0415: Unknown result type (might be due to invalid IL or missing references) //IL_041a: Unknown result type (might be due to invalid IL or missing references) //IL_0427: Unknown result type (might be due to invalid IL or missing references) //IL_044e: Unknown result type (might be due to invalid IL or missing references) //IL_0453: Unknown result type (might be due to invalid IL or missing references) //IL_045f: Unknown result type (might be due to invalid IL or missing references) //IL_046b: Unknown result type (might be due to invalid IL or missing references) //IL_0477: Unknown result type (might be due to invalid IL or missing references) //IL_0483: Unknown result type (might be due to invalid IL or missing references) //IL_048f: Unknown result type (might be due to invalid IL or missing references) //IL_0490: Unknown result type (might be due to invalid IL or missing references) //IL_049a: Unknown result type (might be due to invalid IL or missing references) //IL_04a5: Unknown result type (might be due to invalid IL or missing references) //IL_04b5: Unknown result type (might be due to invalid IL or missing references) //IL_04c0: Unknown result type (might be due to invalid IL or missing references) //IL_04c8: Unknown result type (might be due to invalid IL or missing references) //IL_04d0: Unknown result type (might be due to invalid IL or missing references) //IL_04d8: Unknown result type (might be due to invalid IL or missing references) //IL_04e1: Unknown result type (might be due to invalid IL or missing references) //IL_04e9: Unknown result type (might be due to invalid IL or missing references) //IL_04f3: Expected O, but got Unknown //IL_04f6: Unknown result type (might be due to invalid IL or missing references) //IL_04fb: Unknown result type (might be due to invalid IL or missing references) //IL_0508: Unknown result type (might be due to invalid IL or missing references) //IL_052f: Unknown result type (might be due to invalid IL or missing references) //IL_0534: Unknown result type (might be due to invalid IL or missing references) //IL_0540: Unknown result type (might be due to invalid IL or missing references) //IL_054c: Unknown result type (might be due to invalid IL or missing references) //IL_0558: Unknown result type (might be due to invalid IL or missing references) //IL_0564: Unknown result type (might be due to invalid IL or missing references) //IL_0570: Unknown result type (might be due to invalid IL or missing references) //IL_0571: Unknown result type (might be due to invalid IL or missing references) //IL_057b: Unknown result type (might be due to invalid IL or missing references) //IL_0586: Unknown result type (might be due to invalid IL or missing references) //IL_0596: Unknown result type (might be due to invalid IL or missing references) //IL_05a1: Unknown result type (might be due to invalid IL or missing references) //IL_05b1: Unknown result type (might be due to invalid IL or missing references) //IL_05bc: Unknown result type (might be due to invalid IL or missing references) //IL_05c4: 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_05d4: Unknown result type (might be due to invalid IL or missing references) //IL_05dd: Unknown result type (might be due to invalid IL or missing references) //IL_05e6: Unknown result type (might be due to invalid IL or missing references) //IL_05f0: Expected O, but got Unknown //IL_05f3: Unknown result type (might be due to invalid IL or missing references) //IL_05f8: Unknown result type (might be due to invalid IL or missing references) //IL_0605: 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"); 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, 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}"); } } 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(Coordinator), "OnUseItem")] public static class CoordinatorPatch { [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 = UpgradePatch.GetField(5__1, "_localLeftEye"); 5__4 = UpgradePatch.GetField(5__1, "_localRightEye"); 5__5 = UpgradePatch.GetField(5__1, "_localBody"); 5__6 = UpgradePatch.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 DrinkPatch { [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 = UpgradePatch.GetField(val, "_localLeftEye"); bool field2 = UpgradePatch.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 MicrophoneSpeedBoostPatch { [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_05db: Unknown result type (might be due to invalid IL or missing references) //IL_05e5: 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__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 static List _cachedModdedSpawnables; private static MethodInfo _getSeededRandomMethod; static MysteryBoxIncludeModdedItemsPatch() { CacheModdedSpawnables(); _getSeededRandomMethod = AccessTools.Method(typeof(MysteryBox), "GetSeededRandom", (Type[])null, (Type[])null); } private static void CacheModdedSpawnables() { _cachedModdedSpawnables = 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) { 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")) { _cachedModdedSpawnables.Add(val); } } } break; } Debug.Log((object)$"[Armory] Cached {_cachedModdedSpawnables.Count} modded items for Mystery Box"); } [HarmonyPrefix] public static bool Prefix(MysteryBox __instance, ref SpawnableSO __result) { //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: 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_014e: 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_0171: Unknown result type (might be due to invalid IL or missing references) //IL_017e: 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 (_cachedModdedSpawnables != null && _cachedModdedSpawnables.Count > 0) { List list2 = new List(); list2.AddRange(list); float num = list.Average((SpawnableEntry e) => e.chanceWeight); foreach (SpawnableSO cachedModdedSpawnable in _cachedModdedSpawnables) { list2.Add(new SpawnableEntry { spawnable = cachedModdedSpawnable, chanceWeight = num * 2f }); } float num2 = list2.Sum((SpawnableEntry e) => e.chanceWeight); Random random = _getSeededRandomMethod.Invoke(__instance, null) as Random; float num3 = (float)random.NextDouble() * num2; foreach (SpawnableEntry item in list2) { num3 -= item.chanceWeight; if (num3 <= 0f) { __result = item.spawnable; Debug.Log((object)("[Armory] Mystery Box selected: " + item.spawnable.spawnableName)); return false; } } } return true; } } [HarmonyPatch(typeof(Taser), "OnUseItem")] public static class TaserPatch { [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(Upgrade), "UseRoutine")] public static class UpgradePatch { [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 GoldenChipPatch { [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; } return true; } } } namespace Items_Mod_For_Gamble.ModdedItem { 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 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); } } } }