using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using HarmonyLib;
using Microsoft.CodeAnalysis;
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")]
[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("com.repo.gambitgambler", "Gambit Gambler", "1.0.3")]
public class GambitGambler : BaseUnityPlugin
{
private const int THRESHOLD_MEDIUM = 5000;
private const int THRESHOLD_BIG = 10000;
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)
{
ExecuteTax(__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_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_0090: Unknown result type (might be due to invalid IL or missing references)
//IL_0092: Invalid comparison between Unknown and I4
//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
Colors currentColorbyAngle = __instance.GetCurrentColorbyAngle(__instance.targetAngleDegrees);
if (!CalculateDynamicReward(currentColorbyAngle, out var total, out var bags))
{
return false;
}
AccessTools.Method(typeof(EnemySpinny), "MoneyEffect", (Type[])null, (Type[])null).Invoke(__instance, null);
AccessTools.Field(typeof(EnemySpinny), "moneyToBeSpawned").SetValue(__instance, false);
if (bags == 0)
{
DirectDeposit(__instance, total);
}
else
{
SpawnLootBags(__instance, total, bags);
}
string text = SemiFunc.DollarGetString(total);
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 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)
{
if (!SemiFunc.RunIsLevel())
{
return true;
}
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 void ExecuteTax(EnemySpinny instance)
{
//IL_0091: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: 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();
if (num <= 0)
{
TriggerEnemyAlert(instance);
return;
}
float num2 = Random.Range(0.15f, 0.25f);
int num3 = Mathf.FloorToInt((float)num * num2);
if (num3 < 100)
{
num3 = num;
}
int num4 = num - num3;
SemiFunc.StatSetRunCurrency(num4);
TriggerMoneyUI();
string arg = SemiFunc.DollarGetString(num3);
SemiFunc.UIFocusText($"YOU LOSE! Gambit taxed {num2 * 100f:0}% of your funds: -${arg}", Color.red, Color.white, 4f);
instance.enemySpinnyAnim.smallhurtParticle.Play(true);
}
private static void ExecuteBankruptcy(EnemySpinny instance)
{
//IL_008b: Unknown result type (might be due to invalid IL or missing references)
//IL_0090: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)instance.playerTarget != (Object)(object)SemiFunc.PlayerAvatarLocal())
{
return;
}
int num = SemiFunc.StatGetRunCurrency();
if (num <= 0)
{
TriggerEnemyAlert(instance);
return;
}
int num2 = Mathf.FloorToInt((float)num * 0.5f);
int num3 = num - num2;
if (num3 <= 0)
{
num3 = 1;
}
SemiFunc.StatSetRunCurrency(num3);
TriggerMoneyUI();
string text = SemiFunc.DollarGetString(num2);
string text2 = SemiFunc.DollarGetString(num3);
SemiFunc.UIFocusText("MARKET CRASH! You lost 50% of your money (-$" + text + ")! Left: $" + text2, Color.red, Color.white, 5f);
instance.enemySpinnyAnim.smallhurtParticle.Play(true);
instance.enemySpinnyAnim.HurtSound();
}
private static void TriggerEnemyAlert(EnemySpinny instance)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
SemiFunc.UIFocusText("YOU'RE BROKE! Gambit alerted all nearby enemies.", Color.red, Color.white, 4f);
instance.enemySpinnyAnim.smallhurtParticle.Play(true);
instance.enemySpinnyAnim.HurtSound();
SemiFunc.EnemyInvestigate(((Component)instance).transform.position, 100f, false);
}
private static bool CalculateDynamicReward(Colors color, out int total, out int bags)
{
//IL_003c: 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_003f: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_0056: Expected I4, but got Unknown
total = 0;
bags = 0;
int num = (int)AccessTools.Field(typeof(RoundDirector), "haulGoal").GetValue(RoundDirector.instance);
if (num <= 0)
{
num = 10000;
}
switch (color - 1)
{
case 2:
total = RoundToNearestThousand(num);
bags = 1;
return true;
case 0:
total = RoundToNearestThousand((float)num * 0.5f);
if (total > 60000)
{
bags = 2;
}
else if (total > 30000)
{
bags = 3;
}
else if (total > 10000)
{
bags = 4;
}
else
{
bags = 5;
}
return true;
case 1:
{
float num2 = Random.Range(0.1f, 0.3f);
total = (int)((float)num * num2);
if (total > 5000)
{
bags = 1;
}
else
{
bags = 0;
}
return true;
}
default:
return false;
}
}
private static int RoundToNearestThousand(float val)
{
return Mathf.RoundToInt(val / 1000f) * 1000;
}
private static void DirectDeposit(EnemySpinny instance, int amount)
{
if (!SemiFunc.IsMultiplayer() || !((Object)(object)instance.playerTarget != (Object)(object)SemiFunc.PlayerAvatarLocal()))
{
int num = SemiFunc.StatGetRunCurrency();
SemiFunc.StatSetRunCurrency(num + amount);
TriggerMoneyUI();
}
}
private static void SpawnLootBags(EnemySpinny instance, int totalAmount, int count)
{
//IL_004c: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: 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_0065: Unknown result type (might be due to invalid IL or missing references)
//IL_0077: Unknown result type (might be due to invalid IL or missing references)
//IL_0079: Unknown result type (might be due to invalid IL or missing references)
int num = totalAmount / count;
GameObject val = AssetManager.instance.surplusValuableSmall;
if (num > 10000)
{
val = AssetManager.instance.surplusValuableBig;
}
else if (num > 5000)
{
val = AssetManager.instance.surplusValuableMedium;
}
for (int i = 0; i < count; i++)
{
Vector3 val2 = instance.moneyBagSpawnPoint.position + Random.insideUnitSphere * 0.5f;
if (!SemiFunc.IsMultiplayer())
{
GameObject val3 = Object.Instantiate<GameObject>(val, val2, Quaternion.identity);
AccessTools.Field(typeof(ValuableObject), "dollarValueOverride").SetValue(val3.GetComponent<ValuableObject>(), num);
}
}
}
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;
}
}
}