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<ItemManager>.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<NetworkIdentity>();
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<ItemManager>.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<NetworkIdentity>();
uint num = 0u;
if ((Object)(object)component != (Object)null && assetIdField != null)
{
num = (uint)assetIdField.GetValue(component);
}
Item component2 = val.GetComponent<Item>();
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<GameObject> registeredPrefabs = new List<GameObject>();
[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<NetworkIdentity>();
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<bool> enableCursedCoin;
internal static ConfigEntry<bool> enablePills;
internal static ConfigEntry<bool> enableBlind;
internal static ConfigEntry<bool> enableDoll;
internal static ConfigEntry<bool> enableTaxes;
internal static ConfigEntry<bool> 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<bool>("Custom Items", "Cursed Coin", true, "Enable \"cursed coin\" to show up in shop");
enablePills = ((BaseUnityPlugin)this).Config.Bind<bool>("Custom Items", "Experimental Pills", true, "Enable \"experimental pills\" to show up in the shop");
enableBlind = ((BaseUnityPlugin)this).Config.Bind<bool>("Custom Items", "Blind Luck", true, "Enable \"Blind Luck\" to show up in the shop");
enableDoll = ((BaseUnityPlugin)this).Config.Bind<bool>("Custom Items", "Voodoo Doll", true, "Enable \"Voodoo Doll\" to show up in the shop");
enableTaxes = ((BaseUnityPlugin)this).Config.Bind<bool>("Custom Items", "Tax Fraud", true, "Enable \"Tax Fraud\" to show up in the shop");
enableEnergy = ((BaseUnityPlugin)this).Config.Bind<bool>("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 <color=#BC0508>25% chance to lose 1.5x max bet</color>\n<color=#00ffcc>3 Uses</color>",
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<GoldenChip, CursedCoin>((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 = "<color=#00ffcc>70%</color> to gain a body part\n<color=#BC0508>30%</color> 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<Upgrade, Experimental_Pills>((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 = "<color=#BC0508>Lose</color> both your eyes\n<color=#23e82e>Gain</color> 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<Drink, BlindLuck>((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 = "<color=#BC0508>80%</color> to lose all body parts\n<color=#23e82e>20%</color> 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<Coordinator, VoodooDoll>((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 = "<color=#23e82e>Decrease</color> quota by 20%\n<color=#BC0508>5%</color> 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<Taser, TaxFraud>((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 <color=#23e82e>3x</color> 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<Microphone, EnergyDrink>((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 <DollRoutine>d__1 : IEnumerator<object>, IDisposable, IEnumerator
{
private int <>1__state;
private object <>2__current;
public Coordinator doll;
private PlayerOrgans <organs>5__1;
private PlayerProfile <profile>5__2;
private bool <leftEye>5__3;
private bool <rightEye>5__4;
private bool <body>5__5;
private bool <mouth>5__6;
private OrganManager <mgr>5__7;
private float <roll>5__8;
private float <multiplier>5__9;
private long <gainAmount>5__10;
private MoneyManager <money>5__11;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <DollRoutine>d__1(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<organs>5__1 = null;
<profile>5__2 = null;
<mgr>5__7 = null;
<money>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;
<organs>5__1 = ((networkHolder != null) ? ((Component)networkHolder).GetComponent<PlayerOrgans>() : null);
PlayerInventory networkHolder2 = ((Item)doll).NetworkHolder;
<profile>5__2 = ((networkHolder2 != null) ? ((Component)networkHolder2).GetComponent<PlayerProfile>() : null);
if ((Object)(object)<organs>5__1 == (Object)null || (Object)(object)<profile>5__2 == (Object)null)
{
return false;
}
<leftEye>5__3 = UpgradePatch.GetField(<organs>5__1, "_localLeftEye");
<rightEye>5__4 = UpgradePatch.GetField(<organs>5__1, "_localRightEye");
<body>5__5 = UpgradePatch.GetField(<organs>5__1, "_localBody");
<mouth>5__6 = UpgradePatch.GetField(<organs>5__1, "_localMouth");
if (!<leftEye>5__3 && !<rightEye>5__4 && !<body>5__5 && !<mouth>5__6)
{
return false;
}
<mgr>5__7 = NetworkSingleton<OrganManager>.Instance;
<roll>5__8 = Random.value;
if (<roll>5__8 <= 0.8f)
{
<mgr>5__7.ServerToggleOrgan(<organs>5__1, (OrganType)0, false);
<mgr>5__7.ServerToggleOrgan(<organs>5__1, (OrganType)1, false);
<mgr>5__7.ServerToggleOrgan(<organs>5__1, (OrganType)2, false);
<mgr>5__7.ServerToggleOrgan(<organs>5__1, (OrganType)3, false);
}
else
{
<multiplier>5__9 = NetworkSingleton<UpgradeManager>.Instance.GetUpgradeData(<profile>5__2.steamId, (PlayerUpgradeType)2);
<gainAmount>5__10 = (long)((float)NetworkSingleton<GameManager>.Instance.currentQuota * <multiplier>5__9);
<money>5__11 = NetworkSingleton<MoneyManager>.Instance;
if ((Object)(object)<money>5__11 != (Object)null)
{
<money>5__11.TryChangeBalance(<gainAmount>5__10, <profile>5__2, (ChangeType)4);
}
<money>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(<DollRoutine>d__1))]
private static IEnumerator DollRoutine(Coordinator doll)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <DollRoutine>d__1(0)
{
doll = doll
};
}
}
[HarmonyPatch(typeof(Drink), "OnUseItem")]
public static class DrinkPatch
{
[CompilerGenerated]
private sealed class <BlindRoutine>d__5 : IEnumerator<object>, IDisposable, IEnumerator
{
private int <>1__state;
private object <>2__current;
public Drink drink;
private PlayerOrgans <organs>5__1;
private OrganManager <mgr>5__2;
private PlayerProfile <profile>5__3;
private PlayerBuff <buff>5__4;
private float <multiplier>5__5;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <BlindRoutine>d__5(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<organs>5__1 = null;
<mgr>5__2 = null;
<profile>5__3 = null;
<buff>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;
<organs>5__1 = ((networkHolder != null) ? ((Component)networkHolder).GetComponent<PlayerOrgans>() : null);
if ((Object)(object)<organs>5__1 == (Object)null)
{
return false;
}
NetworkSingleton<OrganManager>.Instance.ServerToggleOrgan(<organs>5__1, (OrganType)0, false);
NetworkSingleton<OrganManager>.Instance.ServerToggleOrgan(<organs>5__1, (OrganType)1, false);
<mgr>5__2 = NetworkSingleton<OrganManager>.Instance;
<mgr>5__2.ServerToggleOrgan(<organs>5__1, (OrganType)0, false);
<mgr>5__2.ServerToggleOrgan(<organs>5__1, (OrganType)1, false);
PlayerInventory networkHolder2 = ((Item)drink).NetworkHolder;
<profile>5__3 = ((networkHolder2 != null) ? ((Component)networkHolder2).GetComponent<PlayerProfile>() : null);
PlayerInventory networkHolder3 = ((Item)drink).NetworkHolder;
<buff>5__4 = ((networkHolder3 != null) ? ((Component)networkHolder3).GetComponent<PlayerBuff>() : null);
if ((Object)(object)<profile>5__3 != (Object)null && (Object)(object)<buff>5__4 != (Object)null)
{
<multiplier>5__5 = NetworkSingleton<UpgradeManager>.Instance.GetUpgradeData(<profile>5__3.steamId, (PlayerUpgradeType)2);
<buff>5__4.ApplyBuff((PlayerBuffType)0, 1.5f * <multiplier>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<Drink, Animator> AnimRef = AccessTools.FieldRefAccess<Drink, Animator>("anim");
private static readonly FieldRef<Drink, SFXComponent> CantDrinkSfxRef = AccessTools.FieldRefAccess<Drink, SFXComponent>("cantDrinkSfx");
private static readonly FieldRef<Drink, Coroutine> DrinkRoutineRef = AccessTools.FieldRefAccess<Drink, Coroutine>("_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<PlayerOrgans>() : 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(<BlindRoutine>d__5))]
private static IEnumerator BlindRoutine(Drink drink)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <BlindRoutine>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 <EnergyDrinkRoutine>d__5 : IEnumerator<object>, IDisposable, IEnumerator
{
private int <>1__state;
private object <>2__current;
public float stakeholderMultiplier;
private float <finalSpeedMultiplier>5__1;
private float <finalDuration>5__2;
private float <effectiveMultiplier>5__3;
private Dictionary<Slots, (float duration, int count)> <slotsOriginalValues>5__4;
private Dictionary<Wheel, float> <wheelOriginalDurations>5__5;
private Dictionary<RouletteWheel, float> <rouletteOriginalDurations>5__6;
private Dictionary<RouletteWheel, float> <rouletteOriginalBallDropDurations>5__7;
private Slots[] <allSlots>5__8;
private Wheel[] <allWheels>5__9;
private RouletteWheel[] <allRouletteWheels>5__10;
private float <startTime>5__11;
private Slots[] <>s__12;
private int <>s__13;
private Slots <slot>5__14;
private FieldInfo <durationField>5__15;
private FieldInfo <countField>5__16;
private float <originalDuration>5__17;
private int <originalCount>5__18;
private float <newDuration>5__19;
private int <newCount>5__20;
private Wheel[] <>s__21;
private int <>s__22;
private Wheel <wheel>5__23;
private FieldInfo <spinDurationField>5__24;
private float <originalDuration>5__25;
private float <newDuration>5__26;
private RouletteWheel[] <>s__27;
private int <>s__28;
private RouletteWheel <wheel>5__29;
private FieldInfo <spinDurationField>5__30;
private FieldInfo <ballDropDurationField>5__31;
private float <originalSpinDuration>5__32;
private float <newSpinDuration>5__33;
private float <originalBallDropDuration>5__34;
private float <newBallDropDuration>5__35;
private Dictionary<Slots, (float duration, int count)>.Enumerator <>s__36;
private KeyValuePair<Slots, (float duration, int count)> <kvp>5__37;
private FieldInfo <durationField>5__38;
private FieldInfo <countField>5__39;
private Dictionary<Wheel, float>.Enumerator <>s__40;
private KeyValuePair<Wheel, float> <kvp>5__41;
private FieldInfo <spinDurationField>5__42;
private Dictionary<RouletteWheel, float>.Enumerator <>s__43;
private KeyValuePair<RouletteWheel, float> <kvp>5__44;
private FieldInfo <spinDurationField>5__45;
private Dictionary<RouletteWheel, float>.Enumerator <>s__46;
private KeyValuePair<RouletteWheel, float> <kvp>5__47;
private FieldInfo <ballDropDurationField>5__48;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <EnergyDrinkRoutine>d__5(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<slotsOriginalValues>5__4 = null;
<wheelOriginalDurations>5__5 = null;
<rouletteOriginalDurations>5__6 = null;
<rouletteOriginalBallDropDurations>5__7 = null;
<allSlots>5__8 = null;
<allWheels>5__9 = null;
<allRouletteWheels>5__10 = null;
<>s__12 = null;
<slot>5__14 = null;
<durationField>5__15 = null;
<countField>5__16 = null;
<>s__21 = null;
<wheel>5__23 = null;
<spinDurationField>5__24 = null;
<>s__27 = null;
<wheel>5__29 = null;
<spinDurationField>5__30 = null;
<ballDropDurationField>5__31 = null;
<>s__36 = default(Dictionary<Slots, (float, int)>.Enumerator);
<kvp>5__37 = default(KeyValuePair<Slots, (float, int)>);
<durationField>5__38 = null;
<countField>5__39 = null;
<>s__40 = default(Dictionary<Wheel, float>.Enumerator);
<kvp>5__41 = default(KeyValuePair<Wheel, float>);
<spinDurationField>5__42 = null;
<>s__43 = default(Dictionary<RouletteWheel, float>.Enumerator);
<kvp>5__44 = default(KeyValuePair<RouletteWheel, float>);
<spinDurationField>5__45 = null;
<>s__46 = default(Dictionary<RouletteWheel, float>.Enumerator);
<kvp>5__47 = default(KeyValuePair<RouletteWheel, float>);
<ballDropDurationField>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;
}
<finalSpeedMultiplier>5__1 = _speedMultiplier * stakeholderMultiplier;
<finalDuration>5__2 = _boostDuration;
<effectiveMultiplier>5__3 = <finalSpeedMultiplier>5__1;
<slotsOriginalValues>5__4 = new Dictionary<Slots, (float, int)>();
<wheelOriginalDurations>5__5 = new Dictionary<Wheel, float>();
<rouletteOriginalDurations>5__6 = new Dictionary<RouletteWheel, float>();
<rouletteOriginalBallDropDurations>5__7 = new Dictionary<RouletteWheel, float>();
<allSlots>5__8 = Object.FindObjectsByType<Slots>((FindObjectsSortMode)0);
<>s__12 = <allSlots>5__8;
for (<>s__13 = 0; <>s__13 < <>s__12.Length; <>s__13++)
{
<slot>5__14 = <>s__12[<>s__13];
if ((Object)(object)<slot>5__14 != (Object)null)
{
<durationField>5__15 = typeof(Slots).GetField("spinDuration", BindingFlags.Instance | BindingFlags.NonPublic);
<countField>5__16 = typeof(Slots).GetField("spinCount", BindingFlags.Instance | BindingFlags.NonPublic);
if (<durationField>5__15 != null && <countField>5__16 != null)
{
<originalDuration>5__17 = (float)<durationField>5__15.GetValue(<slot>5__14);
<originalCount>5__18 = (int)<countField>5__16.GetValue(<slot>5__14);
<slotsOriginalValues>5__4[<slot>5__14] = (<originalDuration>5__17, <originalCount>5__18);
<newDuration>5__19 = <originalDuration>5__17 / <effectiveMultiplier>5__3;
<newCount>5__20 = Mathf.RoundToInt((float)<originalCount>5__18 * <effectiveMultiplier>5__3);
<newDuration>5__19 = Mathf.Clamp(<newDuration>5__19, 0.5f, 10f);
<newCount>5__20 = Mathf.Clamp(<newCount>5__20, 5, 100);
<durationField>5__15.SetValue(<slot>5__14, <newDuration>5__19);
<countField>5__16.SetValue(<slot>5__14, <newCount>5__20);
}
<durationField>5__15 = null;
<countField>5__16 = null;
}
<slot>5__14 = null;
}
<>s__12 = null;
<allWheels>5__9 = Object.FindObjectsByType<Wheel>((FindObjectsSortMode)0);
<>s__21 = <allWheels>5__9;
for (<>s__22 = 0; <>s__22 < <>s__21.Length; <>s__22++)
{
<wheel>5__23 = <>s__21[<>s__22];
if ((Object)(object)<wheel>5__23 != (Object)null)
{
<spinDurationField>5__24 = typeof(Wheel).GetField("spinDuration", BindingFlags.Instance | BindingFlags.NonPublic);
if (<spinDurationField>5__24 != null)
{
<originalDuration>5__25 = (float)<spinDurationField>5__24.GetValue(<wheel>5__23);
<wheelOriginalDurations>5__5[<wheel>5__23] = <originalDuration>5__25;
<newDuration>5__26 = <originalDuration>5__25 / <effectiveMultiplier>5__3;
<newDuration>5__26 = Mathf.Clamp(<newDuration>5__26, 1f, 10f);
<spinDurationField>5__24.SetValue(<wheel>5__23, <newDuration>5__26);
}
<spinDurationField>5__24 = null;
}
<wheel>5__23 = null;
}
<>s__21 = null;
<allRouletteWheels>5__10 = Object.FindObjectsByType<RouletteWheel>((FindObjectsSortMode)0);
<>s__27 = <allRouletteWheels>5__10;
for (<>s__28 = 0; <>s__28 < <>s__27.Length; <>s__28++)
{
<wheel>5__29 = <>s__27[<>s__28];
if ((Object)(object)<wheel>5__29 != (Object)null)
{
<spinDurationField>5__30 = typeof(Wheel).GetField("spinDuration", BindingFlags.Instance | BindingFlags.NonPublic);
<ballDropDurationField>5__31 = typeof(RouletteWheel).GetField("ballDropDuration", BindingFlags.Instance | BindingFlags.NonPublic);
if (<spinDurationField>5__30 != null)
{
<originalSpinDuration>5__32 = (float)<spinDurationField>5__30.GetValue(<wheel>5__29);
<rouletteOriginalDurations>5__6[<wheel>5__29] = <originalSpinDuration>5__32;
<newSpinDuration>5__33 = <originalSpinDuration>5__32 / <effectiveMultiplier>5__3;
<newSpinDuration>5__33 = Mathf.Clamp(<newSpinDuration>5__33, 1f, 15f);
<spinDurationField>5__30.SetValue(<wheel>5__29, <newSpinDuration>5__33);
}
if (<ballDropDurationField>5__31 != null)
{
<originalBallDropDuration>5__34 = (float)<ballDropDurationField>5__31.GetValue(<wheel>5__29);
<rouletteOriginalBallDropDurations>5__7[<wheel>5__29] = <originalBallDropDuration>5__34;
<newBallDropDuration>5__35 = <originalBallDropDuration>5__34 / <effectiveMultiplier>5__3;
<newBallDropDuration>5__35 = Mathf.Clamp(<newBallDropDuration>5__35, 0.3f, 3f);
<ballDropDurationField>5__31.SetValue(<wheel>5__29, <newBallDropDuration>5__35);
}
<spinDurationField>5__30 = null;
<ballDropDurationField>5__31 = null;
}
<wheel>5__29 = null;
}
<>s__27 = null;
<startTime>5__11 = Time.time;
break;
}
case 2:
<>1__state = -1;
break;
}
if (Time.time - <startTime>5__11 < <finalDuration>5__2)
{
<>2__current = (object)new WaitForSeconds(1f);
<>1__state = 2;
return true;
}
<>s__36 = <slotsOriginalValues>5__4.GetEnumerator();
try
{
while (<>s__36.MoveNext())
{
<kvp>5__37 = <>s__36.Current;
if ((Object)(object)<kvp>5__37.Key != (Object)null)
{
<durationField>5__38 = typeof(Slots).GetField("spinDuration", BindingFlags.Instance | BindingFlags.NonPublic);
<countField>5__39 = typeof(Slots).GetField("spinCount", BindingFlags.Instance | BindingFlags.NonPublic);
if (<durationField>5__38 != null && <countField>5__39 != null)
{
<durationField>5__38.SetValue(<kvp>5__37.Key, <kvp>5__37.Value.duration);
<countField>5__39.SetValue(<kvp>5__37.Key, <kvp>5__37.Value.count);
}
<durationField>5__38 = null;
<countField>5__39 = null;
}
<kvp>5__37 = default(KeyValuePair<Slots, (float, int)>);
}
}
finally
{
((IDisposable)<>s__36).Dispose();
}
<>s__36 = default(Dictionary<Slots, (float, int)>.Enumerator);
<>s__40 = <wheelOriginalDurations>5__5.GetEnumerator();
try
{
while (<>s__40.MoveNext())
{
<kvp>5__41 = <>s__40.Current;
if ((Object)(object)<kvp>5__41.Key != (Object)null)
{
<spinDurationField>5__42 = typeof(Wheel).GetField("spinDuration", BindingFlags.Instance | BindingFlags.NonPublic);
if (<spinDurationField>5__42 != null)
{
<spinDurationField>5__42.SetValue(<kvp>5__41.Key, <kvp>5__41.Value);
}
<spinDurationField>5__42 = null;
}
<kvp>5__41 = default(KeyValuePair<Wheel, float>);
}
}
finally
{
((IDisposable)<>s__40).Dispose();
}
<>s__40 = default(Dictionary<Wheel, float>.Enumerator);
<>s__43 = <rouletteOriginalDurations>5__6.GetEnumerator();
try
{
while (<>s__43.MoveNext())
{
<kvp>5__44 = <>s__43.Current;
if ((Object)(object)<kvp>5__44.Key != (Object)null)
{
<spinDurationField>5__45 = typeof(Wheel).GetField("spinDuration", BindingFlags.Instance | BindingFlags.NonPublic);
if (<spinDurationField>5__45 != null)
{
<spinDurationField>5__45.SetValue(<kvp>5__44.Key, <kvp>5__44.Value);
}
<spinDurationField>5__45 = null;
}
<kvp>5__44 = default(KeyValuePair<RouletteWheel, float>);
}
}
finally
{
((IDisposable)<>s__43).Dispose();
}
<>s__43 = default(Dictionary<RouletteWheel, float>.Enumerator);
<>s__46 = <rouletteOriginalBallDropDurations>5__7.GetEnumerator();
try
{
while (<>s__46.MoveNext())
{
<kvp>5__47 = <>s__46.Current;
if ((Object)(object)<kvp>5__47.Key != (Object)null)
{
<ballDropDurationField>5__48 = typeof(RouletteWheel).GetField("ballDropDuration", BindingFlags.Instance | BindingFlags.NonPublic);
if (<ballDropDurationField>5__48 != null)
{
<ballDropDurationField>5__48.SetValue(<kvp>5__47.Key, <kvp>5__47.Value);
}
<ballDropDurationField>5__48 = null;
}
<kvp>5__47 = default(KeyValuePair<RouletteWheel, float>);
}
}
finally
{
((IDisposable)<>s__46).Dispose();
}
<>s__46 = default(Dictionary<RouletteWheel, float>.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<PlayerProfile>() : null);
float stakeholderMultiplier = 1f;
if ((Object)(object)val != (Object)null)
{
stakeholderMultiplier = NetworkSingleton<UpgradeManager>.Instance.GetUpgradeData(val.steamId, (PlayerUpgradeType)2);
}
if (_activeBoostCoroutine != null)
{
GameManager instance = NetworkSingleton<GameManager>.Instance;
if (instance != null)
{
((MonoBehaviour)instance).StopCoroutine(_activeBoostCoroutine);
}
}
GameManager instance2 = NetworkSingleton<GameManager>.Instance;
_activeBoostCoroutine = ((instance2 != null) ? ((MonoBehaviour)instance2).StartCoroutine(EnergyDrinkRoutine(stakeholderMultiplier)) : null);
((ConsumableItem)__instance).DestroyItem();
}
return false;
}
return true;
}
[IteratorStateMachine(typeof(<EnergyDrinkRoutine>d__5))]
private static IEnumerator EnergyDrinkRoutine(float stakeholderMultiplier)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <EnergyDrinkRoutine>d__5(0)
{
stakeholderMultiplier = stakeholderMultiplier
};
}
}
[HarmonyPatch(typeof(MysteryBox), "GetRandomSpawnableByWeight")]
public static class MysteryBoxIncludeModdedItemsPatch
{
private static List<SpawnableSO> _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<SpawnableSO>();
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<SpawnableEntry> list) || list.Count == 0)
{
return true;
}
if (_cachedModdedSpawnables != null && _cachedModdedSpawnables.Count > 0)
{
List<SpawnableEntry> list2 = new List<SpawnableEntry>();
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 <TaxesRoutine>d__1 : IEnumerator<object>, IDisposable, IEnumerator
{
private int <>1__state;
private object <>2__current;
public Taser taxes;
private PlayerProfile <profile>5__1;
private float <roll>5__2;
private float <multiplier>5__3;
private long <removeAmount>5__4;
private MoneyManager <money>5__5;
private GameManager <gm>5__6;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <TaxesRoutine>d__1(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<profile>5__1 = null;
<money>5__5 = null;
<gm>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;
<profile>5__1 = ((networkHolder != null) ? ((Component)networkHolder).GetComponent<PlayerProfile>() : null);
<roll>5__2 = Random.value;
<multiplier>5__3 = NetworkSingleton<UpgradeManager>.Instance.GetUpgradeData(<profile>5__1.steamId, (PlayerUpgradeType)2);
<removeAmount>5__4 = (long)((float)NetworkSingleton<GameManager>.Instance.currentQuota * Mathf.Clamp(<multiplier>5__3 * 0.2f, 0.2f, 0.75f));
<money>5__5 = NetworkSingleton<MoneyManager>.Instance;
<gm>5__6 = NetworkSingleton<GameManager>.Instance;
<gm>5__6.NetworkcurrentQuota = Math.Max(0L, <gm>5__6.NetworkcurrentQuota - <removeAmount>5__4);
if ((double)<roll>5__2 <= 0.05)
{
<money>5__5.TryChangeBalance(-NetworkSingleton<MoneyManager>.Instance.balance, <profile>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(<TaxesRoutine>d__1))]
private static IEnumerator TaxesRoutine(Taser taxes)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <TaxesRoutine>d__1(0)
{
taxes = taxes
};
}
private static void RefreshAllKeypadMinMaxBetTexts()
{
Keypad[] array = Object.FindObjectsByType<Keypad>((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 <PillsRoutine>d__1 : IEnumerator<object>, IDisposable, IEnumerator
{
private int <>1__state;
private object <>2__current;
public Upgrade item;
private PlayerOrgans <organs>5__1;
private PlayerOrganData <state>5__2;
private bool <hasMissing>5__3;
private float <roll>5__4;
private OrganManager <mgr>5__5;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <PillsRoutine>d__1(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<organs>5__1 = null;
<state>5__2 = null;
<mgr>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;
<organs>5__1 = ((networkHolder != null) ? ((Component)networkHolder).GetComponent<PlayerOrgans>() : null);
if ((Object)(object)<organs>5__1 == (Object)null)
{
return false;
}
<state>5__2 = GetCurrentState(<organs>5__1);
<hasMissing>5__3 = !<state>5__2.leftEye || !<state>5__2.rightEye || !<state>5__2.body || !<state>5__2.mouth;
if (!<hasMissing>5__3)
{
return false;
}
<roll>5__4 = Random.value;
if (<roll>5__4 < 0.7f)
{
Repair(<state>5__2);
}
else
{
Remove(<state>5__2);
}
<organs>5__1.ServerSetBodyParts(<state>5__2);
<mgr>5__5 = NetworkSingleton<OrganManager>.Instance;
<mgr>5__5.ServerToggleOrgan(<organs>5__1, (OrganType)0, <state>5__2.leftEye);
<mgr>5__5.ServerToggleOrgan(<organs>5__1, (OrganType)1, <state>5__2.rightEye);
<mgr>5__5.ServerToggleOrgan(<organs>5__1, (OrganType)2, <state>5__2.body);
<mgr>5__5.ServerToggleOrgan(<organs>5__1, (OrganType)3, <state>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(<PillsRoutine>d__1))]
private static IEnumerator PillsRoutine(Upgrade item)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <PillsRoutine>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<Action> list = new List<Action>();
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<Action> list = new List<Action>();
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 <CursedRoutine>d__3 : IEnumerator<object>, IDisposable, IEnumerator
{
private int <>1__state;
private object <>2__current;
public GoldenChip chip;
private GameBase <game>5__1;
private int <uses>5__2;
private bool <cursed>5__3;
private long <loseAmount>5__4;
private MoneyManager <money>5__5;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <CursedRoutine>d__3(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<game>5__1 = null;
<money>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;
<game>5__1 = chip.Network_targetGame;
if ((Object)(object)<game>5__1 == (Object)null)
{
return false;
}
if (!CursedUses.ContainsKey(chip))
{
CursedUses[chip] = 3;
}
<uses>5__2 = CursedUses[chip];
<uses>5__2--;
CursedUses[chip] = <uses>5__2;
<cursed>5__3 = Random.value <= 0.25f;
if (<cursed>5__3)
{
<loseAmount>5__4 = (long)((float)<game>5__1.MaxBet * 1.5f * NetworkSingleton<UpgradeManager>.Instance.GetUpgradeData(((Component)((Item)chip).NetworkHolder).GetComponent<PlayerProfile>().steamId, (PlayerUpgradeType)2));
<money>5__5 = NetworkSingleton<MoneyManager>.Instance;
if ((Object)(object)<money>5__5 != (Object)null && (Object)(object)((Item)chip).NetworkHolder != (Object)null)
{
<money>5__5.TryChangeBalance(-<loseAmount>5__4, ((Component)((Item)chip).NetworkHolder).GetComponent<PlayerProfile>(), (ChangeType)4);
}
((ConsumableItem)chip).DestroyItem();
<money>5__5 = null;
}
else
{
<game>5__1.ServerSetBet(<game>5__1.MaxBet);
<game>5__1.ApplyGoldenChip(NetworkSingleton<UpgradeManager>.Instance.GetUpgradeData(((Component)((Item)chip).NetworkHolder).GetComponent<PlayerProfile>().steamId, (PlayerUpgradeType)2));
}
((InteractableBase)chip).TooltipMessage = $"<color=#00ffcc>{<uses>5__2} Uses Left</color>";
if (<uses>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<GoldenChip, int> CursedUses = new Dictionary<GoldenChip, int>();
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(<CursedRoutine>d__3))]
private static IEnumerator CursedRoutine(GoldenChip chip)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <CursedRoutine>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);
}
}
}
}