using System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using HarmonyLib; using Microsoft.CodeAnalysis; using Photon.Pun; using UnityEngine; [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.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyCompany("GambitGambler")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+7465be75949cc43be2e671cb148d287f95b5ce03")] [assembly: AssemblyProduct("GambitGambler")] [assembly: AssemblyTitle("GambitGambler")] [assembly: AssemblyVersion("1.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace GambitGambler { [BepInPlugin("GambitGambler", "Gambit Gambler", "1.0.7")] public class GambitGambler : BaseUnityPlugin { private const int VAL_1K = 1; private const int VAL_5K = 5; private const int VAL_10K = 10; private void Awake() { ((BaseUnityPlugin)this).Logger.LogInfo((object)"Gambit Gambler Loaded!"); Harmony.CreateAndPatchAll(typeof(GambitGambler), (string)null); } [HarmonyPatch(typeof(EnemySpinny), "Awake")] [HarmonyPostfix] private static void ConfigureWheel(EnemySpinny __instance) { //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) Colors[] array = new Colors[9]; RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/); Colors[] array2 = (Colors[])(object)array; int num = Mathf.Min(new int[3] { __instance.SliceColours.Length, __instance.colors.Length, array2.Length }); for (int i = 0; i < num; i++) { __instance.SliceColours[i] = array2[i]; __instance.colors[i] = GetColor(array2[i]); } } [HarmonyPatch(typeof(EnemySpinny), "Update")] [HarmonyPrefix] private static void EnemySpinny_Update_Prefix(EnemySpinny __instance) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Invalid comparison between Unknown and I4 //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Invalid comparison between Unknown and I4 //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Invalid comparison between Unknown and I4 //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Invalid comparison between Unknown and I4 //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Invalid comparison between Unknown and I4 //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Invalid comparison between Unknown and I4 //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Invalid comparison between Unknown and I4 //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Invalid comparison between Unknown and I4 if ((int)__instance.currentState == 10 && !(bool)AccessTools.Field(typeof(EnemySpinny), "jinglePlayed").GetValue(__instance) && (int)__instance.GetCurrentColorbyAngle(__instance.targetAngleDegrees) == 4) { __instance.enemySpinnyAnim.jingleRed.Play(((Component)__instance).transform.position, 1f, 1f, 1f, 1f); __instance.enemySpinnyAnim.hurtParticle.PlayParticles(); AccessTools.Field(typeof(EnemySpinny), "jinglePlayed").SetValue(__instance, true); } if ((int)__instance.currentState == 11 && !(bool)AccessTools.Field(typeof(EnemySpinny), "effectDone").GetValue(__instance)) { Colors currentColorbyAngle = __instance.GetCurrentColorbyAngle(__instance.targetAngleDegrees); if ((int)currentColorbyAngle == 2 || (int)currentColorbyAngle == 3 || (int)currentColorbyAngle == 1) { AccessTools.Field(typeof(EnemySpinny), "moneyToBeSpawned").SetValue(__instance, true); AccessTools.Field(typeof(EnemySpinny), "isCollidingMoney").SetValue(__instance, false); __instance.enemySpinnyAnim.moneyPrizeParticle.PlayParticles(); } else if ((int)currentColorbyAngle == 4) { ExecuteBankruptcy(__instance); } else if ((int)currentColorbyAngle == 0) { ExecuteSteal(__instance); } ((MonoBehaviour)__instance).Invoke("CameraShake", 0f); AccessTools.Field(typeof(EnemySpinny), "effectDone").SetValue(__instance, true); } } [HarmonyPatch(typeof(EnemySpinny), "SpawnMoneyBag")] [HarmonyPrefix] private static bool SpawnRewards(EnemySpinny __instance) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Expected I4, but got Unknown //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Invalid comparison between Unknown and I4 //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) Colors currentColorbyAngle = __instance.GetCurrentColorbyAngle(__instance.targetAngleDegrees); int num = (int)AccessTools.Field(typeof(RoundDirector), "haulGoal").GetValue(RoundDirector.instance); if (num <= 0) { num = 10; } int num2 = 0; int num3 = 0; Colors val = currentColorbyAngle; Colors val2 = val; switch (val2 - 1) { case 2: num2 = num; num3 = 1; break; case 0: num2 = num / 2; num3 = ((num2 > 10000) ? 3 : 2); break; case 1: num2 = num * Random.Range(15, 31) / 100; if (num2 < 1) { num2 = 1; } num3 = ((num2 > 5000) ? 1 : 0); break; } AccessTools.Method(typeof(EnemySpinny), "MoneyEffect", (Type[])null, (Type[])null).Invoke(__instance, null); AccessTools.Field(typeof(EnemySpinny), "moneyToBeSpawned").SetValue(__instance, false); if (num3 > 0) { SpawnSmartLoot(__instance, num2, num3); } else { DirectDeposit(__instance, num2 / 1000); } string text = FormatK(num2); string text2 = (((int)currentColorbyAngle == 3) ? ("JACKPOT! Gambit gave you: $" + text) : ("YOU WIN! Gambit gave you: $" + text)); SemiFunc.UIFocusText(text2, GetColor(currentColorbyAngle), Color.white, 5f); return false; } private static void ExecuteSteal(EnemySpinny instance) { //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)instance.playerTarget != (Object)(object)SemiFunc.PlayerAvatarLocal()) { return; } int num = SemiFunc.StatGetRunCurrency(); int num2 = ((Random.Range(1, 101) <= 80) ? Random.Range(15, 31) : Random.Range(31, 51)); int num3 = (int)AccessTools.Field(typeof(RoundDirector), "haulGoal").GetValue(RoundDirector.instance); int num4 = num3 / 1000; int num5 = Mathf.Max(1, num4 * 5 / 100); int num6 = num * num2 / 100; if (num6 < num5) { num6 = num5; } if (num < num6) { if (num > 0) { SemiFunc.StatSetRunCurrency(0); } TriggerEnemyAlert(instance, num6); } else { int num7 = num - num6; SemiFunc.StatSetRunCurrency(num7); TriggerMoneyUI(); string text = ((num2 > 30) ? "GAMBIT WAS GREEDY!" : "YOU LOST!"); SemiFunc.UIFocusText(text + " Gambit won and stole your money. You lost: $" + FormatK(num6), Color.red, Color.white, 4f); instance.enemySpinnyAnim.smallhurtParticle.Play(true); } } private static void ExecuteBankruptcy(EnemySpinny instance) { //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)instance.playerTarget != (Object)(object)SemiFunc.PlayerAvatarLocal())) { int num = SemiFunc.StatGetRunCurrency(); if (num <= 0) { TriggerEnemyAlert(instance, 0); return; } string text = FormatK(num); SemiFunc.StatSetRunCurrency(0); TriggerMoneyUI(); SemiFunc.UIFocusText("TOTAL BANKRUPTCY! The Gambit took all of your money and you lost everything ($" + text + ")", Color.black, Color.red, 6f); instance.enemySpinnyAnim.smallhurtParticle.Play(true); instance.enemySpinnyAnim.HurtSound(); } } private static void DirectDeposit(EnemySpinny instance, int kAmount) { if (!SemiFunc.IsMultiplayer() || !((Object)(object)instance.playerTarget != (Object)(object)SemiFunc.PlayerAvatarLocal())) { int num = SemiFunc.StatGetRunCurrency(); SemiFunc.StatSetRunCurrency(num + kAmount); TriggerMoneyUI(); } } private static void SpawnSmartLoot(EnemySpinny instance, int totalAmountRaw, int count) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Expected I4, but got Unknown int num = totalAmountRaw / count; GameObject val = AssetManager.instance.surplusValuableSmall; Type val2 = (Type)1; if (num > 10000) { val = AssetManager.instance.surplusValuableBig; val2 = (Type)3; } else if (num > 5000) { val = AssetManager.instance.surplusValuableMedium; val2 = (Type)2; } for (int i = 0; i < count; i++) { Vector3 val3 = instance.moneyBagSpawnPoint.position + Random.insideUnitSphere * 0.5f; GameObject val4 = ((!SemiFunc.IsMultiplayer()) ? Object.Instantiate(val, val3, Quaternion.identity) : PhotonNetwork.InstantiateRoomObject("Valuables/" + ((Object)val).name, val3, Quaternion.identity, (byte)0, (object[])null)); ValuableObject component = val4.GetComponent(); if ((Object)(object)component != (Object)null) { AccessTools.Field(typeof(ValuableObject), "dollarValueOverride").SetValue(component, num); AccessTools.Field(typeof(ValuableObject), "volumeType").SetValue(component, (int)val2); AccessTools.Method(typeof(ValuableObject), "DollarValueSetLogic", (Type[])null, (Type[])null)?.Invoke(component, null); } } } private static void TriggerEnemyAlert(EnemySpinny instance, int missingAmountK) { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) string text; if (missingAmountK <= 0) { text = "YOU'RE BANKRUPT! You don't have anything to give Gambit, it got mad and alerted all nearby enemies."; } else { string text2 = FormatK(missingAmountK); text = "YOU FOOL! You gambled with Gambit but you don't have the $" + text2 + " it takes to pay him. He took the rest of your money and alerted all nearby enemies."; } SemiFunc.UIFocusText(text, Color.red, Color.white, 4f); instance.enemySpinnyAnim.smallhurtParticle.Play(true); instance.enemySpinnyAnim.HurtSound(); SemiFunc.EnemyInvestigate(((Component)instance).transform.position, 100f, false); } private static void TriggerMoneyUI() { if ((Object)(object)CurrencyUI.instance != (Object)null) { AccessTools.Method(typeof(SemiUI), "Show", (Type[])null, (Type[])null).Invoke(CurrencyUI.instance, null); AccessTools.Field(typeof(SemiUI), "showTimer").SetValue(CurrencyUI.instance, 2.5f); } } [HarmonyPatch(typeof(SemiUI), "Hide")] [HarmonyPrefix] private static bool PreventHide(SemiUI __instance) { if ((Object)(object)__instance == (Object)(object)CurrencyUI.instance && SemiFunc.RunIsLevel()) { float num = (float)AccessTools.Field(typeof(SemiUI), "showTimer").GetValue(__instance); if (num > 0f) { num -= Time.deltaTime; AccessTools.Field(typeof(SemiUI), "showTimer").SetValue(__instance, num); if (num > 0f) { return false; } } } return true; } private static string FormatK(int kAmount) { return SemiFunc.DollarGetString(kAmount) + "K"; } private static Color GetColor(Colors color) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected I4, but got Unknown //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //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) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) if (1 == 0) { } Color result = (Color)((int)color switch { 3 => Color.white, 1 => Color.yellow, 2 => Color.green, 0 => Color.red, 4 => Color.black, _ => Color.white, }); if (1 == 0) { } return result; } } }