Decompiled source of GambitGambler v1.1.2

GambitGambler.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Configuration;
using ExitGames.Client.Photon;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using Photon.Realtime;
using TMPro;
using UnityEngine;
using UnityEngine.UI;

[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]
	[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 GambitGambler
{
	public enum PayoutDelivery
	{
		CurrentBehavior,
		BagsOnly,
		DirectDeposit
	}
	[Serializable]
	public sealed class GambitRules
	{
		public bool ExtraEncounters;

		public float SpawnChance = 50f;

		public int MaximumGambits = 3;

		public float RewardMultiplier = 1f;

		public PayoutDelivery Delivery;

		public float StealMultiplier = 1f;

		public float BankruptcyPercent = 100f;

		public bool AlertEnemies = true;

		public GambitRules Copy()
		{
			return (GambitRules)MemberwiseClone();
		}

		public bool IsValid()
		{
			return InRange(SpawnChance, 0f, 100f) && InRange(RewardMultiplier, 0f, 5f) && MaximumGambits >= 1 && MaximumGambits <= 5 && InRange(StealMultiplier, 0f, 3f) && InRange(BankruptcyPercent, 0f, 100f) && Enum.IsDefined(typeof(PayoutDelivery), Delivery);
		}

		private static bool InRange(float value, float min, float max)
		{
			return !float.IsNaN(value) && !float.IsInfinity(value) && value >= min && value <= max;
		}
	}
	public static class GambitConfig
	{
		public static ConfigEntry<KeyCode> MenuKeybind;

		private static ConfigEntry<bool> extraEncounters;

		private static ConfigEntry<bool> alertEnemies;

		private static ConfigEntry<int> maximumGambits;

		private static ConfigEntry<float> spawnChance;

		private static ConfigEntry<float> rewardMultiplier;

		private static ConfigEntry<float> stealMultiplier;

		private static ConfigEntry<float> bankruptcyPercent;

		private static ConfigEntry<PayoutDelivery> delivery;

		public static void Init(ConfigFile config)
		{
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Expected O, but got Unknown
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Expected O, but got Unknown
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Expected O, but got Unknown
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Expected O, but got Unknown
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: Expected O, but got Unknown
			MenuKeybind = config.Bind<KeyCode>("Controls", "Menu Keybind", (KeyCode)287, "Local settings-menu key; independent of ValuableTracker.");
			extraEncounters = config.Bind<bool>("Encounters", "Additional Encounters", false, "Host: roll once per gameplay level without a naturally selected Gambit.");
			spawnChance = config.Bind<float>("Encounters", "Additional Spawn Chance", 50f, new ConfigDescription("Percent chance to add one Gambit; zero leaves natural spawning unchanged.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 100f), Array.Empty<object>()));
			maximumGambits = config.Bind<int>("Encounters", "Maximum Gambits", 3, new ConfigDescription("Host: limit for mod-added Gambits, counting all existing Gambits including natural and temporarily despawned ones. Lowering it does not remove existing enemies.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 5), Array.Empty<object>()));
			rewardMultiplier = config.Bind<float>("Rewards", "Reward Multiplier", 1f, new ConfigDescription("Multiplier for existing quota-based rewards.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 5f), Array.Empty<object>()));
			delivery = config.Bind<PayoutDelivery>("Rewards", "Payout Delivery", PayoutDelivery.CurrentBehavior, "Current behavior, physical bags only, or direct currency deposits.");
			stealMultiplier = config.Bind<float>("Penalties", "Steal Multiplier", 1f, new ConfigDescription("Multiplier for the red outcome, including its minimum charge.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 3f), Array.Empty<object>()));
			bankruptcyPercent = config.Bind<float>("Penalties", "Bankruptcy Loss Percent", 100f, new ConfigDescription("Percentage of run currency lost on black.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 100f), Array.Empty<object>()));
			alertEnemies = config.Bind<bool>("Penalties", "Alert Nearby Enemies", true, "Alert nearby enemies when broke or unable to pay.");
		}

		public static GambitRules LocalRules()
		{
			return new GambitRules
			{
				ExtraEncounters = extraEncounters.Value,
				SpawnChance = spawnChance.Value,
				MaximumGambits = maximumGambits.Value,
				RewardMultiplier = rewardMultiplier.Value,
				Delivery = delivery.Value,
				StealMultiplier = stealMultiplier.Value,
				BankruptcyPercent = bankruptcyPercent.Value,
				AlertEnemies = alertEnemies.Value
			};
		}

		public static void Save(GambitRules rules)
		{
			extraEncounters.Value = rules.ExtraEncounters;
			spawnChance.Value = rules.SpawnChance;
			maximumGambits.Value = rules.MaximumGambits;
			rewardMultiplier.Value = rules.RewardMultiplier;
			delivery.Value = rules.Delivery;
			stealMultiplier.Value = rules.StealMultiplier;
			bankruptcyPercent.Value = rules.BankruptcyPercent;
			alertEnemies.Value = rules.AlertEnemies;
		}
	}
	[HarmonyPatch]
	public static class GambitEncounters
	{
		private static readonly MethodInfo Prepare = AccessTools.Method(typeof(LevelGenerator), "PrefabsPrepare", (Type[])null, (Type[])null);

		private static readonly MethodInfo Spawn = AccessTools.Method(typeof(LevelGenerator), "EnemySpawn", (Type[])null, (Type[])null);

		private static readonly FieldInfo SpawnTarget = AccessTools.Field(typeof(LevelGenerator), "EnemiesSpawnTarget");

		private static readonly FieldInfo FirstPoint = AccessTools.Field(typeof(EnemyParent), "firstSpawnPoint");

		private static readonly MethodInfo Activate = AccessTools.Method(typeof(EnemyParent), "Spawn", (Type[])null, (Type[])null);

		public static bool Spawning { get; private set; }

		public static string Status { get; private set; } = "";

		private static EnemySetup FindSetup()
		{
			return ((IEnumerable<EnemySetup>)Resources.FindObjectsOfTypeAll<EnemySetup>()).FirstOrDefault((Func<EnemySetup, bool>)((EnemySetup setup) => Object.op_Implicit((Object)(object)setup) && setup.spawnObjects != null && setup.spawnObjects.Any((PrefabRef prefab) => prefab != null && ((PrefabRef<GameObject>)(object)prefab).ResourcePath != null && ((PrefabRef<GameObject>)(object)prefab).ResourcePath.EndsWith("/Enemy - Spinny", StringComparison.OrdinalIgnoreCase))));
		}

		public static int GambitCount()
		{
			return Object.FindObjectsByType<EnemySpinny>((FindObjectsInactive)1, (FindObjectsSortMode)0).Length;
		}

		public static bool AtLimit()
		{
			return GambitCount() >= GambitSession.Instance.Rules.MaximumGambits;
		}

		[HarmonyPatch(typeof(EnemyDirector), "AmountSetup")]
		[HarmonyPostfix]
		private static void AddEncounter(EnemyDirector __instance, List<EnemySetup> ___enemyList, List<EnemySetup> ___enemyListCurrent, int ___enemyListIndex, ref int ___totalAmount)
		{
			if (!SemiFunc.IsMasterClientOrSingleplayer() || !SemiFunc.RunIsLevel() || !GambitSession.Instance.Rules.ExtraEncounters)
			{
				return;
			}
			EnemySetup val = FindSetup();
			if (!Object.op_Implicit((Object)(object)val))
			{
				GambitGambler.Instance.LogWarning("Gambit setup was not found; additional encounter skipped.");
			}
			else if (!___enemyListCurrent.Contains(val) && GambitCount() <= 0 && !AtLimit())
			{
				float spawnChance = GambitSession.Instance.Rules.SpawnChance;
				if (!(spawnChance <= 0f) && (!(spawnChance < 100f) || !(Random.Range(0f, 100f) >= spawnChance)))
				{
					___enemyList.Insert(___enemyListIndex + ___totalAmount, val);
					___enemyListCurrent.Add(val);
					___totalAmount++;
				}
			}
		}

		public static void SpawnNow()
		{
			if (!GambitSession.CanEdit || Spawning)
			{
				return;
			}
			if (!SemiFunc.RunIsLevel() || !SemiFunc.LevelGenDone())
			{
				Status = "START A LEVEL FIRST";
				return;
			}
			if (AtLimit())
			{
				Status = "GAMBIT LIMIT REACHED";
				return;
			}
			EnemySetup val = FindSetup();
			if (!Object.op_Implicit((Object)(object)val))
			{
				Status = "GAMBIT ASSET NOT AVAILABLE";
				return;
			}
			LevelGenerator generator = LevelGenerator.Instance;
			List<LevelPoint> source = SemiFunc.LevelPointsGetAll();
			List<PlayerAvatar> players = GameDirector.instance.PlayerList;
			LevelPoint val2 = (from candidate in source
				where Object.op_Implicit((Object)(object)candidate) && !candidate.Truck && players.All((PlayerAvatar player) => !Object.op_Implicit((Object)(object)player) || Vector3.Distance(((Component)player).transform.position, ((Component)candidate).transform.position) >= 12f)
				orderby Vector3.Distance(((Component)candidate).transform.position, ((Component)generator.LevelPathTruck).transform.position) descending
				select candidate).FirstOrDefault();
			if (!Object.op_Implicit((Object)(object)val2))
			{
				Status = "NO SAFE SPAWN POINT";
				return;
			}
			Spawning = true;
			Status = "PREPARING GAMBIT";
			((MonoBehaviour)GambitSession.Instance).StartCoroutine(SpawnRoutine(generator, val, val2));
		}

		private static IEnumerator SpawnRoutine(LevelGenerator generator, EnemySetup setup, LevelPoint point)
		{
			try
			{
				yield return (IEnumerator)Prepare.Invoke(generator, new object[3] { setup.spawnObjects, null, null });
				if (!Object.op_Implicit((Object)(object)generator) || (Object)(object)generator != (Object)(object)LevelGenerator.Instance || !Object.op_Implicit((Object)(object)point) || !GambitSession.CanEdit || !SemiFunc.RunIsLevel() || !SemiFunc.LevelGenDone())
				{
					yield break;
				}
				if (AtLimit())
				{
					Status = "GAMBIT LIMIT REACHED";
					yield break;
				}
				HashSet<EnemySpinny> existing = new HashSet<EnemySpinny>(Object.FindObjectsByType<EnemySpinny>((FindObjectsInactive)1, (FindObjectsSortMode)0));
				int previousTarget = (int)SpawnTarget.GetValue(generator);
				try
				{
					Spawn.Invoke(generator, new object[2]
					{
						setup,
						((Component)point).transform.position
					});
				}
				finally
				{
					SpawnTarget.SetValue(generator, previousTarget);
				}
				EnemySpinny gambit = ((IEnumerable<EnemySpinny>)Object.FindObjectsByType<EnemySpinny>((FindObjectsInactive)1, (FindObjectsSortMode)0)).FirstOrDefault((Func<EnemySpinny, bool>)((EnemySpinny candidate) => !existing.Contains(candidate)));
				if (!Object.op_Implicit((Object)(object)gambit))
				{
					Status = "SPAWN FAILED - CHECK LOG";
					yield break;
				}
				EnemyParent parent = ((Component)gambit).GetComponentInParent<EnemyParent>();
				float deadline = Time.realtimeSinceStartup + 15f;
				while (Object.op_Implicit((Object)(object)parent) && Object.op_Implicit((Object)(object)generator) && (Object)(object)generator == (Object)(object)LevelGenerator.Instance && GambitSession.CanEdit && !EnemyDirector.instance.enemiesSpawned.Contains(parent) && Time.realtimeSinceStartup < deadline)
				{
					yield return null;
				}
				if (Object.op_Implicit((Object)(object)parent) && Object.op_Implicit((Object)(object)generator) && !((Object)(object)generator != (Object)(object)LevelGenerator.Instance) && GambitSession.CanEdit)
				{
					if (!EnemyDirector.instance.enemiesSpawned.Contains(parent))
					{
						Status = "GAMBIT SETUP TIMED OUT";
						yield break;
					}
					FirstPoint.SetValue(parent, point);
					Activate.Invoke(parent, null);
					Status = "GAMBIT SPAWNED";
				}
			}
			finally
			{
				Spawning = false;
				if (Status == "PREPARING GAMBIT")
				{
					Status = "SPAWN CANCELLED - CHECK LOG";
				}
			}
		}
	}
	[HarmonyPatch]
	[BepInPlugin("GambitGambler", "Gambit Gambler", "1.1.2")]
	public class GambitGambler : BaseUnityPlugin
	{
		public const string Version = "1.1.2";

		private static CurrencyUI currencyDisplay;

		private static float currencyVisibleUntil;

		private const int VAL_1K = 1;

		private const int VAL_5K = 5;

		private const int VAL_10K = 10;

		public static GambitGambler Instance { get; private set; }

		public void LogWarning(string message)
		{
			((BaseUnityPlugin)this).Logger.LogWarning((object)message);
		}

		private void Awake()
		{
			Instance = this;
			GambitConfig.Init(((BaseUnityPlugin)this).Config);
			((Component)this).gameObject.AddComponent<GambitSession>();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Gambit Gambler Loaded!");
			Harmony.CreateAndPatchAll(typeof(GambitGambler).Assembly, (string)null);
		}

		[HarmonyPatch(typeof(EnemySpinny), "Awake")]
		[HarmonyPostfix]
		private static void ConfigureWheel(EnemySpinny __instance)
		{
			//IL_0074: 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)
			if (!Object.op_Implicit((Object)(object)((Component)__instance).GetComponent<GambitSpinState>()))
			{
				((Component)__instance).gameObject.AddComponent<GambitSpinState>();
			}
			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), "GetAndSyncRandomRotationRPC")]
		[HarmonyPostfix]
		private static void CaptureSpinRules(EnemySpinny __instance)
		{
			GambitSpinState component = ((Component)__instance).GetComponent<GambitSpinState>();
			component.Rules = GambitSession.Instance.Rules.Copy();
			component.RewardHandled = false;
		}

		private static GambitRules SpinRules(EnemySpinny instance)
		{
			return ((Component)instance).GetComponent<GambitSpinState>().Rules ?? GambitSession.Instance.Rules;
		}

		[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_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Invalid comparison between Unknown and I4
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Invalid comparison between Unknown and I4
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Invalid comparison between Unknown and I4
			//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b7: Invalid comparison between Unknown and I4
			//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cb: 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))
			{
				return;
			}
			Colors currentColorbyAngle = __instance.GetCurrentColorbyAngle(__instance.targetAngleDegrees);
			AccessTools.Field(typeof(EnemySpinny), "effectDone").SetValue(__instance, true);
			if ((int)currentColorbyAngle == 2 || (int)currentColorbyAngle == 3 || (int)currentColorbyAngle == 1)
			{
				AccessTools.Field(typeof(EnemySpinny), "moneyToBeSpawned").SetValue(__instance, SemiFunc.IsMasterClientOrSingleplayer());
				AccessTools.Field(typeof(EnemySpinny), "isCollidingMoney").SetValue(__instance, false);
				__instance.enemySpinnyAnim.moneyPrizeParticle.PlayParticles();
			}
			else
			{
				__instance.enemySpinnyAnim.smallhurtParticle.Play(true);
				if (SemiFunc.IsMasterClientOrSingleplayer())
				{
					if ((int)currentColorbyAngle == 4)
					{
						ExecuteBankruptcy(__instance);
					}
					else if ((int)currentColorbyAngle == 0)
					{
						ExecuteSteal(__instance);
					}
				}
			}
			AccessTools.Method(typeof(EnemySpinny), "CameraShake", (Type[])null, (Type[])null).Invoke(__instance, new object[1] { currentColorbyAngle });
		}

		[HarmonyPatch(typeof(EnemySpinny), "SpawnMoneyBag")]
		[HarmonyPrefix]
		private static bool SpawnRewards(EnemySpinny __instance)
		{
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Expected I4, but got Unknown
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Invalid comparison between Unknown and I4
			//IL_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: Invalid comparison between Unknown and I4
			//IL_0228: Unknown result type (might be due to invalid IL or missing references)
			//IL_022a: Invalid comparison between Unknown and I4
			//IL_024f: Unknown result type (might be due to invalid IL or missing references)
			AccessTools.Field(typeof(EnemySpinny), "moneyToBeSpawned").SetValue(__instance, false);
			if (!SemiFunc.IsMasterClientOrSingleplayer())
			{
				return false;
			}
			GambitSpinState component = ((Component)__instance).GetComponent<GambitSpinState>();
			if (component.RewardHandled)
			{
				return false;
			}
			component.RewardHandled = true;
			GambitRules gambitRules = SpinRules(__instance);
			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;
			}
			num2 = (int)Math.Min(2147483647.0, Math.Round((double)num2 * (double)gambitRules.RewardMultiplier));
			if ((int)currentColorbyAngle == 2)
			{
				num3 = ((num2 > 5000) ? 1 : 0);
			}
			else if ((int)currentColorbyAngle == 1)
			{
				num3 = ((num2 > 10000) ? 3 : 2);
			}
			if (gambitRules.Delivery == PayoutDelivery.DirectDeposit)
			{
				num3 = 0;
			}
			else if (gambitRules.Delivery == PayoutDelivery.BagsOnly && num2 > 0)
			{
				num3 = Mathf.Max(1, num3);
			}
			AccessTools.Method(typeof(EnemySpinny), "MoneyEffect", (Type[])null, (Type[])null).Invoke(__instance, null);
			AccessTools.Field(typeof(EnemySpinny), "moneyToBeSpawned").SetValue(__instance, false);
			if (num3 > 0 && num2 > 0)
			{
				SpawnSmartLoot(__instance, num2, num3);
			}
			else
			{
				DirectDeposit(__instance, num2 / 1000);
			}
			string text = ((num3 > 0) ? SemiFunc.DollarGetString(num2) : FormatK(num2 / 1000));
			string message = (((int)currentColorbyAngle == 3) ? ("JACKPOT! Gambit gave you: $" + text) : ("YOU WIN! Gambit gave you: $" + text));
			GambitSession.Instance.Announce(message, currentColorbyAngle);
			return false;
		}

		private static void ExecuteSteal(EnemySpinny instance)
		{
			if (!SemiFunc.IsMasterClientOrSingleplayer())
			{
				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;
			}
			num6 = (int)Math.Min(2147483647.0, Math.Round((double)num6 * (double)SpinRules(instance).StealMultiplier));
			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!");
				GambitSession.Instance.Announce(text + " Gambit won and stole your money. You lost: $" + FormatK(num6), (Colors)0);
			}
		}

		private static void ExecuteBankruptcy(EnemySpinny instance)
		{
			if (SemiFunc.IsMasterClientOrSingleplayer())
			{
				int num = SemiFunc.StatGetRunCurrency();
				if (num <= 0)
				{
					TriggerEnemyAlert(instance, 0);
					return;
				}
				int num2 = (int)((long)num * (long)Mathf.RoundToInt(SpinRules(instance).BankruptcyPercent) / 100);
				string arg = FormatK(num2);
				SemiFunc.StatSetRunCurrency(num - num2);
				TriggerMoneyUI();
				GambitSession.Instance.Announce($"BANKRUPTCY! Gambit took {SpinRules(instance).BankruptcyPercent:0}% of your money (${arg})", (Colors)4);
				instance.enemySpinnyAnim.HurtSound();
			}
		}

		private static void DirectDeposit(EnemySpinny instance, int kAmount)
		{
			if (SemiFunc.IsMasterClientOrSingleplayer())
			{
				int num = SemiFunc.StatGetRunCurrency();
				SemiFunc.StatSetRunCurrency((int)Math.Min(2147483647L, (long)num + (long)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<GameObject>(val, val3, Quaternion.identity) : PhotonNetwork.InstantiateRoomObject("Valuables/" + ((Object)val).name, val3, Quaternion.identity, (byte)0, (object[])null));
				ValuableObject component = val4.GetComponent<ValuableObject>();
				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_0083: Unknown result type (might be due to invalid IL or missing references)
			string message;
			if (missingAmountK <= 0)
			{
				message = "YOU'RE BANKRUPT! You don't have anything to give Gambit, it got mad and alerted all nearby enemies.";
			}
			else
			{
				string text = FormatK(missingAmountK);
				message = "YOU FOOL! You gambled with Gambit but you don't have the $" + text + " it takes to pay him. He took the rest of your money and alerted all nearby enemies.";
			}
			if (!SpinRules(instance).AlertEnemies)
			{
				message = ((missingAmountK <= 0) ? "YOU'RE BANKRUPT! You have nothing to give Gambit." : "YOU LOST! Gambit took the rest of your money.");
			}
			GambitSession.Instance.Announce(message, (Colors)0);
			instance.enemySpinnyAnim.HurtSound();
			if (SpinRules(instance).AlertEnemies)
			{
				SemiFunc.EnemyInvestigate(((Component)instance).transform.position, 100f, false);
			}
		}

		public static void TriggerMoneyUI()
		{
			if ((Object)(object)CurrencyUI.instance != (Object)null)
			{
				currencyDisplay = CurrencyUI.instance;
				currencyVisibleUntil = Time.time + 2.5f;
				AccessTools.Method(typeof(SemiUI), "Show", (Type[])null, (Type[])null).Invoke(CurrencyUI.instance, null);
			}
		}

		[HarmonyPatch(typeof(SemiUI), "Hide")]
		[HarmonyPrefix]
		private static bool PreventHide(SemiUI __instance)
		{
			return !((Object)(object)__instance == (Object)(object)currencyDisplay) || !((Object)(object)__instance == (Object)(object)CurrencyUI.instance) || !SemiFunc.RunIsLevel() || !(Time.time < currencyVisibleUntil);
		}

		private static string FormatK(int kAmount)
		{
			return SemiFunc.DollarGetString(kAmount) + "K";
		}

		public 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;
		}
	}
	public sealed class GambitSession : MonoBehaviourPunCallbacks, IOnEventCallback
	{
		private const string RulesKey = "RJ.GG.rules.1";

		private const string OwnerKey = "RJ.GG.owner.1";

		private const string VersionKey = "RJ.GG.version";

		private const string EventTag = "RJ.GambitGambler.feedback.1";

		private const byte FeedbackCode = 173;

		private Room observedRoom;

		private string lastPublished;

		private bool warnedVersion;

		private bool useRoomRules;

		public static GambitSession Instance { get; private set; }

		public static bool CanEdit => !PhotonNetwork.InRoom || PhotonNetwork.IsMasterClient;

		public GambitRules Rules { get; private set; } = new GambitRules();

		public bool Ready { get; private set; }

		public string Status { get; private set; } = "";

		private void Awake()
		{
			Instance = this;
			Rules = GambitConfig.LocalRules();
			Ready = true;
			Refresh();
		}

		private void Update()
		{
			//IL_0044: 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_0059: Expected O, but got Unknown
			//IL_0061: Expected O, but got Unknown
			if (observedRoom != PhotonNetwork.CurrentRoom)
			{
				observedRoom = PhotonNetwork.CurrentRoom;
				lastPublished = null;
				warnedVersion = false;
				useRoomRules = false;
				if (PhotonNetwork.InRoom)
				{
					Player localPlayer = PhotonNetwork.LocalPlayer;
					Hashtable val = new Hashtable();
					((Dictionary<object, object>)val).Add((object)"RJ.GG.version", (object)"1.1.2");
					localPlayer.SetCustomProperties(val, (Hashtable)null, (WebFlags)null);
				}
				Refresh();
			}
			if (CanEdit)
			{
				GambitRules gambitRules = GambitConfig.LocalRules();
				if (!useRoomRules && JsonUtility.ToJson((object)gambitRules) != JsonUtility.ToJson((object)Rules))
				{
					Rules = gambitRules;
					Publish();
				}
				else if (PhotonNetwork.InRoom && lastPublished == null)
				{
					Publish();
				}
			}
		}

		private void OnDestroy()
		{
			GambitFocusFeedback.Reset();
			GambitSettingsUI.Cleanup();
			if ((Object)(object)Instance == (Object)(object)this)
			{
				Instance = null;
			}
		}

		public void Change(Action<GambitRules> change)
		{
			if (!CanEdit)
			{
				return;
			}
			GambitRules gambitRules = Rules.Copy();
			change(gambitRules);
			if (gambitRules.IsValid())
			{
				if (!useRoomRules)
				{
					GambitConfig.Save(gambitRules);
				}
				Rules = gambitRules;
				Publish();
			}
		}

		public void ResetRules()
		{
			Change(delegate(GambitRules rules)
			{
				GambitRules gambitRules = new GambitRules();
				rules.ExtraEncounters = gambitRules.ExtraEncounters;
				rules.SpawnChance = gambitRules.SpawnChance;
				rules.MaximumGambits = gambitRules.MaximumGambits;
				rules.RewardMultiplier = gambitRules.RewardMultiplier;
				rules.Delivery = gambitRules.Delivery;
				rules.StealMultiplier = gambitRules.StealMultiplier;
				rules.BankruptcyPercent = gambitRules.BankruptcyPercent;
				rules.AlertEnemies = gambitRules.AlertEnemies;
			});
		}

		private void Publish()
		{
			//IL_0046: 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_0057: Expected O, but got Unknown
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Expected O, but got Unknown
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Expected O, but got Unknown
			//IL_008b: Expected O, but got Unknown
			if (!CanEdit)
			{
				return;
			}
			Ready = true;
			if (!PhotonNetwork.InRoom)
			{
				Status = "SINGLEPLAYER";
				return;
			}
			string value = JsonUtility.ToJson((object)Rules);
			Room currentRoom = PhotonNetwork.CurrentRoom;
			Hashtable val = new Hashtable();
			((Dictionary<object, object>)val).Add((object)"RJ.GG.rules.1", (object)value);
			((Dictionary<object, object>)val).Add((object)"RJ.GG.owner.1", (object)PhotonNetwork.LocalPlayer.ActorNumber);
			((Dictionary<object, object>)val).Add((object)"RJ.GG.version", (object)"1.1.2");
			if (currentRoom.SetCustomProperties(val, (Hashtable)null, (WebFlags)null))
			{
				lastPublished = value;
			}
			Status = "HOST SETTINGS";
			CheckPeerVersions();
		}

		private void Refresh()
		{
			if (!PhotonNetwork.InRoom)
			{
				Rules = GambitConfig.LocalRules();
				Ready = true;
				Status = "SINGLEPLAYER";
				return;
			}
			if (PhotonNetwork.IsMasterClient)
			{
				if (lastPublished == null)
				{
					Publish();
				}
				return;
			}
			Ready = false;
			Status = "WAITING FOR HOST SETTINGS";
			Hashtable customProperties = ((RoomInfo)PhotonNetwork.CurrentRoom).CustomProperties;
			if (!(customProperties[(object)"RJ.GG.owner.1"] is int num) || num != PhotonNetwork.MasterClient.ActorNumber || !(customProperties[(object)"RJ.GG.rules.1"] is string text))
			{
				return;
			}
			if (!object.Equals(customProperties[(object)"RJ.GG.version"], "1.1.2"))
			{
				Status = "HOST MOD VERSION MISMATCH";
				if (!warnedVersion)
				{
					GambitGambler.Instance.LogWarning(Status);
					warnedVersion = true;
				}
				return;
			}
			try
			{
				GambitRules gambitRules = JsonUtility.FromJson<GambitRules>(text);
				if (gambitRules != null && gambitRules.IsValid())
				{
					Rules = gambitRules;
					Ready = true;
					Status = "HOST SETTINGS - READ ONLY";
				}
			}
			catch (ArgumentException)
			{
				Status = "INVALID HOST SETTINGS";
			}
		}

		public override void OnJoinedRoom()
		{
			observedRoom = null;
		}

		public override void OnLeftRoom()
		{
			observedRoom = null;
			useRoomRules = false;
			Refresh();
		}

		public override void OnRoomPropertiesUpdate(Hashtable propertiesThatChanged)
		{
			Refresh();
		}

		public override void OnPlayerEnteredRoom(Player newPlayer)
		{
			CheckPeerVersions();
		}

		public override void OnPlayerLeftRoom(Player otherPlayer)
		{
			CheckPeerVersions();
		}

		public override void OnPlayerPropertiesUpdate(Player targetPlayer, Hashtable changedProps)
		{
			CheckPeerVersions();
		}

		private void CheckPeerVersions()
		{
			if (!PhotonNetwork.InRoom || !PhotonNetwork.IsMasterClient)
			{
				return;
			}
			Player[] playerList = PhotonNetwork.PlayerList;
			foreach (Player val in playerList)
			{
				if (!val.IsLocal && !object.Equals(val.CustomProperties[(object)"RJ.GG.version"], "1.1.2"))
				{
					Status = "CLIENT MOD VERSION MISMATCH";
					return;
				}
			}
			Status = "HOST SETTINGS";
		}

		public override void OnMasterClientSwitched(Player newMasterClient)
		{
			useRoomRules = PhotonNetwork.IsMasterClient && Ready;
			lastPublished = null;
			Refresh();
		}

		public void Announce(string message, Colors color)
		{
			//IL_0010: 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_003f: Expected I4, 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)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Expected O, but got Unknown
			if (CanEdit)
			{
				ShowFeedback(message, color);
				if (PhotonNetwork.InRoom)
				{
					PhotonNetwork.RaiseEvent((byte)173, (object)new object[3]
					{
						"RJ.GambitGambler.feedback.1",
						message,
						(int)color
					}, new RaiseEventOptions
					{
						Receivers = (ReceiverGroup)0
					}, SendOptions.SendReliable);
				}
			}
		}

		public void OnEvent(EventData photonEvent)
		{
			if (photonEvent.Code == 173 && PhotonNetwork.InRoom && photonEvent.Sender == PhotonNetwork.MasterClient.ActorNumber && photonEvent.CustomData is object[] array && array.Length == 3 && object.Equals(array[0], "RJ.GambitGambler.feedback.1") && array[1] is string message && array[2] is int num && Enum.IsDefined(typeof(Colors), num))
			{
				ShowFeedback(message, (Colors)num);
			}
		}

		private static void ShowFeedback(string message, Colors color)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			if (SemiFunc.RunIsLevel())
			{
				GambitFocusFeedback.Show(message, color);
				GambitGambler.TriggerMoneyUI();
			}
		}
	}
	[HarmonyPatch]
	internal static class GambitFocusFeedback
	{
		private const float FlashDuration = 0.8f;

		private static readonly FieldInfo flashTimer = AccessTools.Field(typeof(SemiUI), "flashColorTime");

		private static MissionUI focusUI;

		private static TextMeshProUGUI focusText;

		private static Color normalText;

		private static Color normalFace;

		private static Color normalGlow;

		private static Color outcomeColor;

		private static float startedAt;

		private static bool flashing;

		[HarmonyPatch(typeof(MissionUI), "Start")]
		[HarmonyPostfix]
		private static void CaptureColors(MissionUI __instance)
		{
			//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_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			Reset();
			focusUI = __instance;
			focusText = ((Component)__instance).GetComponent<TextMeshProUGUI>();
			if (Object.op_Implicit((Object)(object)focusText))
			{
				normalText = ((Graphic)focusText).color;
				normalFace = ((TMP_Text)focusText).fontMaterial.GetColor(ShaderUtilities.ID_FaceColor);
				normalGlow = ((TMP_Text)focusText).fontMaterial.GetColor(ShaderUtilities.ID_GlowColor);
			}
		}

		internal static void Show(string message, Colors color)
		{
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Invalid comparison between Unknown and I4
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Invalid comparison between Unknown and I4
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Invalid comparison between Unknown and I4
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)MissionUI.instance))
			{
				if ((Object)(object)focusUI != (Object)(object)MissionUI.instance)
				{
					CaptureColors(MissionUI.instance);
				}
				if (Object.op_Implicit((Object)(object)focusText))
				{
					SemiFunc.UIFocusText(message, normalText, normalText, 5f);
					flashTimer.SetValue(focusUI, 0f);
					outcomeColor = (((int)color == 3 || (int)color == 1) ? Color.yellow : (((int)color == 2) ? Color.green : Color.red));
					startedAt = Time.unscaledTime;
					flashing = true;
					SetColor(0f);
				}
			}
		}

		[HarmonyPatch(typeof(MissionUI), "MissionText")]
		[HarmonyPrefix]
		private static void BeforeMessage(MissionUI __instance)
		{
			if ((Object)(object)__instance == (Object)(object)focusUI)
			{
				Reset();
			}
		}

		[HarmonyPatch(typeof(SemiUI), "FlashColorLogic")]
		[HarmonyPrefix]
		private static bool AnimateFlash(SemiUI __instance)
		{
			if (!flashing || (Object)(object)__instance != (Object)(object)focusUI)
			{
				return true;
			}
			if (!Object.op_Implicit((Object)(object)focusText) || !SemiFunc.RunIsLevel())
			{
				Reset();
				return true;
			}
			float num = Mathf.Clamp01((Time.unscaledTime - startedAt) / 0.8f);
			SetColor(Mathf.SmoothStep(0f, 1f, num));
			if (num >= 1f)
			{
				Reset();
			}
			return false;
		}

		private static void SetColor(float blend)
		{
			//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_0011: 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_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: 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_004e: 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)
			((Graphic)focusText).color = Color.Lerp(outcomeColor, normalText, blend);
			Material fontMaterial = ((TMP_Text)focusText).fontMaterial;
			fontMaterial.SetColor(ShaderUtilities.ID_FaceColor, Color.Lerp(outcomeColor, normalFace, blend));
			fontMaterial.SetColor(ShaderUtilities.ID_GlowColor, Color.Lerp(outcomeColor, normalGlow, blend));
		}

		internal static void Reset()
		{
			if (flashing)
			{
				if (Object.op_Implicit((Object)(object)focusText))
				{
					SetColor(1f);
				}
				flashing = false;
			}
		}
	}
	public sealed class GambitSpinState : MonoBehaviour
	{
		public GambitRules Rules;

		public bool RewardHandled;
	}
	public static class GambitSettingsUI
	{
		private sealed class ScrollInput : MonoBehaviour
		{
			public RectTransform Track;

			public Image Border;

			private bool dragging;

			private bool wasHovering;

			private float grabOffset;

			private void OnDisable()
			{
				dragging = false;
			}

			private void Update()
			{
				//IL_0048: Unknown result type (might be due to invalid IL or missing references)
				//IL_005f: 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_0058: 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)
				//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
				//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
				//IL_011c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0121: Unknown result type (might be due to invalid IL or missing references)
				//IL_0133: Unknown result type (might be due to invalid IL or missing references)
				//IL_0138: Unknown result type (might be due to invalid IL or missing references)
				//IL_026f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0274: Unknown result type (might be due to invalid IL or missing references)
				//IL_0282: Unknown result type (might be due to invalid IL or missing references)
				//IL_0287: Unknown result type (might be due to invalid IL or missing references)
				//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
				//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
				//IL_01e8: 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_0206: Unknown result type (might be due to invalid IL or missing references)
				//IL_020b: Unknown result type (might be due to invalid IL or missing references)
				//IL_021d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0222: Unknown result type (might be due to invalid IL or missing references)
				//IL_029c: Unknown result type (might be due to invalid IL or missing references)
				//IL_02be: Unknown result type (might be due to invalid IL or missing references)
				if (!isMenuOpen || KeybindHandler.IsRebinding)
				{
					dragging = false;
					scrollTarget = scrollRect.verticalNormalizedPosition;
					return;
				}
				bool flag = Hover(Track);
				((Graphic)Border).color = Color.Lerp(((Graphic)Border).color, (flag || dragging) ? Color.white : repoBlueBorder, MotionBlend());
				if (flag && !wasHovering && Object.op_Implicit((Object)(object)MenuManager.instance))
				{
					MenuManager.instance.MenuEffectHover(1f, -1f);
				}
				wasHovering = flag;
				Rect rect;
				if (flag && Input.GetMouseButtonDown(0))
				{
					dragging = true;
					float y = ((Transform)Track).InverseTransformPoint(((Component)MenuCursor.instance).transform.position).y;
					rect = Track.rect;
					float num = ((Rect)(ref rect)).height * scrollBar.size * 0.5f;
					rect = Track.rect;
					float num2 = ((Rect)(ref rect)).yMin + num;
					rect = Track.rect;
					float num3 = Mathf.Lerp(num2, ((Rect)(ref rect)).yMax - num, scrollBar.value);
					grabOffset = ((Mathf.Abs(y - num3) <= num) ? (y - num3) : 0f);
				}
				if (dragging)
				{
					if (!Object.op_Implicit((Object)(object)MenuCursor.instance) || !Input.GetMouseButton(0))
					{
						dragging = false;
					}
					else
					{
						rect = Track.rect;
						float num4 = ((Rect)(ref rect)).height * scrollBar.size * 0.5f;
						float num5 = ((Transform)Track).InverseTransformPoint(((Component)MenuCursor.instance).transform.position).y - grabOffset;
						rect = Track.rect;
						float num6 = ((Rect)(ref rect)).yMin + num4;
						rect = Track.rect;
						SetScrollPosition(Mathf.InverseLerp(num6, ((Rect)(ref rect)).yMax - num4, num5), immediate: true);
					}
				}
				else if (!Input.GetMouseButton(0) && (flag || Hover(scrollViewport)))
				{
					rect = scrollRect.content.rect;
					float height = ((Rect)(ref rect)).height;
					rect = scrollViewport.rect;
					float num7 = height - ((Rect)(ref rect)).height;
					if (num7 > 0f && Input.mouseScrollDelta.y != 0f)
					{
						SetScrollPosition(scrollTarget + Input.mouseScrollDelta.y * 22f / num7);
					}
				}
				float num8 = Mathf.Lerp(scrollRect.verticalNormalizedPosition, scrollTarget, MotionBlend());
				if (Mathf.Abs(num8 - scrollTarget) < 0.0005f)
				{
					num8 = scrollTarget;
				}
				scrollRect.verticalNormalizedPosition = num8;
				UpdateScrollbar();
			}
		}

		private sealed class ResetHandler : MonoBehaviour
		{
			public TextMeshProUGUI Text;

			public RectTransform Rect;

			private bool wasHovering;

			private void Update()
			{
				//IL_0034: Unknown result type (might be due to invalid IL or missing references)
				//IL_0043: 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_0052: Unknown result type (might be due to invalid IL or missing references)
				//IL_0073: Unknown result type (might be due to invalid IL or missing references)
				//IL_008c: Unknown result type (might be due to invalid IL or missing references)
				//IL_007b: Unknown result type (might be due to invalid IL or missing references)
				//IL_009b: Unknown result type (might be due to invalid IL or missing references)
				if (!isMenuOpen)
				{
					return;
				}
				bool flag = GambitSession.CanEdit && Hover(Rect);
				((Graphic)Text).color = Color.Lerp(((Graphic)Text).color, flag ? Color.white : Color.gray, MotionBlend());
				((TMP_Text)Text).rectTransform.anchoredPosition = Vector2.Lerp(((TMP_Text)Text).rectTransform.anchoredPosition, (Vector2)(flag ? new Vector2(2f, 0f) : Vector2.zero), MotionBlend());
				if (flag && !wasHovering && Object.op_Implicit((Object)(object)MenuManager.instance))
				{
					MenuManager.instance.MenuEffectHover(1f, -1f);
				}
				wasHovering = flag;
				if (flag && Input.GetMouseButtonDown(0))
				{
					GambitSession.Instance.ResetRules();
					GambitConfig.MenuKeybind.Value = (KeyCode)287;
					UpdateFooterText();
					if (Object.op_Implicit((Object)(object)MenuManager.instance))
					{
						MenuManager.instance.MenuEffectClick((MenuClickEffectType)1, (MenuPage)null, -1f, -1f, true, true);
					}
				}
			}
		}

		private sealed class ActionHandler : MonoBehaviour
		{
			public RectTransform Rect;

			public Image Border;

			public TextMeshProUGUI Text;

			public Action Action;

			public Func<bool> Enabled;

			private bool wasHovering;

			private void Update()
			{
				//IL_003c: 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_0044: Unknown result type (might be due to invalid IL or missing references)
				//IL_005a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0083: Unknown result type (might be due to invalid IL or missing references)
				//IL_0092: Unknown result type (might be due to invalid IL or missing references)
				//IL_008b: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
				if (!isMenuOpen)
				{
					return;
				}
				bool flag = Enabled();
				bool flag2 = flag && Hover(Rect);
				((Graphic)Border).color = Color.Lerp(((Graphic)Border).color, flag2 ? Color.white : repoBlueBorder, MotionBlend());
				if (!Object.op_Implicit((Object)(object)((Component)this).GetComponentInChildren<SelectionColor>()))
				{
					((Graphic)Text).color = Color.Lerp(((Graphic)Text).color, flag ? Color.white : Color.gray, MotionBlend());
				}
				if (flag2 && !wasHovering && Object.op_Implicit((Object)(object)MenuManager.instance))
				{
					MenuManager.instance.MenuEffectHover(1f, -1f);
				}
				wasHovering = flag2;
				if (flag2 && Input.GetMouseButtonDown(0))
				{
					Action();
					if (Object.op_Implicit((Object)(object)MenuManager.instance))
					{
						MenuManager.instance.MenuEffectClick((MenuClickEffectType)1, (MenuPage)null, -1f, -1f, true, true);
					}
				}
			}
		}

		private sealed class SelectionColor : MonoBehaviour
		{
			public Func<bool> Selected;

			private void Update()
			{
				//IL_000a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0023: Unknown result type (might be due to invalid IL or missing references)
				//IL_001c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0032: Unknown result type (might be due to invalid IL or missing references)
				TextMeshProUGUI component = ((Component)this).GetComponent<TextMeshProUGUI>();
				((Graphic)component).color = Color.Lerp(((Graphic)component).color, Selected() ? repoOrange : Color.white, MotionBlend());
			}
		}

		private sealed class SliderHandler : MonoBehaviour
		{
			public RectTransform Track;

			public RectTransform Handle;

			public TextMeshProUGUI Value;

			public Image Border;

			public float Min;

			public float Max;

			public float Step;

			public Func<float> Getter;

			public Action<float> Setter;

			public string Suffix;

			private bool dragging;

			private bool wasHovering;

			private float preview;

			private void OnDisable()
			{
				dragging = false;
			}

			private void Update()
			{
				//IL_0039: Unknown result type (might be due to invalid IL or missing references)
				//IL_003e: 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_0043: Unknown result type (might be due to invalid IL or missing references)
				//IL_005a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0066: Unknown result type (might be due to invalid IL or missing references)
				//IL_006b: Unknown result type (might be due to invalid IL or missing references)
				//IL_007c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0088: 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_009e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0118: Unknown result type (might be due to invalid IL or missing references)
				//IL_012f: Unknown result type (might be due to invalid IL or missing references)
				//IL_013e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0128: Unknown result type (might be due to invalid IL or missing references)
				//IL_0191: Unknown result type (might be due to invalid IL or missing references)
				//IL_0196: Unknown result type (might be due to invalid IL or missing references)
				//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
				//IL_01ba: 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_01ce: Unknown result type (might be due to invalid IL or missing references)
				//IL_0264: Unknown result type (might be due to invalid IL or missing references)
				//IL_0269: Unknown result type (might be due to invalid IL or missing references)
				//IL_0278: Unknown result type (might be due to invalid IL or missing references)
				//IL_027d: 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_02b8: Unknown result type (might be due to invalid IL or missing references)
				//IL_02c4: Unknown result type (might be due to invalid IL or missing references)
				//IL_0312: Unknown result type (might be due to invalid IL or missing references)
				//IL_0321: Unknown result type (might be due to invalid IL or missing references)
				//IL_031a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0330: Unknown result type (might be due to invalid IL or missing references)
				bool flag = GambitSession.CanEdit && GambitSession.Instance.Ready;
				Vector3 val = (Object.op_Implicit((Object)(object)MenuCursor.instance) ? ((Transform)Track).InverseTransformPoint(((Component)MenuCursor.instance).transform.position) : Vector3.positiveInfinity);
				Rect rect;
				int num;
				if (flag && isMenuOpen && Hover(scrollViewport))
				{
					float x = val.x;
					rect = Track.rect;
					if (x >= ((Rect)(ref rect)).xMin - 10f)
					{
						float x2 = val.x;
						rect = Track.rect;
						if (x2 <= ((Rect)(ref rect)).xMax + 10f)
						{
							num = ((Mathf.Abs(val.y) <= 13f) ? 1 : 0);
							goto IL_00b6;
						}
					}
				}
				num = 0;
				goto IL_00b6;
				IL_00b6:
				bool flag2 = (byte)num != 0;
				if (!flag || !isMenuOpen)
				{
					dragging = false;
				}
				if (flag2 && !wasHovering && Object.op_Implicit((Object)(object)MenuManager.instance))
				{
					MenuManager.instance.MenuEffectHover(1f, -1f);
				}
				wasHovering = flag2;
				((Graphic)Border).color = Color.Lerp(((Graphic)Border).color, (flag2 || dragging) ? Color.white : repoBlueBorder, MotionBlend());
				if (flag2 && Input.GetMouseButtonDown(0))
				{
					dragging = true;
				}
				if (dragging && Object.op_Implicit((Object)(object)MenuCursor.instance))
				{
					float x3 = ((Transform)Track).InverseTransformPoint(((Component)MenuCursor.instance).transform.position).x;
					float min = Min;
					float max = Max;
					rect = Track.rect;
					float xMin = ((Rect)(ref rect)).xMin;
					rect = Track.rect;
					preview = Mathf.Round(Mathf.Lerp(min, max, Mathf.InverseLerp(xMin, ((Rect)(ref rect)).xMax, x3)) / Step) * Step;
					preview = Mathf.Clamp(preview, Min, Max);
					if (Input.GetMouseButtonUp(0))
					{
						dragging = false;
						Setter(preview);
					}
				}
				float num2 = (dragging ? preview : Getter());
				rect = Track.rect;
				float xMin2 = ((Rect)(ref rect)).xMin;
				rect = Track.rect;
				Vector2 val2 = default(Vector2);
				((Vector2)(ref val2))..ctor(Mathf.Lerp(xMin2, ((Rect)(ref rect)).xMax, Mathf.InverseLerp(Min, Max, num2)), 0f);
				Handle.anchoredPosition = Vector2.Lerp(Handle.anchoredPosition, val2, MotionBlend(24f));
				((TMP_Text)Value).text = num2.ToString((Step < 1f) ? "0.0" : "0") + Suffix;
				((Graphic)Value).color = Color.Lerp(((Graphic)Value).color, flag ? Color.white : Color.gray, MotionBlend());
			}
		}

		private class KeybindHandler : MonoBehaviour
		{
			public static bool IsRebinding;

			private Image border;

			private Image btnBg;

			private TextMeshProUGUI keyText;

			private RectTransform btnRect;

			private bool listening;

			private bool isHovering;

			private float invalidTimer = 0f;

			private Vector2 originalTextPos;

			public void Setup(Image b, Image bg, TextMeshProUGUI t, RectTransform rect)
			{
				//IL_002a: 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)
				border = b;
				btnBg = bg;
				keyText = t;
				btnRect = rect;
				originalTextPos = ((TMP_Text)keyText).rectTransform.anchoredPosition;
			}

			private void OnDisable()
			{
				listening = false;
				IsRebinding = false;
				invalidTimer = 0f;
			}

			private void Update()
			{
				//IL_0031: 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_00b1: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
				//IL_030d: Unknown result type (might be due to invalid IL or missing references)
				//IL_031c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0315: Unknown result type (might be due to invalid IL or missing references)
				//IL_0118: Unknown result type (might be due to invalid IL or missing references)
				//IL_011d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0120: Unknown result type (might be due to invalid IL or missing references)
				//IL_032b: Unknown result type (might be due to invalid IL or missing references)
				//IL_034c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0131: Unknown result type (might be due to invalid IL or missing references)
				//IL_0138: Invalid comparison between Unknown and I4
				//IL_0378: Unknown result type (might be due to invalid IL or missing references)
				//IL_0355: Unknown result type (might be due to invalid IL or missing references)
				//IL_013a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0141: Invalid comparison between Unknown and I4
				//IL_0387: 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_014a: Invalid comparison between Unknown and I4
				//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
				//IL_01b6: Invalid comparison between Unknown and I4
				//IL_016d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0220: Unknown result type (might be due to invalid IL or missing references)
				//IL_01d6: 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_03da: Unknown result type (might be due to invalid IL or missing references)
				//IL_026b: Unknown result type (might be due to invalid IL or missing references)
				//IL_027e: Unknown result type (might be due to invalid IL or missing references)
				//IL_043d: 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_046e: Unknown result type (might be due to invalid IL or missing references)
				if (!isMenuOpen)
				{
					if (listening)
					{
						listening = false;
						IsRebinding = false;
						((TMP_Text)keyText).text = KeyName(GambitConfig.MenuKeybind.Value);
						((Graphic)btnBg).color = repoBlueActive;
					}
					return;
				}
				if (invalidTimer > 0f)
				{
					invalidTimer -= Time.unscaledDeltaTime;
					if (!(invalidTimer <= 0f))
					{
						return;
					}
					listening = true;
					((TMP_Text)keyText).text = "[PRESS KEY]";
					((Graphic)keyText).color = repoYellow;
					((Graphic)btnBg).color = repoOrange;
				}
				if (listening)
				{
					if (!Input.anyKeyDown)
					{
						return;
					}
					{
						foreach (KeyCode value in Enum.GetValues(typeof(KeyCode)))
						{
							if (!Input.GetKeyDown(value))
							{
								continue;
							}
							if ((int)value == 323 || (int)value == 324 || (int)value == 325)
							{
								((TMP_Text)keyText).text = "INVALID INPUT";
								((Graphic)keyText).color = Color.red;
								invalidTimer = 1.2f;
								if ((Object)(object)MenuManager.instance != (Object)null)
								{
									MenuManager.instance.MenuEffectClick((MenuClickEffectType)2, (MenuPage)null, -1f, -1f, true, true);
								}
								break;
							}
							if ((int)value == 27)
							{
								((TMP_Text)keyText).text = "INVALID INPUT";
								((Graphic)keyText).color = Color.red;
								invalidTimer = 1.2f;
								if ((Object)(object)MenuManager.instance != (Object)null)
								{
									MenuManager.instance.MenuEffectClick((MenuClickEffectType)2, (MenuPage)null, -1f, -1f, true, true);
								}
								break;
							}
							GambitConfig.MenuKeybind.Value = value;
							listening = false;
							IsRebinding = false;
							UpdateFooterText();
							if ((Object)(object)MenuManager.instance != (Object)null)
							{
								MenuManager.instance.MenuEffectClick((MenuClickEffectType)1, (MenuPage)null, -1f, -1f, true, true);
							}
							((TMP_Text)keyText).text = KeyName(value);
							((Graphic)btnBg).color = repoBlueActive;
							break;
						}
						return;
					}
				}
				bool flag = IsMouseOver(btnRect);
				if (flag && !isHovering && (Object)(object)MenuManager.instance != (Object)null)
				{
					MenuManager.instance.MenuEffectHover(1f, -1f);
				}
				isHovering = flag;
				((Graphic)border).color = Color.Lerp(((Graphic)border).color, flag ? Color.white : repoBlueBorder, MotionBlend());
				((TMP_Text)keyText).rectTransform.anchoredPosition = Vector2.Lerp(((TMP_Text)keyText).rectTransform.anchoredPosition, (Vector2)(flag ? new Vector2(originalTextPos.x + 2f, originalTextPos.y) : originalTextPos), MotionBlend());
				if (flag && Input.GetMouseButtonDown(0))
				{
					listening = true;
					IsRebinding = true;
					((Graphic)btnBg).color = repoOrange;
					((TMP_Text)keyText).text = "[PRESS KEY]";
					((Graphic)keyText).color = repoYellow;
					if ((Object)(object)MenuManager.instance != (Object)null)
					{
						MenuManager.instance.MenuEffectClick((MenuClickEffectType)0, (MenuPage)null, -1f, -1f, true, true);
					}
				}
				if (!listening && invalidTimer <= 0f)
				{
					((TMP_Text)keyText).text = KeyName(GambitConfig.MenuKeybind.Value);
					((Graphic)keyText).color = Color.white;
					if (!flag)
					{
						((Graphic)btnBg).color = repoBlueActive;
					}
				}
			}

			private bool IsMouseOver(RectTransform target)
			{
				return Hover(target);
			}
		}

		private class RepoRowHandler : MonoBehaviour
		{
			private Image border;

			private Image onHover;

			private Image offHover;

			private RectTransform activeGroup;

			private RectTransform glow;

			private RectTransform onRect;

			private RectTransform offRect;

			private TextMeshProUGUI onText;

			private TextMeshProUGUI offText;

			private Func<bool> getter;

			private Action<bool> setter;

			private bool isHoveringAny;

			private bool isClickAnimActive;

			private float flickerTimer;

			private float popScale = 0f;

			public void Setup(Image brd, RectTransform h, RectTransform g, TextMeshProUGUI on, TextMeshProUGUI off, Func<bool> get, Action<bool> set, Image hOn, Image hOff)
			{
				border = brd;
				activeGroup = h;
				glow = g;
				onText = on;
				offText = off;
				getter = get;
				setter = set;
				onHover = hOn;
				offHover = hOff;
			}

			public void SetOnTarget(RectTransform r)
			{
				onRect = r;
			}

			public void SetOffTarget(RectTransform r)
			{
				offRect = r;
			}

			private void Update()
			{
				//IL_017b: Unknown result type (might be due to invalid IL or missing references)
				//IL_018f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0188: 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_01c7: Unknown result type (might be due to invalid IL or missing references)
				//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
				//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
				//IL_01da: Unknown result type (might be due to invalid IL or missing references)
				//IL_01df: Unknown result type (might be due to invalid IL or missing references)
				//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
				//IL_02bb: Unknown result type (might be due to invalid IL or missing references)
				//IL_0212: Unknown result type (might be due to invalid IL or missing references)
				//IL_0217: Unknown result type (might be due to invalid IL or missing references)
				//IL_0226: Unknown result type (might be due to invalid IL or missing references)
				//IL_0237: 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_0278: Unknown result type (might be due to invalid IL or missing references)
				//IL_0283: Unknown result type (might be due to invalid IL or missing references)
				//IL_0377: Unknown result type (might be due to invalid IL or missing references)
				//IL_0388: Unknown result type (might be due to invalid IL or missing references)
				//IL_02f7: Unknown result type (might be due to invalid IL or missing references)
				//IL_0306: Unknown result type (might be due to invalid IL or missing references)
				//IL_0347: Unknown result type (might be due to invalid IL or missing references)
				//IL_0340: Unknown result type (might be due to invalid IL or missing references)
				//IL_0362: Unknown result type (might be due to invalid IL or missing references)
				//IL_035b: Unknown result type (might be due to invalid IL or missing references)
				if (!isMenuOpen)
				{
					return;
				}
				bool flag = GambitSession.CanEdit && GambitSession.Instance.Ready;
				bool flag2 = getter();
				bool flag3 = flag && IsMouseOver(onRect);
				bool flag4 = flag && IsMouseOver(offRect);
				if (Object.op_Implicit((Object)(object)onHover))
				{
					((Behaviour)onHover).enabled = flag3 && !flag2;
				}
				if (Object.op_Implicit((Object)(object)offHover))
				{
					((Behaviour)offHover).enabled = flag4 && flag2;
				}
				bool flag5 = flag3 || flag4;
				if (flag5)
				{
					if (!isHoveringAny && (Object)(object)MenuManager.instance != (Object)null)
					{
						MenuManager.instance.MenuEffectHover(1f, -1f);
					}
					if (Input.GetMouseButtonDown(0))
					{
						bool flag6 = flag3 || (!flag4 && flag2);
						if (flag6 != flag2)
						{
							setter(flag6);
							flickerTimer = 0.25f;
							isClickAnimActive = true;
							popScale = 0f;
							if ((Object)(object)MenuManager.instance != (Object)null)
							{
								MenuManager.instance.MenuEffectClick((MenuClickEffectType)4, (MenuPage)null, -1f, -1f, true, true);
							}
						}
					}
				}
				isHoveringAny = flag5;
				((Graphic)border).color = Color.Lerp(((Graphic)border).color, isHoveringAny ? Color.white : repoBlueBorder, MotionBlend(10f));
				Vector2 val = (flag2 ? new Vector2(-30f, 0f) : new Vector2(30f, 0f));
				activeGroup.anchoredPosition = Vector2.Lerp(activeGroup.anchoredPosition, val, MotionBlend(25f));
				if (isClickAnimActive)
				{
					((Transform)glow).localScale = Vector3.Lerp(((Transform)glow).localScale, Vector3.zero, MotionBlend(40f));
					if (Vector2.Distance(activeGroup.anchoredPosition, val) < 1f)
					{
						popScale = Mathf.MoveTowards(popScale, 1.4f, Time.unscaledDeltaTime * 12f);
						((Transform)glow).localScale = Vector3.one * popScale;
						if (popScale >= 1.4f)
						{
							isClickAnimActive = false;
						}
					}
				}
				else
				{
					((Transform)glow).localScale = Vector3.Lerp(((Transform)glow).localScale, new Vector3(((flag2 && flag3) || (!flag2 && flag4)) ? 1.15f : 1f, ((flag2 && flag3) || (!flag2 && flag4)) ? 1.15f : 1f, 1f), MotionBlend(15f));
				}
				if (flickerTimer > 0f)
				{
					flickerTimer -= Time.unscaledDeltaTime;
					((Graphic)onText).color = (flag2 ? repoOrange : Color.white);
					((Graphic)offText).color = ((!flag2) ? repoOrange : Color.white);
				}
				else
				{
					((Graphic)onText).color = Color.white;
					((Graphic)offText).color = Color.white;
				}
			}

			private bool IsMouseOver(RectTransform target)
			{
				return Hover(target);
			}
		}

		private class RepoButton : MonoBehaviour
		{
			public bool targetValue;
		}

		private static GameObject SettingsPanel;

		private static GameObject WindowContainer;

		private static MenuPage SettingsMenuPage;

		private static CanvasGroup SettingsCanvasGroup;

		private static TextMeshProUGUI FooterHintText;

		private static TextMeshProUGUI statusText;

		private static TextMeshProUGUI gambitCountText;

		private static TMP_FontAsset nativeFont;

		private static RectTransform scrollViewport;

		private static ScrollRect scrollRect;

		private static Scrollbar scrollBar;

		private static readonly List<GameObject> pages = new List<GameObject>();

		private static readonly List<TextMeshProUGUI> tabs = new List<TextMeshProUGUI>();

		private static readonly Color repoBlueActive = new Color(0.067f, 0.298f, 0.725f, 1f);

		private static readonly Color repoBlueBorder = new Color(0f, 0.5f, 1f);

		private static readonly Color repoOrange = new Color(1f, 0.46f, 0f);

		private static readonly Color repoYellow = new Color(1f, 0.8f, 0f);

		private static readonly Color repoHover = new Color(0f, 0.5f, 1f, 0.3f);

		private static readonly FieldInfo currentPage = AccessTools.Field(typeof(MenuManager), "currentMenuPage");

		private static readonly FieldInfo menuState = AccessTools.Field(typeof(MenuManager), "currentMenuState");

		private static readonly FieldInfo pageState = AccessTools.Field(typeof(MenuPage), "currentPageState");

		private static readonly FieldInfo inputDisableTimerField = AccessTools.Field(typeof(PlayerController), "InputDisableTimer");

		private static float introLerp;

		private static float scrollTarget = 1f;

		private static int selectedPage;

		public static bool isMenuOpen;

		private static float MotionBlend(float speed = 18f)
		{
			return 1f - Mathf.Exp((0f - speed) * Time.unscaledDeltaTime);
		}

		public unsafe static string KeyName(KeyCode key)
		{
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Invalid comparison between Unknown and I4
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Invalid comparison between Unknown and I4
			string text = ((object)(*(KeyCode*)(&key))/*cast due to .constrained prefix*/).ToString();
			if (text.StartsWith("Alpha"))
			{
				return text.Substring(5);
			}
			if (text.StartsWith("Keypad"))
			{
				return "Numpad " + text.Substring(6);
			}
			if ((int)key == 13)
			{
				return "Enter";
			}
			if ((int)key == 27)
			{
				return "Esc";
			}
			return Regex.Replace(text, "(\\B[A-Z])", " $1");
		}

		private static bool OtherMenuOpen()
		{
			//IL_00cb: 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_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Invalid comparison between Unknown and I4
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Invalid comparison between Unknown and I4
			if (Object.op_Implicit((Object)(object)GameObject.Find("ValuableTracker_SettingsRoot")))
			{
				return true;
			}
			if (!isMenuOpen && Object.op_Implicit((Object)(object)MenuManager.instance) && menuState != null)
			{
				return (int)menuState.GetValue(MenuManager.instance) == 0;
			}
			MenuPage val = (MenuPage)((Object.op_Implicit((Object)(object)MenuManager.instance) && currentPage != null) ? /*isinst with value type is only supported in some contexts*/: null);
			if (!Object.op_Implicit((Object)(object)val) || (Object)(object)val == (Object)(object)SettingsMenuPage || !((Component)val).gameObject.activeInHierarchy)
			{
				return false;
			}
			PageState val2 = (PageState)pageState.GetValue(val);
			return (int)val2 != 3 && (int)val2 != 5;
		}

		public static void Cleanup()
		{
			Close();
			if (Object.op_Implicit((Object)(object)SettingsPanel))
			{
				Object.Destroy((Object)(object)SettingsPanel);
			}
			SettingsPanel = null;
			WindowContainer = null;
			SettingsMenuPage = null;
			SettingsCanvasGroup = null;
			FooterHintText = null;
			statusText = null;
			gambitCountText = null;
			scrollViewport = null;
			scrollRect = null;
			scrollBar = null;
			pages.Clear();
			tabs.Clear();
			introLerp = 0f;
			KeybindHandler.IsRebinding = false;
		}

		private static void Close()
		{
			if (isMenuOpen && Object.op_Implicit((Object)(object)MenuManager.instance))
			{
				MenuManager.instance.MenuEffectPopUpClose();
				if (!OtherMenuOpen())
				{
					MenuManager.instance.StateSet((MenuState)1);
				}
			}
			isMenuOpen = false;
		}

		public static void UpdateTick()
		{
			//IL_0055: 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_020d: 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_0212: Unknown result type (might be due to invalid IL or missing references)
			//IL_0215: Unknown result type (might be due to invalid IL or missing references)
			//IL_021a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0225: Unknown result type (might be due to invalid IL or missing references)
			//IL_0295: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_03cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c8: 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)
			if (!Object.op_Implicit((Object)(object)SettingsPanel))
			{
				CreateSettingsMenu();
			}
			if (!Object.op_Implicit((Object)(object)SettingsPanel))
			{
				return;
			}
			bool flag = OtherMenuOpen();
			if (isMenuOpen && flag)
			{
				Close();
			}
			if (!KeybindHandler.IsRebinding && Input.GetKeyDown(GambitConfig.MenuKeybind.Value))
			{
				if (isMenuOpen)
				{
					Close();
				}
				else if (!flag)
				{
					if (!SettingsPanel.activeSelf)
					{
						WindowContainer.GetComponent<RectTransform>().anchoredPosition = new Vector2(0f, 50f);
					}
					isMenuOpen = true;
					SettingsPanel.transform.SetAsLastSibling();
					if (Object.op_Implicit((Object)(object)MenuManager.instance))
					{
						MenuManager.instance.MenuEffectPopUpOpen();
					}
				}
			}
			if (isMenuOpen && !KeybindHandler.IsRebinding && Input.GetKeyDown((KeyCode)27))
			{
				Close();
			}
			if (isMenuOpen)
			{
				if (Object.op_Implicit((Object)(object)MenuManager.instance))
				{
					MenuManager.instance.StateSet((MenuState)0);
				}
				if (Object.op_Implicit((Object)(object)CursorManager.instance))
				{
					CursorManager.instance.Unlock(0.1f);
				}
				if (Object.op_Implicit((Object)(object)PlayerController.instance) && inputDisableTimerField != null)
				{
					inputDisableTimerField.SetValue(PlayerController.instance, 0.1f);
				}
				SemiFunc.UIHideAim();
				SemiFunc.UIHideInventory();
				SemiFunc.UIHideHaul();
				SemiFunc.UIHideHealth();
				SemiFunc.UIHideEnergy();
				SemiFunc.CameraOverrideStopAim();
			}
			introLerp = Mathf.MoveTowards(introLerp, isMenuOpen ? 1f : 0f, Time.unscaledDeltaTime * 5f);
			RectTransform component = WindowContainer.GetComponent<RectTransform>();
			Vector2 val = (Vector2)(isMenuOpen ? Vector2.zero : new Vector2(0f, -50f));
			component.anchoredPosition = Vector2.Lerp(component.anchoredPosition, val, MotionBlend());
			SettingsCanvasGroup.alpha = Mathf.SmoothStep(0f, 1f, introLerp);
			SettingsPanel.SetActive(isMenuOpen || introLerp > 0f);
			UpdateFooterText();
			((TMP_Text)statusText).text = GambitSession.Instance.Status;
			((Graphic)statusText).color = Color.Lerp(((Graphic)statusText).color, (!GambitSession.CanEdit && GambitSession.Instance.Ready) ? repoOrange : Color.gray, MotionBlend());
			if (selectedPage == 0 && !string.IsNullOrEmpty(GambitEncounters.Status))
			{
				TextMeshProUGUI obj = statusText;
				((TMP_Text)obj).text = ((TMP_Text)obj).text + "  |  " + GambitEncounters.Status;
			}
			if (isMenuOpen && selectedPage == 0 && Object.op_Implicit((Object)(object)gambitCountText))
			{
				int num = GambitEncounters.GambitCount();
				GambitSession instance = GambitSession.Instance;
				bool flag2 = instance.Ready && num >= instance.Rules.MaximumGambits;
				string arg = (instance.Ready ? instance.Rules.MaximumGambits.ToString() : "?");
				((TMP_Text)gambitCountText).text = $"Gambits in level: {num} / {arg}" + (flag2 ? " - Limit reached" : "");
				((Graphic)gambitCountText).color = Color.Lerp(((Graphic)gambitCountText).color, flag2 ? repoOrange : Color.white, MotionBlend());
			}
		}

		private static void UpdateFooterText()
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)FooterHintText))
			{
				((TMP_Text)FooterHintText).text = "Press " + KeyName(GambitConfig.MenuKeybind.Value) + " to Close";
			}
		}

		private static GameObject RectObject(string name, Transform parent, Vector2 size, Vector2 position)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_0031: 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)
			GameObject val = new GameObject(name, new Type[1] { typeof(RectTransform) });
			val.transform.SetParent(parent, false);
			RectTransform component = val.GetComponent<RectTransform>();
			component.sizeDelta = size;
			component.anchoredPosition = position;
			return val;
		}

		private static void Stretch(RectTransform rect)
		{
			//IL_0002: 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_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			rect.anchorMin = Vector2.zero;
			rect.anchorMax = Vector2.one;
			rect.offsetMin = Vector2.zero;
			rect.offsetMax = Vector2.zero;
		}

		private static void CreateSettingsMenu()
		{
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_016c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0190: Unknown result type (might be due to invalid IL or missing references)
			//IL_0195: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f2: 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_0220: Unknown result type (might be due to invalid IL or missing references)
			//IL_024e: Unknown result type (might be due to invalid IL or missing references)
			//IL_025d: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fd: 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_0335: Unknown result type (might be due to invalid IL or missing references)
			//IL_033a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0361: Unknown result type (might be due to invalid IL or missing references)
			//IL_0378: 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_03a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_03cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_0491: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0623: Unknown result type (might be due to invalid IL or missing references)
			//IL_067d: 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_055e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0566: Unknown result type (might be due to invalid IL or missing references)
			//IL_057a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0587: Unknown result type (might be due to invalid IL or missing references)
			//IL_06eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0760: Unknown result type (might be due to invalid IL or missing references)
			//IL_0767: Unknown result type (might be due to invalid IL or missing references)
			//IL_077b: Unknown result type (might be due to invalid IL or missing references)
			//IL_07d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_07e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_083b: Unknown result type (might be due to invalid IL or missing references)
			//IL_08b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_08b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_08cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0927: Unknown result type (might be due to invalid IL or missing references)
			//IL_0936: Unknown result type (might be due to invalid IL or missing references)
			//IL_09b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a23: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a91: Unknown result type (might be due to invalid IL or missing references)
			//IL_0af2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b01: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b15: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b77: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b86: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b9a: Unknown result type (might be due to invalid IL or missing references)
			object obj2;
			if (!Object.op_Implicit((Object)(object)MenuHolder.instance))
			{
				GameObject obj = GameObject.Find("Game Hud");
				obj2 = ((obj != null) ? obj.transform : null);
			}
			else
			{
				obj2 = ((Component)MenuHolder.instance).transform;
			}
			Transform val = (Transform)obj2;
			if (!Object.op_Implicit((Object)(object)val))
			{
				return;
			}
			pages.Clear();
			tabs.Clear();
			isMenuOpen = false;
			introLerp = 0f;
			GameObject val2 = GameObject.Find("Tax Haul");
			if (Object.op_Implicit((Object)(object)val2) && Object.op_Implicit((Object)(object)val2.GetComponent<TMP_Text>()))
			{
				nativeFont = val2.GetComponent<TMP_Text>().font;
			}
			SettingsPanel = RectObject("GambitGambler_SettingsRoot", val, Vector2.zero, Vector2.zero);
			SettingsPanel.layer = ((Component)val).gameObject.layer;
			SettingsCanvasGroup = SettingsPanel.AddComponent<CanvasGroup>();
			SettingsCanvasGroup.blocksRaycasts = true;
			SettingsCanvasGroup.alpha = 0f;
			SettingsMenuPage = SettingsPanel.AddComponent<MenuPage>();
			((Behaviour)SettingsMenuPage).enabled = false;
			Stretch(SettingsPanel.GetComponent<RectTransform>());
			GameObject val3 = RectObject("Dimmer", SettingsPanel.transform, Vector2.zero, Vector2.zero);
			Stretch(val3.GetComponent<RectTransform>());
			((Graphic)val3.AddComponent<Image>()).color = new Color(0f, 0f, 0f, 0.7f);
			WindowContainer = RectObject("WindowContainer", SettingsPanel.transform, new Vector2(500f, 350f), Vector2.zero);
			((Graphic)WindowContainer.AddComponent<Image>()).color = new Color(0.02f, 0.02f, 0.02f, 0.4f);
			CreateTextElement("Title", "GAMBIT GAMBLER SETTINGS", 36, new Vector2(0f, 130f), WindowContainer.transform, repoOrange, (TextAlignmentOptions)514, new Vector2(480f, 60f));
			CreateResetButton(new Vector2(0f, 90f), WindowContainer.transform);
			GameObject val4 = RectObject("Viewport", WindowContainer.transform, new Vector2(380f, 145f), new Vector2(-8f, -42.5f));
			scrollViewport = val4.GetComponent<RectTransform>();
			val4.AddComponent<RectMask2D>();
			scrollRect = WindowContainer.AddComponent<ScrollRect>();
			scrollRect.viewport = scrollViewport;
			scrollRect.horizontal = false;
			scrollRect.vertical = true;
			scrollRect.inertia = false;
			scrollRect.movementType = (MovementType)2;
			((Behaviour)scrollRect).enabled = false;
			GameObject val5 = RectObject("Scrollbar", WindowContainer.transform, new Vector2(12f, 145f), new Vector2(195f, -42.5f));
			Image val6 = val5.AddComponent<Image>();
			((Graphic)val6).color = repoBlueBorder;
			GameObject val7 = RectObject("InnerHole", val5.transform, new Vector2(8f, 141f), Vector2.zero);
			((Graphic)val7.AddComponent<Image>()).color = new Color(0f, 0f, 0f, 0.95f);
			GameObject val8 = RectObject("Handle", val5.transform, Vector2.zero, Vector2.zero);
			RectTransform component = val8.GetComponent<RectTransform>();
			Stretch(component);
			component.offsetMin = new Vector2(2f, 2f);
			component.offsetMax = new Vector2(-2f, -2f);
			((Graphic)val8.AddComponent<Image>()).color = repoBlueBorder;
			scrollBar = val5.AddComponent<Scrollbar>();
			scrollBar.handleRect = component;
			scrollBar.direction = (Direction)2;
			((Selectable)scrollBar).transition = (Transition)0;
			((Behaviour)scrollBar).enabled = false;
			ScrollInput scrollInput = WindowContainer.AddComponent<ScrollInput>();
			scrollInput.Track = val5.GetComponent<RectTransform>();
			scrollInput.Border = val6;
			string[] array = new string[3] { "ENCOUNTERS", "REWARDS", "PENALTIES" };
			Vector2 val10 = default(Vector2);
			for (int i = 0; i < array.Length; i++)
			{
				int index = i;
				tabs.Add(CreateAction(array[i], new Vector2((float)(-130 + i * 130), 55f), new Vector2(120f, 26f), WindowContainer.transform, delegate
				{
					SelectPage(index);
				}, () => true));
				((Component)tabs[i]).gameObject.AddComponent<SelectionColor>().Selected = () => selectedPage == index;
				GameObject val9 = RectObject(array[i], val4.transform, new Vector2(380f, (float)((i == 0) ? 350 : 250)), Vector2.zero);
				RectTransform component2 = val9.GetComponent<RectTransform>();
				((Vector2)(ref val10))..ctor(0.5f, 1f);
				component2.anchorMax = val10;
				component2.anchorMin = val10;
				component2.pivot = new Vector2(0.5f, 1f);
				component2.anchoredPosition = Vector2.zero;
				pages.Add(val9);
				CreateKeybindRow("MENU KEYBIND", new Vector2(0f, (float)((i == 0) ? (-115) : (-70))), val9.transform);
			}
			Transform transform = pages[0].transform;
			Transform transform2 = pages[1].transform;
			Transform transform3 = pages[2].transform;
			CreateSettingRow("EXTRA ENCOUNTERS", new Vector2(0f, 150f), transform, () => GambitSession.Instance.Rules.ExtraEncounters, delegate(bool value)
			{
				GambitSession.Instance.Change(delegate(GambitRules rules)
				{
					rules.ExtraEncounters = value;
				});
			});
			CreateSlider("ADDITIONAL SPAWN CHANCE", new Vector2(0f, 95f), transform, 0f, 100f, 1f, () => GambitSession.Instance.Rules.SpawnChance, delegate(float value)
			{
				GambitSession.Instance.Change(delegate(GambitRules rules)
				{
					rules.SpawnChance = value;
				});
			}, "%");
			CreateSlider("MAXIMUM GAMBITS", new Vector2(0f, 35f), transform, 1f, 5f, 1f, () => GambitSession.Instance.Rules.MaximumGambits, delegate(float value)
			{
				GambitSession.Instance.Change(delegate(GambitRules rules)
				{
					rules.MaximumGambits = Mathf.RoundToInt(value);
				});
			}, "");
			gambitCountText = CreateTextElement("GambitCount", "", 18, new Vector2(0f, -14.25f), transform, Color.white, (TextAlignmentOptions)514, new Vector2(380f, 24f));
			((TMP_Text)gambitCountText).enableAutoSizing = true;
			((TMP_Text)gambitCountText).fontSizeMin = 14f;
			((TMP_Text)gambitCountText).fontSizeMax = 18f;
			((TMP_Text)gambitCountText).textWrappingMode = (TextWrappingModes)0;
			CreateAction("SPAWN GAMBIT NOW", new Vector2(0f, -55f), new Vector2(380f, 35f), transform, GambitEncounters.SpawnNow, () => GambitSession.CanEdit && SemiFunc.RunIsLevel() && SemiFunc.LevelGenDone() && !GambitEncounters.Spawning && !GambitEncounters.AtLimit());
			CreateSlider("REWARD MULTIPLIER", new Vector2(0f, 95f), transform2, 0f, 5f, 0.1f, () => GambitSession.Instance.Rules.RewardMultiplier, delegate(float value)
			{
				GambitSession.Instance.Change(delegate(GambitRules rules)
				{
					rules.RewardMultiplier = value;
				});
			}, "x");
			CreateTextElement("DeliveryLabel", "PAYOUT DELIVERY", 20, new Vector2(0f, 40f), transform2, Color.white, (TextAlignmentOptions)514, new Vector2(380f, 30f));
			string[] array2 = new string[3] { "CURRENT", "BAGS ONLY", "DEPOSIT" };
			for (int num = 0; num < array2.Length; num++)
			{
				PayoutDelivery mode = (PayoutDelivery)num;
				TextMeshProUGUI val11 = CreateAction(array2[num], new Vector2((float)(-125 + num * 125), 0f), new Vector2(120f, 35f), transform2, delegate
				{
					GambitSession.Instance.Change(delegate(GambitRules rules)
					{
						rules.Delivery = mode;
					});
				}, () => GambitSession.CanEdit);
				((Component)val11).gameObject.AddComponent<SelectionColor>().Selected = () => GambitSession.Instance.Rules.Delivery == mode;
			}
			CreateSlider("STEAL MULTIPLIER", new Vector2(0f, 95f), transform3, 0f, 3f, 0.1f, () => GambitSession.Instance.Rules.StealMultiplier, delegate(float value)
			{
				GambitSession.Instance.Change(delegate(GambitRules rules)
				{
					rules.StealMultiplier = value;
				});
			}, "x");
			CreateSlider("BANKRUPTCY LOSS", new Vector2(0f, 35f), transform3, 0f, 100f, 1f, () => GambitSession.Instance.Rules.BankruptcyPercent, delegate(float value)
			{
				GambitSession.Instance.Change(delegate(GambitRules rules)
				{
					rules.BankruptcyPercent = value;
				});
			}, "%");
			CreateSettingRow("ALERT NEARBY ENEMIES", new Vector2(0f, -25f), transform3, () => GambitSession.Instance.Rules.AlertEnemies, delegate(bool value)
			{
				GambitSession.Instance.Change(delegate(GambitRules rules)
				{
					rules.AlertEnemies = value;
				});
			});
			statusText = CreateTextElement("Status", "", 16, new Vector2(0f, -130f), WindowContainer.transform, Color.gray, (TextAlignmentOptions)514, new Vector2(400f, 22f));
			((TMP_Text)statusText).enableAutoSizing = true;
			((TMP_Text)statusText).fontSizeMin = 11f;
			((TMP_Text)statusText).fontSizeMax = 16f;
			((TMP_Text)statusText).textWrappingMode = (TextWrappingModes)0;
			FooterHintText = CreateTextElement("Hint", "", 18, new Vector2(0f, -155f), WindowContainer.transform, Color.white, (TextAlignmentOptions)514, new Vector2(380f, 24f));
			SelectPage(selectedPage);
			SettingsPanel.SetActive(false);
		}

		private static void SelectPage(int index)
		{
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			selectedPage = index;
			for (int i = 0; i < pages.Count; i++)
			{
				pages[i].SetActive(i == index);
			}
			scrollRect.content = pages[index].GetComponent<RectTransform>();
			scrollRect.content.anchoredPosition = Vector2.zero;
			SetScrollPosition(1f, immediate: true);
		}

		private static void SetScrollPosition(float value, bool immediate = false)
		{
			scrollTarget = Mathf.Clamp01(value);
			if (immediate)
			{
				scrollRect.verticalNormalizedPosition = scrollTarget;
			}
			UpdateScrollbar();
		}

		private static void UpdateScrollbar()
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: 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_002a: Unknown result type (might be due to invalid IL or missing references)
			RectTransform val = (RectTransform)((Component)scrollBar).transform;
			Scrollbar obj = scrollBar;
			Rect rect = val.rect;
			float width = ((Rect)(ref rect)).width;
			rect = val.rect;
			obj.size = Mathf.Clamp01(width / ((Rect)(ref rect)).height);
			scrollBar.SetValueWithoutNotify(Mathf.Clamp01(scrollRect.verticalNormalizedPosition));
		}

		private static void CreateResetButton(Vector2 position, Transform parent)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: 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_0034: 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)
			GameObject val = RectObject("ResetBtn", parent, new Vector2(380f, 25f), position);
			TextMeshProUGUI text = CreateTextElement("Label", "RESET TO DEFAULT SETTINGS", 18, Vector2.zero, val.transform, Color.gray, (TextAlignmentOptions)514, new Vector2(380f, 25f));
			ResetHandler resetHandler = val.AddComponent<ResetHandler>();
			resetHandler.Text = text;
			resetHandler.Rect = val.GetComponent<RectTransform>();
		}

		private static TextMeshProUGUI CreateAction(string label, Vector2 position, Vector2 size, Transform parent, Action action, Func<bool> enabled)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: 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_0034: 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_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: 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)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = RectObject(label, parent, size, position);
			Image val2 = val.AddComponent<Image>();
			((Graphic)val2).color = repoBlueBorder;
			GameObject val3 = RectObject("InnerHole", val.transform, size - new Vector2(4f, 4f), Vector2.zero);
			((Graphic)val3.AddComponent<Image>()).color = new Color(0f, 0f, 0f, 0.95f);
			TextMeshProUGUI val4 = CreateTextElement("Label", label, 18, Vector2.zero, val3.transform, Color.white, (TextAlignmentOptions)514, size - new Vector2(8f, 4f));
			ActionHandler actionHandler = val.AddComponent<ActionHandler>();
			actionHandler.Rect = val.GetComponent<RectTransform>();
			actionHandler.Border = val2;
			actionHandler.Text = val4;
			actionHandler.Action = action;
			actionHandler.Enabled = enabled;
			return val4;
		}

		private static bool Hover(RectTransform target)
		{
			//IL_003f: 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: 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_0074: 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)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)target) || !Object.op_Implicit((Object)(object)MenuCursor.instance))
			{
				return false;
			}
			Rect rect;
			if (Object.op_Implicit((Object)(object)scrollViewport) && ((Transform)target).IsChildOf((Transform)(object)scrollViewport))
			{
				rect = scrollViewport.rect;
				if (!((Rect)(ref rect)).Contains(((Transform)scrollViewport).InverseTransformPoint(((Component)MenuCursor.instance).transform.position)))
				{
					return false;
				}
			}
			rect = target.rect;
			return ((Rect)(ref rect)).Contains(((Transform)target).InverseTransformPoint(((Component)MenuCursor.instance).transform.position));
		}

		private static void CreateSlider(string label, Vector2 position, Transform parent, float min, float max, float step, Func<float> getter, Action<float> setter, string suffix)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: 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_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00