using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Numerics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Panik;
using TMPro;
using TwitchSDK;
using TwitchSDK.Interop;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("CloverPlusPlus")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("CloverPlusPlus")]
[assembly: AssemblyTitle("CloverPlusPlus")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[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 CloverPlusPlus
{
[BepInPlugin("com.cloverpit.cloverplusplus", "CloverPlusPlus", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
public const string PLUGIN_GUID = "com.cloverpit.cloverplusplus";
public const string PLUGIN_NAME = "CloverPlusPlus";
public const string PLUGIN_VERSION = "1.0.0";
internal static ManualLogSource Logger;
private void Awake()
{
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
Logger = ((BaseUnityPlugin)this).Logger;
Logger.LogInfo((object)"[CloverPlusPlus] Initializing CloverPlusPlus v1.0.0...");
new Harmony("com.cloverpit.cloverplusplus").PatchAll();
Logger.LogInfo((object)"[CloverPlusPlus] All patches applied successfully!");
}
}
}
namespace CloverPlusPlus.Patches
{
[HarmonyPatch(typeof(SlotMachineScript), "BurningLevelSet")]
public static class BurningLevelPatch
{
[HarmonyPrefix]
public static bool Prefix(BigInteger currentSpinCoins, ref int ____burningLevel)
{
BigInteger bigInteger = GameplayData.DebtGet();
if (bigInteger <= 0L || currentSpinCoins <= 0L)
{
____burningLevel = 0;
return false;
}
BigInteger bigInteger2 = currentSpinCoins * 10;
if (bigInteger2 >= bigInteger * 40)
{
____burningLevel = 7;
}
else if (bigInteger2 >= bigInteger * 30)
{
____burningLevel = 6;
}
else if (bigInteger2 >= bigInteger * 20)
{
____burningLevel = 5;
}
else if (bigInteger2 >= bigInteger * 10)
{
____burningLevel = 4;
}
else if (bigInteger2 >= bigInteger * 5)
{
____burningLevel = 3;
}
else if (bigInteger2 >= bigInteger * 3)
{
____burningLevel = 2;
}
else if (bigInteger2 >= bigInteger)
{
____burningLevel = 1;
}
else
{
____burningLevel = 0;
}
return false;
}
}
[HarmonyPatch(typeof(CameraController), "Update")]
public static class CameraStabilityPatch
{
[HarmonyPrefix]
public static void Prefix(CameraController __instance, ref float ___lerpSpeedMultiplier)
{
if ((Object)(object)__instance == (Object)null)
{
return;
}
float num = Tick.Time * 10f;
if (num > 0.0001f)
{
float num2 = 0.95f / num;
if (___lerpSpeedMultiplier > num2)
{
___lerpSpeedMultiplier = num2;
}
}
}
[HarmonyPostfix]
public static void Postfix(CameraController __instance, Transform ___targetTransform, CameraGame ___myCamera, ref float ___positionDifferenceMagnitude)
{
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: 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_003c: 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_004a: 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_0050: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)__instance == (Object)null || (Object)(object)___targetTransform == (Object)null || (Object)(object)___myCamera == (Object)null)
{
return;
}
Vector3 position = ___targetTransform.position;
Vector3 position2 = ((Component)___myCamera).transform.position;
if (!float.IsNaN(position2.x) && !float.IsInfinity(position2.x))
{
Vector3 val = position2 - position;
if (!(((Vector3)(ref val)).sqrMagnitude > 100f))
{
return;
}
}
((Component)___myCamera).transform.position = position;
___positionDifferenceMagnitude = 0f;
}
}
public static class CloverTicketsPatch
{
[HarmonyPatch(typeof(GameplayData), "CloverTicketsAdd")]
public static class TicketsAddPatch
{
[HarmonyPrefix]
public static bool Prefix(long value, bool addToStats)
{
if (GameplayData.Instance != null)
{
long num = GameplayData.CloverTicketsGet();
long num2;
if (value > 0 && num > 0 && long.MaxValue - num < value)
{
num2 = long.MaxValue;
}
else
{
num2 = num + value;
if (num2 < 0)
{
num2 = 0L;
}
}
GameplayData.CloverTicketsSet(num2);
if (addToStats && value > 0)
{
GameplayData.Stats_TicketsEarned_Add(value);
}
}
return false;
}
}
[HarmonyPatch(typeof(GameplayData), "Stats_TicketsEarned_Add")]
public static class StatsTicketsEarnedAddPatch
{
private static readonly FieldRef<GameplayData, long> StatsTicketsEarnedRef = AccessTools.FieldRefAccess<GameplayData, long>("stats_TicketsEarned");
[HarmonyPrefix]
public static bool Prefix(long ammount)
{
GameplayData instance = GameplayData.Instance;
if (instance != null && ammount > 0)
{
long num = StatsTicketsEarnedRef.Invoke(instance);
long num2;
if (num > 0 && long.MaxValue - num < ammount)
{
num2 = long.MaxValue;
}
else
{
num2 = num + ammount;
if (num2 < 0)
{
num2 = 0L;
}
}
StatsTicketsEarnedRef.Invoke(instance) = num2;
}
return false;
}
}
[HarmonyPatch(typeof(GameplayData), "CloverTicketsSet")]
public static class TicketsSetPatch
{
[HarmonyPrefix]
public static void Prefix(ref long value)
{
if (value < -1000000000)
{
value = long.MaxValue;
}
else if (value < 0)
{
value = 0L;
}
}
}
[HarmonyPatch(typeof(TicketMachineScript), "Start")]
public static class TicketMachineStartPatch
{
private static readonly FieldRef<TicketMachineScript, long> CloverTicketsOldRef = AccessTools.FieldRefAccess<TicketMachineScript, long>("cloverTicketsOld");
[HarmonyPostfix]
public static void Postfix(TicketMachineScript __instance)
{
if ((Object)(object)__instance != (Object)null)
{
CloverTicketsOldRef.Invoke(__instance) = GameplayData.CloverTicketsGet();
}
}
}
[HarmonyPatch(typeof(GeneralUiScript), "Update")]
public static class TicketsUiAnimationPatch
{
[HarmonyPrefix]
public static void Prefix(GeneralUiScript __instance, ref long ___ticketsOld, ref float ___ticketsAddTimer, ref bool ___ticketsUpdateAgain)
{
if ((Object)(object)__instance == (Object)null)
{
return;
}
long num = GameplayData.CloverTicketsGet();
if (___ticketsOld == 0L && num > 0)
{
___ticketsOld = num;
___ticketsAddTimer = 0f;
___ticketsUpdateAgain = false;
if ((Object)(object)__instance.textTickets != (Object)null)
{
((TMP_Text)__instance.textTickets).text = ClassExtensions.ToStringSmart((BigInteger)num) + " <sprite name=\"CloverTicket\">";
}
return;
}
long num2 = num - ___ticketsOld;
long num3 = ((num2 < 0) ? (-num2) : num2);
if (num3 > 100000000)
{
long num4 = num3 / 20;
long num5 = ((num2 > 0) ? 1 : (-1));
___ticketsOld += num5 * (num4 - 100000000);
}
}
[HarmonyPostfix]
public static void Postfix(GeneralUiScript __instance, long ___ticketsOld)
{
if ((Object)(object)__instance == (Object)null || (Object)(object)__instance.textTickets == (Object)null || (___ticketsOld <= 999999999999L && ___ticketsOld >= -999999999999L))
{
return;
}
string text = ((TMP_Text)__instance.textTickets).text;
if (!string.IsNullOrEmpty(text))
{
string text2 = ___ticketsOld.ToString();
if (text.Contains(text2))
{
((TMP_Text)__instance.textTickets).text = text.Replace(text2, ClassExtensions.ToStringSmart((BigInteger)___ticketsOld));
}
}
}
}
}
public static class CryptoSavePatch
{
[HarmonyPatch(typeof(PlatformDataMaster), "EncryptCustom")]
public static class EncryptPatch
{
[HarmonyPrefix]
public static bool Prefix(string data, string password, ref string __result)
{
if (string.IsNullOrEmpty(data))
{
__result = "";
return false;
}
if (string.IsNullOrEmpty(password))
{
__result = "";
return false;
}
char[] xorKey = GetXorKey(password);
int num = xorKey.Length;
int length = data.Length;
char[] array = new char[length];
for (int i = 0; i < length; i++)
{
array[i] = (char)(data[i] ^ xorKey[i % num]);
}
__result = new string(array);
return false;
}
}
[HarmonyPatch(typeof(PlatformDataMaster), "DecryptCustom")]
public static class DecryptPatch
{
[HarmonyPrefix]
public static bool Prefix(string cryptedData, string password, ref string __result)
{
if (string.IsNullOrEmpty(cryptedData))
{
__result = "";
return false;
}
if (string.IsNullOrEmpty(password))
{
__result = "";
return false;
}
char[] xorKey = GetXorKey(password);
int num = xorKey.Length;
int length = cryptedData.Length;
char[] array = new char[length];
for (int i = 0; i < length; i++)
{
array[i] = (char)(cryptedData[i] ^ xorKey[i % num]);
}
__result = new string(array);
return false;
}
}
private static int CryptoShiftsNumber(string password)
{
int num = 8;
for (int i = 0; i < password.Length; i++)
{
num += password[i];
}
while (num > 16 || num < 8)
{
if (num > 16)
{
num -= 16;
}
if (num < 8)
{
num += 8;
}
}
return num;
}
private static char[] GetXorKey(string password)
{
int num = CryptoShiftsNumber(password);
char[] array = password.ToCharArray();
int num2 = array.Length;
char[] array2 = new char[num2];
for (int i = 0; i < num; i++)
{
for (int j = 0; j < num2; j++)
{
int num3 = Mathf.Abs(array[j] % num2);
int num4 = Mathf.FloorToInt(Mathf.Repeat((float)(j + num3), (float)num2));
array2[j] = array[num4];
array2[j] ^= array[j];
}
}
return array2;
}
}
public static class DebtRangePatch
{
[HarmonyPatch(typeof(GameplayData), "DebtGetExt")]
public static class DebtGetExtPatch
{
[HarmonyPrefix]
public static void Prefix(ref BigInteger debtIndex)
{
if (debtIndex < 0L)
{
debtIndex = 0;
}
}
}
[HarmonyPatch(typeof(GameplayMaster), "FCall_DebtNext")]
public static class DebtNextOptimizationPatch
{
[HarmonyPrefix]
public static bool Prefix(bool increaseRoundsAsWell, bool lastDemoDeadline)
{
//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_00f7: Unknown result type (might be due to invalid IL or missing references)
//IL_00fa: Invalid comparison between Unknown and I4
//IL_0150: Unknown result type (might be due to invalid IL or missing references)
//IL_0153: Invalid comparison between Unknown and I4
//IL_010f: Unknown result type (might be due to invalid IL or missing references)
//IL_027a: Unknown result type (might be due to invalid IL or missing references)
//IL_027c: Invalid comparison between Unknown and I4
//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
//IL_01c6: Invalid comparison between Unknown and I4
//IL_0289: Unknown result type (might be due to invalid IL or missing references)
//IL_028c: Invalid comparison between Unknown and I4
//IL_0314: Unknown result type (might be due to invalid IL or missing references)
//IL_0316: Invalid comparison between Unknown and I4
//IL_0187: Unknown result type (might be due to invalid IL or missing references)
//IL_02ed: Unknown result type (might be due to invalid IL or missing references)
int num = GameplayData.RoundsLeftToDeadline();
Identifier val = GameplayData.RunModifier_GetCurrent();
GameplayData.DebtIndexAdd((BigInteger)1);
BigInteger bigInteger = GameplayData.DebtIndexGet();
bool num2 = GameplayData.AreWeOverTheDebtRange(bigInteger);
if (increaseRoundsAsWell)
{
GameplayData.RoundDeadlineTrail_Set(GameplayData.RoundOfDeadlineGet());
GameplayData.DeadlineRoundsIncrement();
}
GameplayData.RoundDeadlineTrail_AtDeadlineBegin_CheckpointSet();
if (num2)
{
int num3 = ClassExtensions.CastToInt(GameplayData.DebtOutOfRangeIndexAmmount(bigInteger));
int num4 = num3 + Mathf.Max(0, ClassExtensions.CastToInt(bigInteger) - 15);
BigInteger bigInteger3;
if (num4 <= 300)
{
BigInteger bigInteger2 = BigInteger.Pow(num3, Mathf.Max(0, num3 - 3));
if (bigInteger2 < 1L)
{
bigInteger2 = 1;
}
bigInteger3 = BigInteger.Pow(new BigInteger(6) << num4 - 1, num4) * bigInteger2;
}
else
{
BigInteger bigInteger4 = GameplayData.DebtOutOfRangeMultiplier_Get();
if (bigInteger4 < 1000L)
{
bigInteger4 = 1000;
}
bigInteger3 = bigInteger4 * 1000000000L;
}
GameplayData.DebtOutOfRangeMultiplier_Set(bigInteger3);
}
PowerupScript.SkeletonEreasePiecesLeftIntoDrawers();
if ((int)val == 14)
{
PowerupScript randomCharmToModify_OnTableOrSlot = AbilityScript.GetRandomCharmToModify_OnTableOrSlot();
if ((Object)(object)randomCharmToModify_OnTableOrSlot != (Object)null)
{
GameplayData.Powerup_Modifier_Set(randomCharmToModify_OnTableOrSlot.identifier, (Modifier)7, true);
}
PowerupScript randomCharmToModify_InDrawers = AbilityScript.GetRandomCharmToModify_InDrawers();
if ((Object)(object)randomCharmToModify_InDrawers != (Object)null)
{
randomCharmToModify_InDrawers.ModifierReEvaluate(false, true);
}
if ((Object)(object)randomCharmToModify_OnTableOrSlot != (Object)null || (Object)(object)randomCharmToModify_InDrawers != (Object)null)
{
RunModifierScript.TriggerAnimation_IfEquipped((Identifier)14);
}
}
if ((int)val == 15)
{
bool flipCoin = R.Rng_RunMod.FlipCoin;
RunModifierScript.TriggerAnimation_IfEquipped((Identifier)15);
for (int i = 0; i < PowerupScript.array_InDrawer.Length; i++)
{
PowerupScript val2 = PowerupScript.array_InDrawer[i];
if ((Object)(object)val2 != (Object)null)
{
if (flipCoin)
{
PowerupScript.ThrowAway(val2.identifier, false);
}
else
{
val2.ModifierReEvaluate(false, true);
}
}
}
}
GameplayData.StoreRestockExtraCostSet((BigInteger)0);
try
{
StoreCapsuleScript.Restock(true, false, (PowerupScript[])null, false, false);
if ((int)val == 1)
{
for (int j = 0; j < StoreCapsuleScript.storePowerups.Length; j++)
{
StoreCapsuleScript.storePowerups[j] = null;
}
StoreCapsuleScript.RefreshCostTextAll();
RunModifierScript.TriggerAnimation_IfEquipped((Identifier)1);
}
}
catch (Exception ex)
{
Debug.LogError((object)("Error while restocking store: " + ex.Message));
}
int num5 = PowerupScript.ModifiedPowerups_GetCount((Modifier)5);
if (num5 > 0)
{
GameplayData.StoreFreeRestocksSet(GameplayData.StoreFreeRestocksGet() + num5);
}
if (GameplayData.Powerup_Jimbo_IsAbilityAvailable((JimboAbility)17, true))
{
GameplayData.StoreFreeRestocksSet(GameplayData.StoreFreeRestocksGet() + 2);
PowerupScript.PlayTriggeredAnimation((Identifier)150);
}
if (PowerupScript.EvilDealBonusMultiplier() > 1)
{
GameplayData.StoreFreeRestocksSet(GameplayData.StoreFreeRestocksGet() + 2);
PowerupScript.PlayTriggeredAnimation((Identifier)106);
}
PowerupScript.Limbo_ResetOnDeadlineEnd();
GameplayData.Powerup_Rage_666Counter = 0;
PowerupScript.SinReset_OnDeadlineEnd();
GameplayData.SymbolModifier_SMult_Quantity = 0L;
if ((int)val == 3)
{
RunModifierScript.MFunc_SmallerStoreRestocksBonus();
RunModifierScript.TriggerAnimation_IfEquipped((Identifier)3);
}
if ((int)val == 17)
{
int count = PowerupScript.list_EquippedNormal.Count;
if (count > 5)
{
PowerupScript val3 = null;
int num6 = 100;
while ((Object)(object)val3 == (Object)null && num6 > 0)
{
num6--;
int index = R.Rng_RunMod.Range(0, count);
val3 = PowerupScript.list_EquippedNormal[index];
}
if ((Object)(object)val3 != (Object)null)
{
RunModifierScript.TriggerAnimation_IfEquipped((Identifier)17);
PowerupScript.ThrowAway(val3.identifier, false);
GameplayData.StoreFreeRestocksSet(GameplayData.StoreFreeRestocksGet() + 2);
}
}
}
if (!lastDemoDeadline)
{
PhoneScript.ResetForDeadline();
}
RedButtonScript.ResetTiming((Timing)3);
if ((int)val != 2)
{
RedButtonScript.RestoreCharges(num);
}
GameplayData.Stats_DeadlinesCompleted_Add();
PowerupScript.RefreshPlacementAll();
return false;
}
}
}
[HarmonyPatch(typeof(DiegeticMenuElement), "IsMouseOver")]
public static class DiegeticMenuRaycastPatch
{
private static readonly FieldRef<DiegeticMenuElement, Camera> GameCameraRef = AccessTools.FieldRefAccess<DiegeticMenuElement, Camera>("gameCamera");
private static readonly FieldRef<DiegeticMenuElement, float> MinDistanceRef = AccessTools.FieldRefAccess<DiegeticMenuElement, float>("minimumMouseDistance");
private static readonly FieldRef<DiegeticMenuElement, DiegeticMenuController> ControllerRef = AccessTools.FieldRefAccess<DiegeticMenuElement, DiegeticMenuController>("myController");
private static int _lastRaycastFrame = -1;
private static DiegeticMenuElement _closestHoveredElement;
private static float _closestDistance = float.MaxValue;
private static readonly RaycastHit[] SharedHits = (RaycastHit[])(object)new RaycastHit[16];
[HarmonyPrefix]
public static bool Prefix(DiegeticMenuElement __instance, ref bool __result)
{
//IL_0105: 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_0116: Unknown result type (might be due to invalid IL or missing references)
//IL_011b: Unknown result type (might be due to invalid IL or missing references)
//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
//IL_00de: Unknown result type (might be due to invalid IL or missing references)
//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)__instance == (Object)null || !((Behaviour)__instance).enabled)
{
__result = false;
return false;
}
if (Time.frameCount != _lastRaycastFrame)
{
_lastRaycastFrame = Time.frameCount;
_closestHoveredElement = null;
_closestDistance = float.MaxValue;
bool flag = VirtualCursors.IsCursorVisible(0, true);
if (!flag && !AimCrossScript.IsEnabled())
{
__result = false;
return false;
}
Camera val = GameCameraRef.Invoke(__instance);
if ((Object)(object)val == (Object)null && CameraGame.list != null && CameraGame.list.Count > 0 && (Object)(object)CameraGame.list[0] != (Object)null)
{
val = CameraGame.list[0].myCamera;
}
if ((Object)(object)val == (Object)null)
{
__result = false;
return false;
}
Vector2 val2 = default(Vector2);
((Vector2)(ref val2))..ctor(0.5f, 0.5f);
if (flag)
{
Vector2 val3 = default(Vector2);
((Vector2)(ref val3))..ctor((float)val.pixelWidth, (float)val.pixelHeight);
val2 = VirtualCursors.CursorPositionNormalizedCenteredGet_ReferenceResolution(0, val3);
val2.x += 0.5f;
val2.y += 0.5f;
}
int num = Physics.RaycastNonAlloc(val.ViewportPointToRay(new Vector3(val2.x, val2.y, 0f)), SharedHits, 100f);
DiegeticMenuController activeMenu = DiegeticMenuController.ActiveMenu;
for (int i = 0; i < num; i++)
{
Collider collider = ((RaycastHit)(ref SharedHits[i])).collider;
if (!((Object)(object)collider == (Object)null))
{
DiegeticMenuElement component = ((Component)collider).GetComponent<DiegeticMenuElement>();
if (!((Object)(object)component == (Object)null) && !((Object)(object)ControllerRef.Invoke(component) != (Object)(object)activeMenu) && ((Behaviour)component).enabled && ((RaycastHit)(ref SharedHits[i])).distance < _closestDistance)
{
_closestDistance = ((RaycastHit)(ref SharedHits[i])).distance;
_closestHoveredElement = component;
}
}
}
}
float num2 = MinDistanceRef.Invoke(__instance);
__result = (Object)(object)__instance == (Object)(object)_closestHoveredElement && _closestDistance <= num2;
return false;
}
}
[HarmonyPatch(typeof(SlotMachineScript), "_ComputePatternValue")]
public static class PatternValueOverflowPatch
{
private static readonly BigInteger MaxDoubleBigInt = new BigInteger(double.MaxValue);
[HarmonyPrefix]
public static bool Prefix(Kind patternKind, Kind symbolKind, ref BigInteger __result)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0002: Invalid comparison between Unknown and I4
//IL_0004: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Invalid comparison between Unknown and I4
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Invalid comparison between Unknown and I4
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Invalid comparison between Unknown and I4
//IL_001d: 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)
if ((int)patternKind == -1 || (int)patternKind == 16)
{
return true;
}
if ((int)symbolKind == -1 || (int)symbolKind == 9)
{
return true;
}
BigInteger bigInteger = GameplayData.AllSymbolsMultiplierGet(true);
BigInteger bigInteger2 = GameplayData.Symbol_CoinsOverallValue_Get(symbolKind);
BigInteger bigInteger3 = GameplayData.AllPatternsMultiplierGet(true);
double num = GameplayData.Pattern_ValueOverall_Get(patternKind, true);
BigInteger bigInteger4 = ((!double.IsInfinity(num) && !double.IsNaN(num) && !(num >= 1.7976931348623156E+306)) ? new BigInteger(100.0 * num) : MaxDoubleBigInt);
__result = bigInteger * bigInteger2 * bigInteger3 * bigInteger4 / 100;
return false;
}
}
[HarmonyPatch(typeof(PosterScript), "FontSizePercGet_SymbolsValue")]
public static class PosterPatch
{
[HarmonyPrefix]
public static bool Prefix(Kind symbolKind, ref float __result)
{
//IL_0023: 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_0056: Unknown result type (might be due to invalid IL or missing references)
List<Kind> list = GameplayData.SymbolsValueList_Get();
if (list == null || list.Count == 0)
{
__result = 100f;
return false;
}
BigInteger bigInteger = GameplayData.Symbol_CoinsOverallValue_Get(list[list.Count - 1]);
BigInteger bigInteger2 = GameplayData.Symbol_CoinsOverallValue_Get(list[0]);
BigInteger bigInteger3 = bigInteger2 - bigInteger;
if (bigInteger3 <= 0L)
{
__result = 100f;
return false;
}
BigInteger bigInteger4 = GameplayData.Symbol_CoinsOverallValue_Get(symbolKind);
if (bigInteger4 <= bigInteger)
{
__result = 75f;
return false;
}
if (bigInteger4 >= bigInteger2)
{
__result = 100f;
return false;
}
float num = FastRatio(bigInteger4 - bigInteger, bigInteger3);
__result = (0.75f + 0.25f * num) * 100f;
return false;
}
private static float FastRatio(BigInteger n, BigInteger d)
{
if (d <= 0L)
{
return 0f;
}
if (n >= d)
{
return 1f;
}
byte[] array = n.ToByteArray();
byte[] array2 = d.ToByteArray();
if (array2.Length <= 8)
{
return (float)((double)n / (double)d);
}
int num = array.Length - 1;
while (num > 0 && array[num] == 0)
{
num--;
}
int num2 = array2.Length - 1;
while (num2 > 0 && array2[num2] == 0)
{
num2--;
}
if (num2 - num > 1)
{
return 0f;
}
ulong num3 = ReadTop32(array, num);
ulong num4 = ReadTop32(array2, num2);
if (num2 > num)
{
num4 <<= 8;
}
if (num4 == 0L)
{
return 0f;
}
return Mathf.Clamp01((float)num3 / (float)num4);
}
private static ulong ReadTop32(byte[] b, int high)
{
ulong num = 0uL;
for (int i = 0; i < 4; i++)
{
int num2 = high - i;
num = (num << 8) | (ulong)((num2 >= 0) ? b[num2] : 0);
}
return num;
}
}
[HarmonyPatch(typeof(Strings), "Sanitize")]
public static class SanitizePatch
{
private const string SpriteSpin = "<sprite name=\"SpinSymbol32\">";
private const string SpriteCoinOrange = "<sprite name=\"CoinSymbolOrange64\">";
[HarmonyPrefix]
public static bool Prefix(SantizationKind santizationKind, string input, SanitizationSubKind subKind, ref string __result)
{
if (string.IsNullOrEmpty(input))
{
__result = input;
return false;
}
if (input.IndexOf('[') == -1 && input.IndexOf('@') == -1 && input.IndexOf('€') == -1 && input.IndexOf('$') == -1 && input.IndexOf('#') == -1 && input.IndexOf("666", StringComparison.Ordinal) == -1 && input.IndexOf("999", StringComparison.Ordinal) == -1)
{
__result = input;
return false;
}
return true;
}
[HarmonyPostfix]
public static void Postfix(ref string __result)
{
if (!string.IsNullOrEmpty(__result))
{
if (__result.IndexOf('@') != -1)
{
__result = __result.Replace("@", "<sprite name=\"SpinSymbol32\">");
}
if (__result.IndexOf('€') != -1)
{
__result = __result.Replace("€", "<sprite name=\"CoinSymbolOrange64\">");
}
}
}
}
public static class SlotBetCostPatch
{
[HarmonyPatch(typeof(GameplayData), "GetHypotehticalMaxSpinsBuyable")]
public static class HypoSpinsPatch
{
[HarmonyPrefix]
public static bool Prefix(ref int __result)
{
if (GameplayData.Instance == null)
{
__result = 0;
return false;
}
BigInteger bigInteger = GameplayData.CoinsGet();
BigInteger bigInteger2 = GameplayData.SpinCostGet_Single();
if (bigInteger2 <= 0L)
{
__result = GameplayData.MaxSpins_Get();
return false;
}
if (bigInteger < bigInteger2)
{
__result = 0;
return false;
}
int num = GameplayData.MaxSpins_Get();
if (num <= 1)
{
__result = 1;
return false;
}
BigInteger bigInteger3 = bigInteger2 * num;
if (bigInteger >= bigInteger3)
{
__result = num;
return false;
}
for (int num2 = num - 1; num2 >= 2; num2--)
{
if (bigInteger >= bigInteger2 * num2)
{
__result = num2;
return false;
}
}
__result = 1;
return false;
}
}
[HarmonyPatch(typeof(SlotMachineScript), "TopTextSet_BetCost")]
public static class TopTextBetCostPatch
{
private static BigInteger _lastBetCost = BigInteger.MinusOne;
private static int _lastSpins = -1;
[HarmonyPrefix]
public static bool Prefix(SlotMachineScript __instance, bool forceUpdate)
{
if (forceUpdate)
{
return true;
}
int hypotehticalMaxSpinsBuyable = GameplayData.GetHypotehticalMaxSpinsBuyable();
BigInteger bigInteger = GameplayData.SpinCostGet_Single() * hypotehticalMaxSpinsBuyable;
if (hypotehticalMaxSpinsBuyable == _lastSpins && bigInteger == _lastBetCost)
{
return false;
}
_lastSpins = hypotehticalMaxSpinsBuyable;
_lastBetCost = bigInteger;
return true;
}
}
}
public static class StoreCapsulePatch
{
[HarmonyPatch(typeof(StoreCapsuleScript), "Restock")]
public static class RestockPrefixPatch
{
[HarmonyPrefix]
public static void Prefix()
{
ResetCheckCount();
}
}
[HarmonyPatch(typeof(StoreCapsuleScript), "PowerupIsForbiddenToRestock")]
public static class ForbiddenPowerupPatch
{
[HarmonyPrefix]
public static bool Prefix(ref bool __result)
{
_forbiddenCheckCount++;
if (_forbiddenCheckCount > 200)
{
__result = false;
return false;
}
return true;
}
}
private static int _forbiddenCheckCount;
public static void ResetCheckCount()
{
_forbiddenCheckCount = 0;
}
}
[HarmonyPatch(typeof(ClassExtensions), "ToStringSmart", new Type[] { typeof(BigInteger) })]
public static class ToStringSmartPatch
{
private struct CacheEntry
{
public BigInteger Key;
public string Value;
}
private static readonly CacheEntry[] Cache = new CacheEntry[64];
[HarmonyPrefix]
public static bool Prefix(BigInteger n, ref string __result)
{
int num = n.GetHashCode() & 0x3F;
if (Cache[num].Value != null && Cache[num].Key == n)
{
__result = Cache[num].Value;
return false;
}
string text = ((!(n <= 999999999999L) || !(n >= -999999999999L)) ? FastScientific(n) : n.ToString());
Cache[num] = new CacheEntry
{
Key = n,
Value = text
};
__result = text;
return false;
}
public static string FastScientific(BigInteger n)
{
bool flag = n.Sign < 0;
byte[] array = (flag ? (-n) : n).ToByteArray();
int num = array.Length - 1;
while (num > 0 && array[num] == 0)
{
num--;
}
if (num <= 16)
{
return n.ToString("E4");
}
byte num2 = array[num];
int num3 = 0;
for (int num4 = num2; num4 > 0; num4 >>= 1)
{
num3++;
}
int num5 = num * 8 + num3;
ulong num6 = 0uL;
for (int i = 0; i < 8; i++)
{
int num7 = num - i;
ulong num8 = (ulong)((num7 >= 0) ? array[num7] : 0);
num6 = (num6 << 8) | num8;
}
int num9 = 8 - num3;
num6 <<= num9;
if (num >= 8 && num9 > 0)
{
uint num10 = array[num - 8];
num6 |= num10 >> 8 - num9;
}
double num11 = Math.Log10(num6) + (double)(num5 - 64) * 0.3010299956639812;
int num12 = (int)Math.Floor(num11);
double num13 = Math.Pow(10.0, num11 - (double)num12);
if (num13 >= 9.99995)
{
num13 /= 10.0;
num12++;
}
string arg = (flag ? "-" : "");
return $"{arg}{num13:F4}E+{num12}";
}
}
[HarmonyPatch(typeof(TwitchMaster), "UpdateAuthState")]
public static class TwitchMasterPatch
{
private static readonly FieldRef<TwitchMaster, GameTask<AuthState>> CurAuthStateRef = AccessTools.FieldRefAccess<TwitchMaster, GameTask<AuthState>>("curAuthState");
private static readonly FieldRef<TwitchMaster, GameTask<AuthenticationInfo>> AuthInfoTaskRef = AccessTools.FieldRefAccess<TwitchMaster, GameTask<AuthenticationInfo>>("AuthInfoTask");
private static readonly FieldRef<TwitchMaster, bool> UrlOpenedRef = AccessTools.FieldRefAccess<TwitchMaster, bool>("urlOpened");
private static readonly FieldRef<TwitchMaster, string> TwitchMenuStringRef = AccessTools.FieldRefAccess<TwitchMaster, string>("twitchMenuString");
[HarmonyPrefix]
public static bool Prefix(TwitchMaster __instance)
{
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
//IL_006e: Unknown result type (might be due to invalid IL or missing references)
//IL_0070: Invalid comparison between Unknown and I4
//IL_00c9: Invalid comparison between Unknown and I4
if (!TwitchMaster.IsTwitchSupported())
{
return false;
}
try
{
ref GameTask<AuthState> reference = ref CurAuthStateRef.Invoke(__instance);
ref GameTask<AuthenticationInfo> reference2 = ref AuthInfoTaskRef.Invoke(__instance);
ref bool reference3 = ref UrlOpenedRef.Invoke(__instance);
ref string reference4 = ref TwitchMenuStringRef.Invoke(__instance);
if (reference2 == null && reference == null)
{
return false;
}
reference = Twitch.API.GetAuthState();
if (reference == null)
{
return false;
}
AuthStatus status = reference.MaybeResult.Status;
if ((int)status == 3)
{
string text = "";
UserInfo val = Twitch.API.GetMyUserInfo()?.MaybeResult;
if (val != (UserInfo)null)
{
text = val.DisplayName;
}
reference4 = Translation.Get("MENU_OPTION_SETTINGS_TWITCH_MODE_NAME") + text;
if (MainMenuScript.IsEnabled())
{
MainMenuScript.instance.OptionsUpdate();
}
}
if ((int)status == 2 && reference2 != null)
{
AuthenticationInfo maybeResult = reference2.MaybeResult;
if (maybeResult != (AuthenticationInfo)null && !reference3)
{
Application.OpenURL(maybeResult.Uri);
reference3 = true;
if (MainMenuScript.IsEnabled())
{
MainMenuScript.instance.OptionsUpdate();
}
}
}
}
catch (Exception)
{
}
return false;
}
}
}