Decompiled source of Megabonk Community Patch v1.4.1

BepInEx\plugins\MegaBonkMod\MegaBonkMod.dll

Decompiled 5 days ago
using System;
using System.Collections;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics;
using System.Net.Http;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Text.Json;
using System.Text.Json.Serialization;
using System.Threading.Tasks;
using Actors.Enemies;
using Assets.Scripts.Actors;
using Assets.Scripts.Actors.Enemies;
using Assets.Scripts.Actors.Player;
using Assets.Scripts.Game.Combat;
using Assets.Scripts.Game.Combat.ConstantAttacks;
using Assets.Scripts.Game.MapGeneration;
using Assets.Scripts.Game.Spawning;
using Assets.Scripts.Inventory.Stats;
using Assets.Scripts.Inventory__Items__Pickups;
using Assets.Scripts.Inventory__Items__Pickups.AbilitiesPassive;
using Assets.Scripts.Inventory__Items__Pickups.AbilitiesPassive.Implementations;
using Assets.Scripts.Inventory__Items__Pickups.Chests;
using Assets.Scripts.Inventory__Items__Pickups.Interactables;
using Assets.Scripts.Inventory__Items__Pickups.Items;
using Assets.Scripts.Inventory__Items__Pickups.Items.ItemImplementations;
using Assets.Scripts.Inventory__Items__Pickups.Pickups;
using Assets.Scripts.Inventory__Items__Pickups.Stats;
using Assets.Scripts.Inventory__Items__Pickups.Upgrades;
using Assets.Scripts.Inventory__Items__Pickups.Weapons;
using Assets.Scripts.Inventory__Items__Pickups.Weapons.Projectiles;
using Assets.Scripts.Managers;
using Assets.Scripts.Menu.Shop;
using Assets.Scripts.Saves___Serialization.Progression.Achievements;
using Assets.Scripts.Saves___Serialization.Progression.Stats;
using Assets.Scripts.Saves___Serialization.Progression.Unlocks;
using Assets.Scripts.Saves___Serialization.SaveFiles.Configs.ConfigSettingsTypes;
using Assets.Scripts.Settings___Saves.SaveFiles;
using Assets.Scripts.Settings___Saves.SaveFiles.ConfigSaves;
using Assets.Scripts.Steam;
using Assets.Scripts.Steam.LeaderboardsNew;
using Assets.Scripts.UI.HUD;
using Assets.Scripts.UI.InGame.Levelup;
using Assets.Scripts.UI.InGame.Rewards;
using Assets.Scripts.UI.InGame.Rewards.Effects;
using Assets.Scripts.Utility;
using Assets.Scripts._Data;
using Assets.Scripts._Data.Tomes;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using HarmonyLib;
using Il2CppInterop.Runtime;
using Il2CppInterop.Runtime.Injection;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSystem;
using Il2CppSystem.Collections.Generic;
using Il2CppSystem.Reflection;
using Inventory__Items__Pickups.Xp_and_Levels;
using Steamworks;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.Localization;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("MegaBonkMod")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("MegaBonkMod")]
[assembly: AssemblyTitle("MegaBonkMod")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace MegaBonkMod;

internal static class AutoLevelPick
{
	private struct Choice
	{
		public UpgradeButton Btn;

		public bool IsTome;

		public bool IsWeapon;

		public ETome Tome;

		public ERarity Rarity;

		public bool IsNew;

		public int StatRank;

		public string Name;
	}

	private static ConfigEntry<bool> _enabled;

	private static bool _selecting;

	private static UpgradePicker _picker;

	internal const int LogMax = 10;

	internal static readonly List<string> Log = new List<string>();

	internal static bool Visible;

	private const float WinW = 460f;

	private const float PadX = 12f;

	private const float LineH = 22f;

	private static readonly GuiWindowFrame _frame = new GuiWindowFrame(new Vector2(60f, 200f));

	private static float _lastWinH;

	private const float DifficultyCap = 600f;

	private static ServerFeed _feed;

	internal static bool Enabled
	{
		get
		{
			if (_enabled != null)
			{
				return _enabled.Value;
			}
			return false;
		}
		set
		{
			if (_enabled != null)
			{
				_enabled.Value = value;
			}
		}
	}

	private static UpgradePicker Picker
	{
		get
		{
			if ((Object)(object)_picker == (Object)null)
			{
				_picker = Object.FindObjectOfType<UpgradePicker>();
			}
			return _picker;
		}
	}

	private static ServerFeed Feed
	{
		get
		{
			if ((Object)(object)_feed == (Object)null)
			{
				_feed = Object.FindObjectOfType<ServerFeed>();
			}
			return _feed;
		}
	}

	internal static void Init(ConfigFile cfg)
	{
		_enabled = cfg.Bind<bool>("AutoUpgrade", "Enabled", false, "Scaling-aware auto-upgrade on level up. Prefers snowball picks (XP / difficulty / luck / new weapons) early and premium Legendary scaling rolls, instead of the game's plain highest-rarity pick. Toggle in-game with the Auto Upgrade hotkey.");
	}

	internal static bool TryAutoPick()
	{
		//IL_0059: Unknown result type (might be due to invalid IL or missing references)
		//IL_0060: Expected O, but got Unknown
		if (!Enabled || _selecting)
		{
			return false;
		}
		UpgradePicker picker = Picker;
		MyPlayer instance = MyPlayer.Instance;
		PlayerInventory val = ((instance != null) ? instance.inventory : null);
		if ((Object)(object)picker == (Object)null || val == null)
		{
			return false;
		}
		_selecting = true;
		try
		{
			picker.ShuffleUpgrades((EEncounter)0);
			Decide(picker, val);
			return true;
		}
		catch (Exception ex)
		{
			ManualLogSource log = Plugin.Log;
			bool flag = default(bool);
			BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(16, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[AutoLevelPick] ");
				((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex.Message);
			}
			log.LogError(val2);
			return false;
		}
		finally
		{
			_selecting = false;
		}
	}

	internal static void Toggle()
	{
		//IL_002b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0031: Expected O, but got Unknown
		//IL_008d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0072: Unknown result type (might be due to invalid IL or missing references)
		Enabled = !Enabled;
		string text = (Enabled ? "ON" : "OFF");
		ManualLogSource log = Plugin.Log;
		bool flag = default(bool);
		BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(16, 1, ref flag);
		if (flag)
		{
			((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[AutoLevelPick] ");
			((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(text);
		}
		log.LogInfo(val);
		Toast.Show("Scaling Auto-Upgrade: " + text, Enabled ? new Color(0.5f, 1f, 0.5f, 1f) : new Color(1f, 0.6f, 0.45f, 1f));
	}

	private static void Record(string line)
	{
		Log.Add(line);
		if (Log.Count > 10)
		{
			Log.RemoveRange(0, Log.Count - 10);
		}
	}

	internal static void ToggleWindow()
	{
		Visible = !Visible;
	}

	private static float WinHeight()
	{
		return 74f + (float)Mathf.Max(1, Log.Count) * 23f + 10f;
	}

	internal static void HandleInput()
	{
		_frame.HandleInput(460f, (_lastWinH > 0f) ? _lastWinH : WinHeight(), 26f);
	}

	internal static void Draw()
	{
		//IL_0019: Unknown result type (might be due to invalid IL or missing references)
		//IL_001e: 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_0058: Unknown result type (might be due to invalid IL or missing references)
		//IL_008e: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
		//IL_0149: Unknown result type (might be due to invalid IL or missing references)
		//IL_0119: Unknown result type (might be due to invalid IL or missing references)
		if (!Visible)
		{
			return;
		}
		float num = (_lastWinH = WinHeight());
		Matrix4x4 old = _frame.Begin();
		float x = _frame.Pivot.x;
		float y = _frame.Pivot.y;
		UiTheme.Backdrop(new Rect(x, y, 460f, num));
		GUI.Box(new Rect(x, y, 460f, num), "Scaling Auto-Upgrade");
		float num2 = 436f;
		float num3 = x + 12f;
		float num4 = y + 22f + 2f;
		GUI.Label(new Rect(num3, num4, num2, 22f), Enabled ? "Status: ON (auto-picking level-ups)" : "Status: OFF");
		num4 += 22f;
		GUI.Label(new Rect(num3, num4, num2, 22f), "Recent picks (newest first):");
		num4 += 22f;
		if (Log.Count == 0)
		{
			GUI.Label(new Rect(num3, num4, num2, 22f), "  (none yet)");
		}
		else
		{
			for (int num5 = Log.Count - 1; num5 >= 0; num5--)
			{
				GUI.Label(new Rect(num3, num4, num2, 22f), Log[num5]);
				num4 += 23f;
			}
		}
		_frame.End(old);
		_frame.DrawGrip(460f, num);
	}

	private static int RarityWeight(ERarity r)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_001e: Expected I4, but got Unknown
		return (int)r switch
		{
			5 => 6, 
			4 => 5, 
			0 => 4, 
			3 => 3, 
			2 => 2, 
			1 => 1, 
			_ => 0, 
		};
	}

	private static int WeaponStatRank(EStat s)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_0003: Invalid comparison between Unknown and I4
		//IL_0011: Unknown result type (might be due to invalid IL or missing references)
		//IL_0014: Unknown result type (might be due to invalid IL or missing references)
		//IL_002a: Expected I4, but got Unknown
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		//IL_0008: Invalid comparison between Unknown and I4
		//IL_002a: Unknown result type (might be due to invalid IL or missing references)
		//IL_002d: Invalid comparison between Unknown and I4
		//IL_000a: Unknown result type (might be due to invalid IL or missing references)
		//IL_000d: Invalid comparison between Unknown and I4
		if ((int)s <= 12)
		{
			if ((int)s == 9)
			{
				return 3;
			}
			if ((int)s == 12)
			{
				return 5;
			}
		}
		else
		{
			switch (s - 16)
			{
			default:
				if ((int)s != 45)
				{
					break;
				}
				return 1;
			case 3:
				return 6;
			case 2:
				return 4;
			case 0:
				return 2;
			case 1:
				break;
			}
		}
		return 0;
	}

	private static int BestStatRank(UpgradeButton b)
	{
		//IL_002c: Unknown result type (might be due to invalid IL or missing references)
		int num = 0;
		try
		{
			List<StatModifier> upgradeOffer = b.upgradeOffer;
			if (upgradeOffer == null)
			{
				return 0;
			}
			int count = upgradeOffer.Count;
			for (int i = 0; i < count; i++)
			{
				StatModifier val = upgradeOffer[i];
				if (val != null)
				{
					int num2 = WeaponStatRank(val.stat);
					if (num2 > num)
					{
						num = num2;
					}
				}
			}
		}
		catch
		{
		}
		return num;
	}

	private static int Importance(Choice c)
	{
		//IL_0009: 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_000f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0012: Invalid comparison between Unknown and I4
		//IL_0014: Unknown result type (might be due to invalid IL or missing references)
		//IL_0017: Invalid comparison between Unknown and I4
		//IL_0019: Unknown result type (might be due to invalid IL or missing references)
		//IL_001c: Invalid comparison between Unknown and I4
		if (c.IsTome)
		{
			ETome tome = c.Tome;
			if ((int)tome != 13)
			{
				if ((int)tome != 14)
				{
					if ((int)tome == 21)
					{
						return 90;
					}
					return 10;
				}
				return 100;
			}
			return 80;
		}
		if (c.IsWeapon)
		{
			return 10 + c.StatRank;
		}
		return 0;
	}

	private static float XpHeadroom()
	{
		try
		{
			float maxXpMultiplier = PlayerXp.maxXpMultiplier;
			if (maxXpMultiplier <= 0f)
			{
				return 1f;
			}
			float stat = PlayerStats.GetStat((EStat)32);
			return Mathf.Clamp01(1f - stat / maxXpMultiplier);
		}
		catch
		{
			return 1f;
		}
	}

	private static List<Choice> Gather(UpgradePicker picker)
	{
		//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
		//IL_005e: 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_006f: Unknown result type (might be due to invalid IL or missing references)
		List<Choice> list = new List<Choice>();
		Il2CppReferenceArray<UpgradeButton> buttons = picker.buttons;
		if (buttons == null)
		{
			return list;
		}
		foreach (UpgradeButton item2 in (Il2CppArrayBase<UpgradeButton>)(object)buttons)
		{
			if ((Object)(object)item2 == (Object)null || item2.isItem)
			{
				continue;
			}
			IUpgradable upgradable = item2.upgradable;
			if (upgradable != null)
			{
				Choice item = new Choice
				{
					Btn = item2,
					Rarity = item2.rarity
				};
				try
				{
					item.IsNew = (int)item2.rarity == 0 || upgradable.GetLevel() <= 0;
				}
				catch
				{
				}
				try
				{
					item.Name = upgradable.GetName() ?? "?";
				}
				catch
				{
					item.Name = "?";
				}
				TomeData val = ((Il2CppObjectBase)upgradable).TryCast<TomeData>();
				if ((Object)(object)val != (Object)null)
				{
					item.IsTome = true;
					item.Tome = val.eTome;
				}
				else if ((Object)(object)((Il2CppObjectBase)upgradable).TryCast<WeaponData>() != (Object)null)
				{
					item.IsWeapon = true;
					item.StatRank = BestStatRank(item2);
				}
				list.Add(item);
			}
		}
		return list;
	}

	private static bool IsScalingTome(Choice c)
	{
		//IL_0009: Unknown result type (might be due to invalid IL or missing references)
		//IL_0010: Invalid comparison between Unknown and I4
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0022: Invalid comparison between Unknown and I4
		if (c.IsTome)
		{
			if ((int)c.Tome != 21 || IsCappedDiff(c))
			{
				if ((int)c.Tome == 14)
				{
					return !IsCappedXp(c);
				}
				return false;
			}
			return true;
		}
		return false;
	}

	private static bool IsCappedXp(Choice c)
	{
		//IL_0009: Unknown result type (might be due to invalid IL or missing references)
		//IL_0010: Invalid comparison between Unknown and I4
		if (c.IsTome && (int)c.Tome == 14)
		{
			return XpHeadroom() <= 0.15f;
		}
		return false;
	}

	private static bool IsCappedDiff(Choice c)
	{
		//IL_0009: Unknown result type (might be due to invalid IL or missing references)
		//IL_0010: Invalid comparison between Unknown and I4
		if (!c.IsTome || (int)c.Tome != 21)
		{
			return false;
		}
		try
		{
			return PlayerStats.GetStat((EStat)38) >= 600f;
		}
		catch
		{
			return false;
		}
	}

	private static void Decide(UpgradePicker picker, PlayerInventory inv)
	{
		List<Choice> list = Gather(picker);
		if (list.Count != 0)
		{
			if (Best(list, (Choice c) => c.IsNew || (int)c.Rarity == 5, out var best))
			{
				Commit(inv, list, best, "bucket 1 (new / legendary)");
			}
			else if (Best(list, IsScalingTome, out best))
			{
				Commit(inv, list, best, "bucket 2 (scaling tome)");
			}
			else if (Best(list, (Choice c) => !IsCappedXp(c) && !IsCappedDiff(c), out best))
			{
				Commit(inv, list, best, "bucket 3 (other tome / weapon)");
			}
			else if (Best(list, (Choice _) => true, out best))
			{
				Commit(inv, list, best, "bucket 4 (capped XP / difficulty — last resort)");
			}
		}
	}

	private static bool Best(List<Choice> choices, Func<Choice, bool> match, out Choice best)
	{
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		best = default(Choice);
		int num = -1;
		foreach (Choice choice in choices)
		{
			if (match(choice))
			{
				int num2 = RarityWeight(choice.Rarity) * 1000 + Importance(choice);
				if (num2 > num)
				{
					num = num2;
					best = choice;
				}
			}
		}
		return num >= 0;
	}

	private static void Commit(PlayerInventory inv, List<Choice> choices, Choice c, string reason)
	{
		//IL_0060: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_0116: Unknown result type (might be due to invalid IL or missing references)
		//IL_011d: Expected O, but got Unknown
		//IL_014a: Unknown result type (might be due to invalid IL or missing references)
		//IL_015b: Unknown result type (might be due to invalid IL or missing references)
		UpgradeButton btn = c.Btn;
		if ((Object)(object)btn == (Object)null)
		{
			return;
		}
		List<string> list = new List<string>();
		foreach (Choice choice in choices)
		{
			if ((Object)(object)choice.Btn != (Object)(object)btn)
			{
				list.Add($"{choice.Name} ({choice.Rarity})");
			}
		}
		string text = $"{c.Name} ({c.Rarity}) — {reason}";
		if (list.Count > 0)
		{
			text = text + "  | over: " + string.Join(", ", list);
		}
		Record(text);
		ManualLogSource log = Plugin.Log;
		bool flag = default(bool);
		BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(23, 1, ref flag);
		if (flag)
		{
			((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[AutoLevelPick] picked ");
			((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(text);
		}
		log.LogInfo(val);
		inv.AddUpgrade(btn.upgradable, btn.upgradeOffer, btn.rarity);
		ShowFeed(btn.upgradable, btn.rarity);
	}

	private static void ShowFeed(IUpgradable up, ERarity rarity)
	{
		//IL_007f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0086: Expected O, but got Unknown
		//IL_0045: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			ServerFeed feed = Feed;
			if (!((Object)(object)feed == (Object)null) && up != null)
			{
				string value = up.GetName() ?? "?";
				string text = $"{value} ({rarity})";
				feed.SetFeed(text, 4f, up.GetIcon());
			}
		}
		catch (Exception ex)
		{
			ManualLogSource log = Plugin.Log;
			bool flag = default(bool);
			BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(21, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[AutoLevelPick] feed ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
			}
			log.LogError(val);
		}
	}
}
[HarmonyPatch(typeof(EncounterWindows), "AddEncounter")]
internal static class Patch_AutoLevelPick
{
	[HarmonyPrefix]
	private static bool Prefix(EEncounter rewardWindowType)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		if ((int)rewardWindowType != 0)
		{
			return true;
		}
		if (!AutoLevelPick.Enabled)
		{
			return true;
		}
		return !AutoLevelPick.TryAutoPick();
	}
}
internal static class ChaosMenu
{
	private static readonly (int id, string name, bool def)[] Stats = new(int, string, bool)[9]
	{
		(1, "Health Regen", false),
		(2, "Shield", false),
		(3, "Thorns", false),
		(4, "Armor", false),
		(5, "Evasion", false),
		(11, "Projectile Speed", false),
		(24, "Knockback", false),
		(10, "Duration", true),
		(25, "Movement Speed", true)
	};

	private static ConfigEntry<bool>[] _allow;

	private static ConfigFile _cfg;

	internal static bool Visible;

	private const float WinW = 260f;

	private const float PadX = 12f;

	private const float LineH = 24f;

	private static readonly GuiWindowFrame _frame = new GuiWindowFrame(new Vector2(40f, 120f));

	private static float _lastWinH;

	private static float WinHeight()
	{
		return 56f + (float)Stats.Length * 26f + 8f;
	}

	internal static void HandleInput()
	{
		_frame.HandleInput(260f, (_lastWinH > 0f) ? _lastWinH : WinHeight(), 28f);
	}

	internal static void Init(ConfigFile cfg)
	{
		_cfg = cfg;
		_allow = new ConfigEntry<bool>[Stats.Length];
		for (int i = 0; i < Stats.Length; i++)
		{
			_allow[i] = cfg.Bind<bool>("ChaosStats", Stats[i].name, Stats[i].def, "Allow '" + Stats[i].name + "' to appear in the Chaos Tome / Gamble pool.");
		}
		ApplyAllToBlacklist();
	}

	private static void ApplyAllToBlacklist()
	{
		for (int i = 0; i < Stats.Length; i++)
		{
			if (_allow[i].Value)
			{
				Plugin.BlacklistedStats.Remove(Stats[i].id);
			}
			else
			{
				Plugin.BlacklistedStats.Add(Stats[i].id);
			}
		}
	}

	internal static void Toggle()
	{
		Visible = !Visible;
	}

	private static void SetAllowed(int idx, bool allowed)
	{
		//IL_006b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0082: Unknown result type (might be due to invalid IL or missing references)
		//IL_0070: 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_0079: Unknown result type (might be due to invalid IL or missing references)
		if (_allow[idx].Value == allowed)
		{
			return;
		}
		_allow[idx].Value = allowed;
		try
		{
			ConfigFile cfg = _cfg;
			if (cfg != null)
			{
				cfg.Save();
			}
		}
		catch
		{
		}
		int item = Stats[idx].id;
		if (allowed)
		{
			Plugin.BlacklistedStats.Remove(item);
		}
		else
		{
			Plugin.BlacklistedStats.Add(item);
		}
		try
		{
			List<EStat> upgradableStatsChaosAndGamble = EncounterUtility.upgradableStatsChaosAndGamble;
			if (upgradableStatsChaosAndGamble == null)
			{
				return;
			}
			EStat val = (EStat)item;
			if (allowed)
			{
				if (!upgradableStatsChaosAndGamble.Contains(val))
				{
					upgradableStatsChaosAndGamble.Add(val);
				}
			}
			else if (upgradableStatsChaosAndGamble.Contains(val))
			{
				upgradableStatsChaosAndGamble.Remove(val);
			}
		}
		catch
		{
		}
	}

	internal static void Draw()
	{
		//IL_0019: Unknown result type (might be due to invalid IL or missing references)
		//IL_001e: 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_0058: Unknown result type (might be due to invalid IL or missing references)
		//IL_008e: 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_0136: Unknown result type (might be due to invalid IL or missing references)
		if (!Visible)
		{
			return;
		}
		float num = (_lastWinH = WinHeight());
		Matrix4x4 old = _frame.Begin();
		float x = _frame.Pivot.x;
		float y = _frame.Pivot.y;
		UiTheme.Backdrop(new Rect(x, y, 260f, num));
		GUI.Box(new Rect(x, y, 260f, num), "Chaos Tome Stats");
		float num2 = 236f;
		float num3 = x + 12f;
		float num4 = y + 24f + 2f;
		GUI.Label(new Rect(num3, num4, num2, 24f), "Toggle stats in the Chaos/Gamble pool:");
		num4 += 24f;
		GUIStyle button = GUI.skin.button;
		for (int i = 0; i < Stats.Length; i++)
		{
			bool value = _allow[i].Value;
			bool flag = GUI.Toggle(new Rect(num3, num4, num2, 24f), value, (value ? "ON   " : "OFF  ") + Stats[i].name, button);
			if (flag != value)
			{
				SetAllowed(i, flag);
			}
			num4 += 26f;
		}
		_frame.End(old);
		_frame.DrawGrip(260f, num);
	}
}
internal static class CursedSwordAim
{
	internal const float AimRange = 30f;

	private static ConfigEntry<bool> _enabled;

	internal static bool Enabled
	{
		get
		{
			if (_enabled != null)
			{
				return _enabled.Value;
			}
			return false;
		}
		set
		{
			if (_enabled != null)
			{
				_enabled.Value = value;
			}
		}
	}

	internal static void Init(ConfigFile cfg)
	{
		_enabled = cfg.Bind<bool>("Weapons", "CursedSwordAutoAim", true, "Cursed Sword auto-aim: the Cursed Sword fires at the nearest enemy instead of along your facing direction. Always on; set false here to disable.");
	}
}
[HarmonyPatch(typeof(ProjectileCringeSword), "TryInit")]
internal static class Patch_CursedSwordAim
{
	internal struct AimState
	{
		public bool Changed;

		public Transform Renderer;

		public Quaternion Saved;
	}

	[HarmonyPrefix]
	private static void Prefix(ProjectileCringeSword __instance, out AimState __state)
	{
		//IL_0033: Unknown result type (might be due to invalid IL or missing references)
		//IL_003a: Invalid comparison between Unknown and I4
		//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_007b: Unknown result type (might be due to invalid IL or missing references)
		//IL_009a: Unknown result type (might be due to invalid IL or missing references)
		//IL_009f: 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)
		//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00db: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
		__state = default(AimState);
		try
		{
			if (!CursedSwordAim.Enabled)
			{
				return;
			}
			WeaponBase weaponBase = ((ProjectileBase)__instance).weaponBase;
			if (weaponBase == null)
			{
				return;
			}
			WeaponData weaponData = weaponBase.weaponData;
			if ((Object)(object)weaponData == (Object)null || (int)weaponData.eWeapon != 28)
			{
				return;
			}
			MyPlayer instance = MyPlayer.Instance;
			if ((Object)(object)instance == (Object)null)
			{
				return;
			}
			PlayerRenderer playerRenderer = instance.playerRenderer;
			if ((Object)(object)playerRenderer == (Object)null)
			{
				return;
			}
			Transform transform = ((Component)playerRenderer).transform;
			Vector3 position = transform.position;
			Enemy enemy = EnemyTargeting.GetEnemy(position, 30f, 0, false, (GameObject)null);
			if (!((Object)(object)enemy == (Object)null))
			{
				Vector3 val = enemy.GetCenterPosition() - position;
				val.y = 0f;
				if (!(((Vector3)(ref val)).sqrMagnitude < 0.0001f))
				{
					((Vector3)(ref val)).Normalize();
					__state.Renderer = transform;
					__state.Saved = transform.rotation;
					__state.Changed = true;
					transform.rotation = Quaternion.LookRotation(-val);
				}
			}
		}
		catch
		{
			__state = default(AimState);
		}
	}

	[HarmonyPostfix]
	private static void Postfix(AimState __state)
	{
		//IL_001d: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			if (__state.Changed && (Object)(object)__state.Renderer != (Object)null)
			{
				__state.Renderer.rotation = __state.Saved;
			}
		}
		catch
		{
		}
	}
}
internal static class Diag
{
	private static readonly ManualLogSource Log = Logger.CreateLogSource("MegaBonkMod.Diag");

	private static bool _installed;

	internal static void Install()
	{
		//IL_0049: Unknown result type (might be due to invalid IL or missing references)
		//IL_004f: Expected O, but got Unknown
		if (_installed)
		{
			return;
		}
		_installed = true;
		try
		{
			Application.SetStackTraceLogType((LogType)0, (StackTraceLogType)2);
			Application.SetStackTraceLogType((LogType)4, (StackTraceLogType)2);
			Application.logMessageReceived += DelegateSupport.ConvertDelegate<LogCallback>((Delegate)new Action<string, string, LogType>(OnUnityLog));
			Log.LogInfo((object)"[Diag] Unity log capture installed.");
		}
		catch (Exception ex)
		{
			bool flag = default(bool);
			BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(23, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[Diag] install failed: ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex);
			}
			Log.LogWarning(val);
		}
	}

	private static void OnUnityLog(string condition, string stackTrace, LogType type)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_0010: Unknown result type (might be due to invalid IL or missing references)
		//IL_0016: Expected O, but got Unknown
		//IL_0003: Unknown result type (might be due to invalid IL or missing references)
		//IL_0005: Invalid comparison between Unknown and I4
		//IL_0025: Unknown result type (might be due to invalid IL or missing references)
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_0009: Invalid comparison between Unknown and I4
		try
		{
			if ((int)type == 0 || (int)type == 4 || (int)type == 1)
			{
				bool flag = default(bool);
				BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(44, 3, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[UnityLog/");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<LogType>(type);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("] ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(condition);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("\n---- stack ----\n");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(stackTrace);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("---------------");
				}
				Log.LogError(val);
			}
		}
		catch
		{
		}
	}
}
internal static class EffectsOpacityToggle
{
	private const string SettingName = "particle_opacity";

	internal static void Toggle()
	{
		//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d0: Expected O, but got Unknown
		//IL_002e: 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_00a6: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			SaveManager instance = SaveManager.Instance;
			CFVisualsSettings val = (((Object)(object)instance != (Object)null && instance.config != null) ? instance.config.cfVisualsSettings : null);
			if (val == null)
			{
				Toast.Show("Effects opacity: settings not loaded", Color.yellow);
				return;
			}
			float num = (val.particle_opacity = ((val.particle_opacity > 0.5f) ? 0f : 1f));
			CurrentSettings.A_SettingUpdated?.Invoke("particle_opacity", (Object)null, (Object)null);
			instance.SaveConfig();
			Toast.Show("Effects opacity: " + ((num > 0.5f) ? "100%" : "0%"), (num > 0.5f) ? Color.green : Color.gray);
		}
		catch (Exception ex)
		{
			ManualLogSource log = Plugin.Log;
			bool flag = default(bool);
			BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(23, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[EffectsOpacityToggle] ");
				((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex.Message);
			}
			log.LogWarning(val2);
		}
	}
}
internal static class GameSpeedToggle
{
	private const float FastMult = 2f;

	internal static bool Fast { get; private set; }

	internal static void Toggle()
	{
		//IL_0060: 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)
		Fast = !Fast;
		if (Fast)
		{
			ModGui.CheatsUsed = true;
			if (Time.timeScale > 0f)
			{
				Time.timeScale = 2f;
			}
			Toast.Show("Game Speed: 2x", Color.cyan);
		}
		else
		{
			if (Time.timeScale > 0f)
			{
				Time.timeScale = 1f;
			}
			Toast.Show("Game Speed: 1x", Color.gray);
		}
	}

	internal static void Tick()
	{
		if (Fast && Time.timeScale > 0f && !Mathf.Approximately(Time.timeScale, 2f))
		{
			Time.timeScale = 2f;
		}
	}
}
internal class GuiWindowFrame
{
	public Vector2 Pivot;

	public float Scale = 2f;

	public float MinScale = 1f;

	public float MaxScale = 4f;

	public const float Grip = 18f;

	private bool _dragging;

	private bool _resizing;

	private Vector2 _dragOff;

	public bool Busy
	{
		get
		{
			if (!_dragging)
			{
				return _resizing;
			}
			return true;
		}
	}

	public GuiWindowFrame(Vector2 pivot)
	{
		//IL_0028: 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)
		Pivot = pivot;
	}

	public void HandleInput(float winW, float winH, float titleH)
	{
		//IL_0000: 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_0075: Unknown result type (might be due to invalid IL or missing references)
		//IL_007a: Unknown result type (might be due to invalid IL or missing references)
		//IL_007e: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
		//IL_0101: Unknown result type (might be due to invalid IL or missing references)
		//IL_0106: Unknown result type (might be due to invalid IL or missing references)
		//IL_010b: Unknown result type (might be due to invalid IL or missing references)
		float x = Input.mousePosition.x;
		float num = (float)Screen.height - Input.mousePosition.y;
		Vector2 val = default(Vector2);
		((Vector2)(ref val))..ctor(x, num);
		float num2 = winW * Scale;
		float num3 = winH * Scale;
		if (Input.GetMouseButtonDown(0))
		{
			Rect val2 = new Rect(Pivot.x + num2 - 18f, Pivot.y + num3 - 18f, 18f, 18f);
			if (((Rect)(ref val2)).Contains(val))
			{
				_resizing = true;
			}
			else
			{
				val2 = new Rect(Pivot.x, Pivot.y, num2, titleH * Scale);
				if (((Rect)(ref val2)).Contains(val))
				{
					_dragging = true;
					_dragOff = val - Pivot;
				}
			}
		}
		if (Input.GetMouseButtonUp(0))
		{
			_dragging = false;
			_resizing = false;
		}
		if (_dragging && Input.GetMouseButton(0))
		{
			Pivot = val - _dragOff;
		}
		if (_resizing && Input.GetMouseButton(0))
		{
			Scale = Mathf.Clamp((x - Pivot.x) / Mathf.Max(1f, winW), MinScale, MaxScale);
		}
	}

	public Matrix4x4 Begin()
	{
		//IL_0000: 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_0017: Unknown result type (might be due to invalid IL or missing references)
		Matrix4x4 matrix = GUI.matrix;
		GUIUtility.ScaleAroundPivot(new Vector2(Scale, Scale), Pivot);
		return matrix;
	}

	public void End(Matrix4x4 old)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		GUI.matrix = old;
	}

	public void DrawGrip(float winW, float winH)
	{
		//IL_0042: Unknown result type (might be due to invalid IL or missing references)
		float num = winW * Scale;
		float num2 = winH * Scale;
		GUI.Box(new Rect(Pivot.x + num - 18f, Pivot.y + num2 - 18f, 18f, 18f), "↘");
	}
}
internal static class Hotkeys
{
	internal static ConfigEntry<KeyCode> ModMenu;

	internal static ConfigEntry<KeyCode> DamageChart;

	internal static ConfigEntry<KeyCode> FastFall;

	internal static ConfigEntry<KeyCode> ChaosMenu;

	internal static ConfigEntry<KeyCode> MapScanner;

	internal static ConfigEntry<KeyCode> MapScanToggle;

	internal static ConfigEntry<KeyCode> SkipChest;

	internal static ConfigEntry<KeyCode> SmartTargeting;

	internal static ConfigEntry<KeyCode> AutoUpgrade;

	internal static ConfigEntry<KeyCode> AutoUpgradeLog;

	internal static ConfigEntry<KeyCode> EffectsOpacity;

	internal static ConfigEntry<KeyCode> GameSpeed;

	internal static bool Capturing = false;

	internal static int LastCaptureFrame = -1;

	internal static bool Suppressed
	{
		get
		{
			if (!Capturing)
			{
				return Time.frameCount == LastCaptureFrame;
			}
			return true;
		}
	}

	internal static void Init(ConfigFile cfg)
	{
		ModMenu = cfg.Bind<KeyCode>("Hotkeys", "ModMenu", (KeyCode)282, "Toggle the mod menu.");
		DamageChart = cfg.Bind<KeyCode>("Hotkeys", "DamageChart", (KeyCode)283, "Toggle the damage chart.");
		FastFall = cfg.Bind<KeyCode>("Hotkeys", "FastFall", (KeyCode)306, "Hold while airborne to fast-fall.");
		ChaosMenu = cfg.Bind<KeyCode>("Hotkeys", "ChaosMenu", (KeyCode)284, "Toggle the chaos stat-toggle menu.");
		MapScanner = cfg.Bind<KeyCode>("Hotkeys", "MapScanner", (KeyCode)285, "Toggle the map scanner window.");
		MapScanToggle = cfg.Bind<KeyCode>("Hotkeys", "MapScanToggle", (KeyCode)286, "Start / stop the map scan (auto-reroll until the map matches your criteria).");
		SkipChest = cfg.Bind<KeyCode>("Hotkeys", "SkipChest", (KeyCode)287, "Toggle Smart Skip Chest Animation (auto-skips when banishes are 0).");
		SmartTargeting = cfg.Bind<KeyCode>("Hotkeys", "PriorityTargeting", (KeyCode)288, "Toggle Priority Targeting (prioritise bosses/elites, then nearest killable).");
		AutoUpgrade = cfg.Bind<KeyCode>("Hotkeys", "AutoUpgrade", (KeyCode)289, "Toggle Scaling Auto-Upgrade (auto-pick level-up choices favouring scaling).");
		AutoUpgradeLog = cfg.Bind<KeyCode>("Hotkeys", "AutoUpgradeLog", (KeyCode)290, "Toggle the Scaling Auto-Upgrade log window (shows what it picked and over what).");
		EffectsOpacity = cfg.Bind<KeyCode>("Hotkeys", "EffectsOpacity", (KeyCode)292, "Toggle the game's Effects opacity (Settings > Effects) between 0% and 100%.");
		GameSpeed = cfg.Bind<KeyCode>("Hotkeys", "GameSpeed", (KeyCode)116, "Toggle game speed between 1x and 2x. Counts as a cheat (blocks leaderboard submission).");
	}

	internal static (string label, ConfigEntry<KeyCode> entry)[] All()
	{
		return new(string, ConfigEntry<KeyCode>)[12]
		{
			("Mod Menu", ModMenu),
			("Damage Chart", DamageChart),
			("Fast Fall", FastFall),
			("Chaos Menu", ChaosMenu),
			("Map Scanner", MapScanner),
			("Map Scan Start/Stop", MapScanToggle),
			("Smart Skip Chest", SkipChest),
			("Priority Targeting", SmartTargeting),
			("Scaling Auto-Upgrade", AutoUpgrade),
			("Auto-Upgrade Log", AutoUpgradeLog),
			("Effects Opacity 0/100", EffectsOpacity),
			("Game Speed 1x/2x", GameSpeed)
		};
	}

	internal unsafe static string Pretty(KeyCode k)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_0003: Unknown result type (might be due to invalid IL or missing references)
		//IL_0009: Unknown result type (might be due to invalid IL or missing references)
		//IL_0027: Expected I4, but got Unknown
		if ((int)k != 0)
		{
			return (k - 303) switch
			{
				3 => "Left Ctrl", 
				2 => "Right Ctrl", 
				1 => "Left Shift", 
				0 => "Right Shift", 
				5 => "Left Alt", 
				4 => "Right Alt", 
				_ => ((object)(*(KeyCode*)(&k))/*cast due to .constrained prefix*/).ToString(), 
			};
		}
		return "None";
	}
}
internal static class IconRecolor
{
	internal static readonly Dictionary<EItem, EItemRarity> Original = new Dictionary<EItem, EItemRarity>();

	private static readonly Dictionary<EItem, Texture2D> _cache = new Dictionary<EItem, Texture2D>();

	private const int Tol = 95;

	internal static void RecolorSource(ItemData id)
	{
		//IL_0098: 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_00b0: Expected O, but got Unknown
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0010: 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_00c2: 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_0027: 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_0029: 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_0063: Unknown result type (might be due to invalid IL or missing references)
		//IL_0064: Unknown result type (might be due to invalid IL or missing references)
		//IL_0075: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)id == (Object)null)
		{
			return;
		}
		EItem eItem = id.eItem;
		if (!Original.TryGetValue(eItem, out var value))
		{
			return;
		}
		EItemRarity rarity = id.rarity;
		if (value == rarity)
		{
			return;
		}
		if (_cache.TryGetValue(eItem, out var value2))
		{
			if ((Object)(object)value2 != (Object)null)
			{
				id.icon = (Texture)(object)value2;
			}
			return;
		}
		Texture icon = id.icon;
		if ((Object)(object)icon == (Object)null)
		{
			return;
		}
		try
		{
			Texture2D val = Build(icon, MyColorUtility.GetItemRarityColor(rarity));
			_cache[eItem] = val;
			if ((Object)(object)val != (Object)null)
			{
				id.icon = (Texture)(object)val;
			}
		}
		catch (Exception ex)
		{
			_cache[eItem] = null;
			ManualLogSource log = Plugin.Log;
			bool flag = default(bool);
			BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(16, 2, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[IconRecolor] ");
				((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<EItem>(eItem);
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(": ");
				((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex.Message);
			}
			log.LogWarning(val2);
		}
	}

	private static Texture2D Build(Texture src, Color newC)
	{
		//IL_004e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0054: Expected O, but got Unknown
		//IL_006d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0329: Unknown result type (might be due to invalid IL or missing references)
		//IL_0338: Unknown result type (might be due to invalid IL or missing references)
		//IL_0347: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0383: 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_038a: 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_026b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0272: 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_028a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0291: Unknown result type (might be due to invalid IL or missing references)
		//IL_0394: Unknown result type (might be due to invalid IL or missing references)
		//IL_039e: Unknown result type (might be due to invalid IL or missing references)
		//IL_03aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ac: 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_02c5: Unknown result type (might be due to invalid IL or missing references)
		//IL_03e3: Unknown result type (might be due to invalid IL or missing references)
		//IL_03ea: Unknown result type (might be due to invalid IL or missing references)
		int w = src.width;
		int h = src.height;
		RenderTexture temporary = RenderTexture.GetTemporary(w, h, 0, (RenderTextureFormat)0);
		RenderTexture active = RenderTexture.active;
		Graphics.Blit(src, temporary);
		RenderTexture.active = temporary;
		Texture2D val = new Texture2D(w, h, (TextureFormat)4, false);
		val.ReadPixels(new Rect(0f, 0f, (float)w, (float)h), 0, 0);
		val.Apply();
		RenderTexture.active = active;
		RenderTexture.ReleaseTemporary(temporary);
		Il2CppStructArray<Color32> px = val.GetPixels32();
		bool[] outside = new bool[w * h];
		Stack<int> stack = new Stack<int>();
		for (int i = 0; i < w; i++)
		{
			Seed(i);
			Seed((h - 1) * w + i);
		}
		for (int j = 0; j < h; j++)
		{
			Seed(j * w);
			Seed(j * w + (w - 1));
		}
		while (stack.Count > 0)
		{
			int num = stack.Pop();
			int num2 = num % w;
			int num3 = num / w;
			if (num2 > 0)
			{
				Seed(num - 1);
			}
			if (num2 < w - 1)
			{
				Seed(num + 1);
			}
			if (num3 > 0)
			{
				Seed(num - w);
			}
			if (num3 < h - 1)
			{
				Seed(num + w);
			}
		}
		long num4 = 0L;
		long num5 = 0L;
		long num6 = 0L;
		int num7 = 0;
		for (int k = 0; k < h; k++)
		{
			for (int l = 0; l < w; l++)
			{
				int num8 = k * w + l;
				Color32 val2 = ((Il2CppArrayBase<Color32>)(object)px)[num8];
				if (val2.a >= 32 && (l == 0 || k == 0 || l == w - 1 || k == h - 1 || outside[num8 - 1] || outside[num8 + 1] || outside[num8 - w] || outside[num8 + w]))
				{
					int num9 = Mathf.Max((int)val2.r, Mathf.Max((int)val2.g, (int)val2.b));
					int num10 = Mathf.Min((int)val2.r, Mathf.Min((int)val2.g, (int)val2.b));
					if (num9 - num10 >= 40)
					{
						num4 += val2.r;
						num5 += val2.g;
						num6 += val2.b;
						num7++;
					}
				}
			}
		}
		((Texture)val).filterMode = (FilterMode)0;
		if (num7 == 0)
		{
			val.Apply();
			return val;
		}
		byte b = (byte)(num4 / num7);
		byte b2 = (byte)(num5 / num7);
		byte b3 = (byte)(num6 / num7);
		byte b4 = (byte)(newC.r * 255f);
		byte b5 = (byte)(newC.g * 255f);
		byte b6 = (byte)(newC.b * 255f);
		int num11 = 9025;
		for (int m = 0; m < h; m++)
		{
			for (int n = 0; n < w; n++)
			{
				int num12 = m * w + n;
				Color32 val3 = ((Il2CppArrayBase<Color32>)(object)px)[num12];
				if (val3.a >= 8)
				{
					int num13 = val3.r - b;
					int num14 = val3.g - b2;
					int num15 = val3.b - b3;
					if (num13 * num13 + num14 * num14 + num15 * num15 <= num11 && NearOutside(n, m))
					{
						((Il2CppArrayBase<Color32>)(object)px)[num12] = new Color32(b4, b5, b6, val3.a);
					}
				}
			}
		}
		val.SetPixels32(px);
		val.Apply();
		return val;
		bool NearOutside(int x, int y)
		{
			for (int num16 = -2; num16 <= 2; num16++)
			{
				for (int num17 = -2; num17 <= 2; num17++)
				{
					int num18 = x + num17;
					int num19 = y + num16;
					if (num18 < 0 || num19 < 0 || num18 >= w || num19 >= h)
					{
						return true;
					}
					if (outside[num19 * w + num18])
					{
						return true;
					}
				}
			}
			return false;
		}
		void Seed(int idx)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			if (((Il2CppArrayBase<Color32>)(object)px)[idx].a < 32 && !outside[idx])
			{
				outside[idx] = true;
				stack.Push(idx);
			}
		}
	}
}
internal static class MapScanner
{
	private sealed class Row
	{
		public string Key;

		public string Label;

		public string[] Match;

		public EItemRarity? MwTier;

		public bool Combined;

		public bool MwAny;

		public bool Exact;
	}

	private static readonly Row[] Rows = new Row[10]
	{
		new Row
		{
			Key = "bosscurse",
			Label = "Boss Curses (exact)",
			Match = new string[1] { "curse" },
			Exact = true
		},
		new Row
		{
			Key = "magnet",
			Label = "Magnet Shrines",
			Match = new string[1] { "magnet" }
		},
		new Row
		{
			Key = "mw_any",
			Label = "Microwave: Any",
			MwAny = true
		},
		new Row
		{
			Key = "mw_common",
			Label = "Microwave: Common",
			MwTier = (EItemRarity)0
		},
		new Row
		{
			Key = "mw_rare",
			Label = "Microwave: Rare",
			MwTier = (EItemRarity)1
		},
		new Row
		{
			Key = "mw_epic",
			Label = "Microwave: Epic",
			MwTier = (EItemRarity)2
		},
		new Row
		{
			Key = "mw_legend",
			Label = "Microwave: Legendary",
			MwTier = (EItemRarity)3
		},
		new Row
		{
			Key = "moaishady",
			Label = "Moai + Shady (any)",
			Combined = true
		},
		new Row
		{
			Key = "moais",
			Label = "Moais",
			Match = new string[1] { "moai" }
		},
		new Row
		{
			Key = "shady",
			Label = "Shady Guy",
			Match = new string[1] { "shady" }
		}
	};

	private static ConfigEntry<int>[] _desired;

	private static ConfigFile _cfg;

	internal static bool Visible;

	internal static bool Active;

	internal static int Attempts;

	internal static string Status = "Idle";

	private static Dictionary<string, int> _cur = new Dictionary<string, int>();

	private static float _nextLiveRefresh;

	private static int _seedAtRestart;

	private static bool _awaitingNewMap;

	private const float WinW = 320f;

	private const float PadX = 12f;

	private const float LineH = 24f;

	private static readonly GuiWindowFrame _frame = new GuiWindowFrame(new Vector2(360f, 80f));

	private static float _lastWinH;

	private static float WinHeight()
	{
		return 56f + (float)Rows.Length * 26f + 24f + 24f + 8f;
	}

	internal static void Init(ConfigFile cfg)
	{
		_cfg = cfg;
		_desired = new ConfigEntry<int>[Rows.Length];
		for (int i = 0; i < Rows.Length; i++)
		{
			_desired[i] = cfg.Bind<int>("MapScanner", Rows[i].Key, 0, "Desired '" + Rows[i].Label + "' the scanner waits for (0 = ignore).");
		}
	}

	internal static void Toggle()
	{
		Visible = !Visible;
	}

	private static Dictionary<string, int> ReadDict()
	{
		//IL_005b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0062: Expected O, but got Unknown
		Dictionary<string, int> dictionary = new Dictionary<string, int>();
		try
		{
			Dictionary<string, InteractableStatusContainer> interactablesByName = InteractablesStatus.interactablesByName;
			if (interactablesByName == null)
			{
				return dictionary;
			}
			Enumerator<string, InteractableStatusContainer> enumerator = interactablesByName.GetEnumerator();
			while (enumerator.MoveNext())
			{
				KeyValuePair<string, InteractableStatusContainer> current = enumerator.Current;
				InteractableStatusContainer value = current.Value;
				if (value != null)
				{
					dictionary[current.Key] = value.numTotal;
				}
			}
		}
		catch (Exception ex)
		{
			ManualLogSource log = Plugin.Log;
			bool flag = default(bool);
			BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(19, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[MapScanner] dict: ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
			}
			log.LogWarning(val);
		}
		return dictionary;
	}

	private static int DictCount(Dictionary<string, int> dict, string[] match)
	{
		int num = 0;
		foreach (KeyValuePair<string, int> item in dict)
		{
			string text = item.Key.ToLowerInvariant();
			foreach (string value in match)
			{
				if (text.Contains(value))
				{
					num += item.Value;
					break;
				}
			}
		}
		return num;
	}

	private static int[] CountMicrowaveTiers()
	{
		//IL_006c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0073: Expected O, but got Unknown
		//IL_002a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0031: Expected I4, but got Unknown
		int[] array = new int[6];
		try
		{
			Il2CppArrayBase<InteractableMicrowave> val = Object.FindObjectsOfType<InteractableMicrowave>();
			if (val != null)
			{
				foreach (InteractableMicrowave item in val)
				{
					if (!((Object)(object)item == (Object)null))
					{
						int num = (int)item.rarity;
						if (num >= 0 && num < array.Length)
						{
							array[num]++;
						}
					}
				}
			}
		}
		catch (Exception ex)
		{
			ManualLogSource log = Plugin.Log;
			bool flag = default(bool);
			BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(17, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[MapScanner] mw: ");
				((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex.Message);
			}
			log.LogWarning(val2);
		}
		return array;
	}

	private static Dictionary<string, int> ComputeCounts()
	{
		//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
		Dictionary<string, int> dict = ReadDict();
		int[] array = CountMicrowaveTiers();
		int num = DictCount(dict, new string[1] { "moai" });
		int num2 = DictCount(dict, new string[1] { "shady" });
		int num3 = 0;
		for (int i = 0; i < array.Length; i++)
		{
			num3 += array[i];
		}
		Dictionary<string, int> dictionary = new Dictionary<string, int>();
		Row[] rows = Rows;
		foreach (Row row in rows)
		{
			int value = ((!row.Combined) ? ((!row.MwAny) ? ((!row.MwTier.HasValue) ? DictCount(dict, row.Match) : array[row.MwTier.Value]) : num3) : (num + num2));
			dictionary[row.Key] = value;
		}
		return dictionary;
	}

	private static bool AnyDesired()
	{
		for (int i = 0; i < _desired.Length; i++)
		{
			if (_desired[i].Value > 0)
			{
				return true;
			}
		}
		return false;
	}

	private static bool Matches(Dictionary<string, int> cur)
	{
		for (int i = 0; i < Rows.Length; i++)
		{
			int value = _desired[i].Value;
			if (value <= 0)
			{
				continue;
			}
			cur.TryGetValue(Rows[i].Key, out var value2);
			if (Rows[i].Exact)
			{
				if (value2 != value)
				{
					return false;
				}
			}
			else if (value2 < value)
			{
				return false;
			}
		}
		return true;
	}

	private static bool HasAnyCount(Dictionary<string, int> cur)
	{
		foreach (int value in cur.Values)
		{
			if (value > 0)
			{
				return true;
			}
		}
		return false;
	}

	private static void PauseGame()
	{
		//IL_0059: Unknown result type (might be due to invalid IL or missing references)
		//IL_005f: Expected O, but got Unknown
		try
		{
			PauseUi val = null;
			PauseHandler val2 = Object.FindObjectOfType<PauseHandler>();
			if ((Object)(object)val2 != (Object)null)
			{
				val = val2.pauseUi;
			}
			if ((Object)(object)val == (Object)null)
			{
				val = Object.FindObjectOfType<PauseUi>();
			}
			if (!((Object)(object)val == (Object)null) && !val.IsPaused() && val.CanPause())
			{
				val.Pause();
			}
		}
		catch (Exception ex)
		{
			ManualLogSource log = Plugin.Log;
			bool flag = default(bool);
			BepInExWarningLogInterpolatedStringHandler val3 = new BepInExWarningLogInterpolatedStringHandler(20, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("[MapScanner] pause: ");
				((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(ex.Message);
			}
			log.LogWarning(val3);
		}
	}

	internal static void StartScan()
	{
		if (MapController.IsMainMenu())
		{
			Status = "Start a run first.";
			return;
		}
		if (!AnyDesired())
		{
			Status = "Set at least one count > 0.";
			return;
		}
		Active = true;
		Attempts = 0;
		_awaitingNewMap = false;
		Status = "Scanning…";
	}

	internal static void StopScan(string msg = "Stopped")
	{
		Active = false;
		_awaitingNewMap = false;
		Status = msg;
	}

	internal static void ToggleScan()
	{
		if (Active)
		{
			StopScan("Cancelled.");
		}
		else
		{
			StartScan();
		}
	}

	internal static void Tick()
	{
		//IL_0129: Unknown result type (might be due to invalid IL or missing references)
		//IL_012f: Expected O, but got Unknown
		if (!Active)
		{
			return;
		}
		try
		{
			if (MapController.IsMainMenu())
			{
				StopScan("Left run.");
			}
			else
			{
				if (MapGenerationController.isGenerating)
				{
					return;
				}
				if (_awaitingNewMap)
				{
					if (MapGenerationController.mapSeed == _seedAtRestart)
					{
						return;
					}
					_awaitingNewMap = false;
				}
				Dictionary<string, int> cur = ComputeCounts();
				if (HasAnyCount(cur))
				{
					_cur = cur;
					if (Matches(cur))
					{
						StopScan($"Match found after {Attempts} reroll(s).");
						PauseGame();
					}
					else
					{
						Attempts++;
						_seedAtRestart = MapGenerationController.mapSeed;
						_awaitingNewMap = true;
						Status = $"Reroll #{Attempts}…";
						MapController.RestartRun();
					}
				}
			}
		}
		catch (Exception ex)
		{
			StopScan("Error: " + ex.Message);
			ManualLogSource log = Plugin.Log;
			bool flag = default(bool);
			BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(13, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[MapScanner] ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex);
			}
			log.LogError(val);
		}
	}

	internal static void HandleInput()
	{
		if (Visible)
		{
			_frame.HandleInput(320f, (_lastWinH > 0f) ? _lastWinH : WinHeight(), 28f);
		}
	}

	internal static void Draw()
	{
		//IL_005a: 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_0087: Unknown result type (might be due to invalid IL or missing references)
		//IL_0099: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
		//IL_0280: Unknown result type (might be due to invalid IL or missing references)
		//IL_0184: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b4: 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_0317: 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_01fe: Unknown result type (might be due to invalid IL or missing references)
		//IL_0230: Unknown result type (might be due to invalid IL or missing references)
		if (!Visible)
		{
			return;
		}
		if (!Active && !MapController.IsMainMenu() && Time.unscaledTime >= _nextLiveRefresh)
		{
			_nextLiveRefresh = Time.unscaledTime + 0.5f;
			Dictionary<string, int> cur = ComputeCounts();
			if (HasAnyCount(cur))
			{
				_cur = cur;
			}
		}
		float num = (_lastWinH = WinHeight());
		Matrix4x4 old = _frame.Begin();
		float x = _frame.Pivot.x;
		float y = _frame.Pivot.y;
		UiTheme.Backdrop(new Rect(x, y, 320f, num));
		GUI.Box(new Rect(x, y, 320f, num), "Map Scanner");
		float num2 = 296f;
		float num3 = x + 12f;
		float num4 = y + 24f + 2f;
		GUI.Label(new Rect(num3, num4, num2, 24f), "Want at least (0 = ignore):");
		num4 += 24f;
		for (int i = 0; i < Rows.Length; i++)
		{
			_cur.TryGetValue(Rows[i].Key, out var value);
			string text = ((Active || _cur.Count > 0) ? $"{Rows[i].Label}  ({value})" : Rows[i].Label);
			GUI.Label(new Rect(num3, num4, num2 - 92f, 24f), text);
			GUI.enabled = !Active;
			float num5 = num3 + num2 - 92f;
			if (GUI.Button(new Rect(num5, num4, 26f, 22f), "-") && _desired[i].Value > 0)
			{
				SetDesired(i, _desired[i].Value - 1);
			}
			GUI.Label(new Rect(num5 + 34f, num4, 26f, 24f), _desired[i].Value.ToString());
			if (GUI.Button(new Rect(num5 + 64f, num4, 26f, 22f), "+"))
			{
				SetDesired(i, _desired[i].Value + 1);
			}
			GUI.enabled = true;
			num4 += 26f;
		}
		string text2 = Hotkeys.Pretty(Hotkeys.MapScanToggle.Value);
		string text3 = (Active ? $"SCANNING — reroll #{Attempts}  ({text2} to stop)" : (text2 + " to start scan"));
		GUI.Label(new Rect(num3, num4, num2, 24f), text3);
		num4 += 24f;
		GUI.Label(new Rect(num3, num4, num2, 24f), "Status: " + Status);
		_frame.End(old);
		_frame.DrawGrip(320f, num);
	}

	private static void SetDesired(int idx, int value)
	{
		if (value < 0)
		{
			value = 0;
		}
		if (_desired[idx].Value == value)
		{
			return;
		}
		_desired[idx].Value = value;
		try
		{
			ConfigFile cfg = _cfg;
			if (cfg != null)
			{
				cfg.Save();
			}
		}
		catch
		{
		}
	}
}
public class ModGui : MonoBehaviour
{
	internal static readonly ConcurrentQueue<Action> MainThread = new ConcurrentQueue<Action>();

	private bool _visible;

	private bool _authenticated;

	private bool _promptVisible;

	private string _passwordInput = "";

	private const string Password = "kittens";

	internal static bool ChartDisabled;

	internal static bool NeedVersionPatch;

	internal static bool UpdateAvailable;

	internal static List<string> UnauthorizedMods = new List<string>();

	internal static bool CheatsUsed;

	internal static bool ShowHitboxes = false;

	internal static float BombusAnnounceTime = -999f;

	private Material _hitboxMat;

	private Collider[] _cachedColliders;

	private int _colliderCacheFrame = -999;

	internal static float HitboxMaxDist = 100f;

	private GameObject _statsParent;

	private GameObject _damageWindow;

	private GameObject _statsWindowObj;

	private GameObject _questsWindow;

	private ScrollRect _damageScroll;

	private bool _chartMutated;

	private bool _addedCanvas;

	private Vector2 _origAnchorMin;

	private Vector2 _origAnchorMax;

	private Vector2 _origPivot;

	private Vector2 _origAnchoredPos;

	private bool _origRtCaptured;

	private readonly GuiWindowFrame _frame = new GuiWindowFrame(new Vector2(20f, 20f));

	private float _lastWinH = 480f;

	private bool _powerupOpen = true;

	internal static bool GodMode = false;

	internal static bool FlyMode = false;

	internal static float FlySpeed = 20f;

	internal static bool InstaKill = false;

	internal static bool FreezeEnemies = false;

	private const float FastFallSpeed = 22f;

	private const float FastFallAccel = 100f;

	private const float WinW = 440f;

	private const float PadX = 8f;

	private const float LineH = 22f;

	public ModGui(IntPtr ptr)
		: base(ptr)
	{
	}//IL_0021: Unknown result type (might be due to invalid IL or missing references)


	private unsafe void Update()
	{
		//IL_02a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e9: 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_02e1: 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_02fe: Unknown result type (might be due to invalid IL or missing references)
		//IL_04d0: Unknown result type (might be due to invalid IL or missing references)
		//IL_04d5: Unknown result type (might be due to invalid IL or missing references)
		//IL_031b: Unknown result type (might be due to invalid IL or missing references)
		//IL_04e3: Unknown result type (might be due to invalid IL or missing references)
		//IL_04ea: Unknown result type (might be due to invalid IL or missing references)
		//IL_04f1: Unknown result type (might be due to invalid IL or missing references)
		//IL_04f8: Unknown result type (might be due to invalid IL or missing references)
		//IL_04fd: Unknown result type (might be due to invalid IL or missing references)
		//IL_0502: 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_007e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0338: Unknown result type (might be due to invalid IL or missing references)
		//IL_0355: Unknown result type (might be due to invalid IL or missing references)
		//IL_0533: Unknown result type (might be due to invalid IL or missing references)
		//IL_053d: Unknown result type (might be due to invalid IL or missing references)
		//IL_054e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0553: 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_0372: Unknown result type (might be due to invalid IL or missing references)
		//IL_038f: Unknown result type (might be due to invalid IL or missing references)
		//IL_03ee: Unknown result type (might be due to invalid IL or missing references)
		//IL_0412: Unknown result type (might be due to invalid IL or missing references)
		//IL_0417: Unknown result type (might be due to invalid IL or missing references)
		//IL_0419: Unknown result type (might be due to invalid IL or missing references)
		//IL_0429: Unknown result type (might be due to invalid IL or missing references)
		//IL_044c: Unknown result type (might be due to invalid IL or missing references)
		Action result;
		while (MainThread.TryDequeue(out result))
		{
			try
			{
				result();
			}
			catch
			{
			}
		}
		NativeSettings.TickCapture();
		NativeSettings.PollKeycapCapture();
		if (NeedVersionPatch)
		{
			string version = Application.version;
			foreach (TextMeshProUGUI item in Object.FindObjectsOfType<TextMeshProUGUI>())
			{
				if (((TMP_Text)item).text != null && ((TMP_Text)item).text.Contains(version))
				{
					BepInPlugin val = (BepInPlugin)Attribute.GetCustomAttribute(typeof(Plugin), typeof(BepInPlugin));
					string text = (((int)val == 0) ? null : ((object)val.Version)?.ToString()) ?? "?";
					((TMP_Text)item).text = "Mod v" + text + "  |  " + ((TMP_Text)item).text;
					NeedVersionPatch = false;
					break;
				}
			}
		}
		if (!Hotkeys.Suppressed && Input.GetKeyDown(Hotkeys.ModMenu.Value))
		{
			if (_authenticated)
			{
				_visible = !_visible;
			}
			else
			{
				_promptVisible = !_promptVisible;
				_passwordInput = "";
			}
		}
		if (_promptVisible && !_authenticated)
		{
			string inputString = Input.inputString;
			for (int i = 0; i < inputString.Length; i++)
			{
				char c = inputString[i];
				switch (c)
				{
				case '\b':
					if (_passwordInput.Length > 0)
					{
						_passwordInput = _passwordInput.Substring(0, _passwordInput.Length - 1);
					}
					break;
				case '\n':
				case '\r':
					if (_passwordInput == "kittens")
					{
						_authenticated = true;
						_promptVisible = false;
						_visible = true;
					}
					else
					{
						_passwordInput = "";
					}
					break;
				default:
					_passwordInput += c;
					break;
				}
			}
		}
		if (!Hotkeys.Suppressed && Input.GetKeyDown(Hotkeys.DamageChart.Value) && !ChartDisabled)
		{
			ToggleDamageChart();
		}
		if (ChartDisabled && _chartMutated)
		{
			RestoreForDeath();
		}
		if ((Object)(object)_damageScroll != (Object)null && (Object)(object)_statsParent != (Object)null && _statsParent.activeSelf)
		{
			float y = Input.mouseScrollDelta.y;
			if (y != 0f)
			{
				try
				{
					_damageScroll.verticalNormalizedPosition = Mathf.Clamp01(_damageScroll.verticalNormalizedPosition + y * 0.12f);
				}
				catch
				{
				}
			}
		}
		if (!Hotkeys.Suppressed && Input.GetKeyDown(Hotkeys.ChaosMenu.Value))
		{
			ChaosMenu.Toggle();
		}
		if (!Hotkeys.Suppressed && Input.GetKeyDown(Hotkeys.MapScanner.Value))
		{
			MapScanner.Toggle();
		}
		if (!Hotkeys.Suppressed && Input.GetKeyDown(Hotkeys.MapScanToggle.Value))
		{
			MapScanner.ToggleScan();
		}
		if (!Hotkeys.Suppressed && Input.GetKeyDown(Hotkeys.EffectsOpacity.Value))
		{
			EffectsOpacityToggle.Toggle();
		}
		if (!Hotkeys.Suppressed && Input.GetKeyDown(Hotkeys.GameSpeed.Value))
		{
			GameSpeedToggle.Toggle();
		}
		if (!Hotkeys.Suppressed && Input.GetKeyDown(Hotkeys.SkipChest.Value))
		{
			SkipChestSync.Toggle();
		}
		if (!Hotkeys.Suppressed && Input.GetKeyDown(Hotkeys.SmartTargeting.Value))
		{
			SmartTargeting.Toggle();
		}
		if (!Hotkeys.Suppressed && Input.GetKeyDown(Hotkeys.AutoUpgrade.Value))
		{
			AutoLevelPick.Toggle();
		}
		if (!Hotkeys.Suppressed && Input.GetKeyDown(Hotkeys.AutoUpgradeLog.Value))
		{
			AutoLevelPick.ToggleWindow();
		}
		MapScanner.Tick();
		SkipChestSync.Tick();
		GameSpeedToggle.Tick();
		try
		{
			PlayerMovement instance = PlayerMovement.Instance;
			if ((Object)(object)instance != (Object)null && !FlyMode && *(byte*)(void*)(((Il2CppObjectBase)instance).Pointer + 223) == 0 && Input.GetKey(Hotkeys.FastFall.Value))
			{
				Rigidbody component = ((Component)instance).GetComponent<Rigidbody>();
				if ((Object)(object)component != (Object)null)
				{
					Vector3 velocity = component.velocity;
					if (velocity.y > -22f)
					{
						velocity.y = Mathf.MoveTowards(velocity.y, -22f, 100f * Time.deltaTime);
						component.velocity = velocity;
					}
				}
			}
		}
		catch
		{
		}
		try
		{
			PlayerMovement instance2 = PlayerMovement.Instance;
			if ((Object)(object)instance2 != (Object)null && FlyMode)
			{
				Rigidbody component2 = ((Component)instance2).GetComponent<Rigidbody>();
				if ((Object)(object)component2 != (Object)null)
				{
					component2.useGravity = false;
					float num = *(float*)(void*)(((Il2CppObjectBase)instance2).Pointer + 280);
					float num2 = *(float*)(void*)(((Il2CppObjectBase)instance2).Pointer + 284);
					Transform orientation = instance2.orientation;
					Vector3 val2 = Vector3.zero;
					if ((Object)(object)orientation != (Object)null)
					{
						val2 = orientation.forward * num2 + orientation.right * num;
					}
					float num3 = 0f;
					if (Input.GetKey((KeyCode)32))
					{
						num3 = FlySpeed;
					}
					if (Input.GetKey((KeyCode)306))
					{
						num3 = 0f - FlySpeed;
					}
					component2.velocity = ((Vector3)(ref val2)).normalized * FlySpeed + new Vector3(0f, num3, 0f);
				}
			}
			else if ((Object)(object)instance2 != (Object)null && !FlyMode)
			{
				Rigidbody component3 = ((Component)instance2).GetComponent<Rigidbody>();
				if ((Object)(object)component3 != (Object)null && !component3.useGravity)
				{
					component3.useGravity = true;
				}
			}
		}
		catch
		{
		}
		if (_visible)
		{
			_frame.HandleInput(440f, _lastWinH, 26f);
		}
		if (ChaosMenu.Visible)
		{
			ChaosMenu.HandleInput();
		}
		if (MapScanner.Visible)
		{
			MapScanner.HandleInput();
		}
		if (AutoLevelPick.Visible)
		{
			AutoLevelPick.HandleInput();
		}
	}

	internal void ResetChartCache()
	{
		_statsParent = null;
		_chartMutated = false;
		_addedCanvas = false;
		_origRtCaptured = false;
		_damageScroll = null;
	}

	internal void RestoreForDeath()
	{
		//IL_006e: Unknown result type (might be due to invalid IL or missing references)
		//IL_007a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0086: 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)
		try
		{
			if (!_chartMutated || (Object)(object)_statsParent == (Object)null)
			{
				return;
			}
			if ((Object)(object)_statsWindowObj != (Object)null)
			{
				_statsWindowObj.SetActive(true);
			}
			if ((Object)(object)_questsWindow != (Object)null)
			{
				_questsWindow.SetActive(true);
			}
			RectTransform component = _statsParent.GetComponent<RectTransform>();
			if ((Object)(object)component != (Object)null && _origRtCaptured)
			{
				component.anchorMin = _origAnchorMin;
				component.anchorMax = _origAnchorMax;
				component.pivot = _origPivot;
				component.anchoredPosition = _origAnchoredPos;
			}
			Canvas component2 = _statsParent.GetComponent<Canvas>();
			if ((Object)(object)component2 != (Object)null)
			{
				component2.overrideSorting = false;
				if (_addedCanvas)
				{
					Object.Destroy((Object)(object)component2);
				}
			}
			GameOverDamageSourcesUi componentInChildren = _statsParent.GetComponentInChildren<GameOverDamageSourcesUi>(true);
			if ((Object)(object)componentInChildren != (Object)null)
			{
				componentInChildren.Start();
			}
			_damageScroll = null;
			_chartMutated = false;
			_addedCanvas = false;
			_origRtCaptured = false;
		}
		catch
		{
		}
	}

	private void ToggleDamageChart()
	{
		//IL_02ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_02db: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e8: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f5: 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_01ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0156: Unknown result type (might be due to invalid IL or missing references)
		//IL_015b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0162: Unknown result type (might be due to invalid IL or missing references)
		//IL_0167: Unknown result type (might be due to invalid IL or missing references)
		//IL_016e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0173: Unknown result type (might be due to invalid IL or missing references)
		//IL_017a: Unknown result type (might be due to invalid IL or missing references)
		//IL_017f: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			if ((Object)(object)_statsParent == (Object)null)
			{
				_statsParent = GameObject.Find("GameUI/GameUI/DeathScreen/StatsWindows");
				if ((Object)(object)_statsParent != (Object)null)
				{
					Transform obj = _statsParent.transform.Find("W_Damage");
					_damageWindow = ((obj != null) ? ((Component)obj).gameObject : null);
					Transform obj2 = _statsParent.transform.Find("W_Stats");
					_statsWindowObj = ((obj2 != null) ? ((Component)obj2).gameObject : null);
					Transform obj3 = _statsParent.transform.Find("W_Quests");
					_questsWindow = ((obj3 != null) ? ((Component)obj3).gameObject : null);
				}
			}
			if ((Object)(object)_statsParent == (Object)null)
			{
				return;
			}
			bool flag = !_statsParent.activeSelf;
			_statsParent.SetActive(flag);
			if ((Object)(object)_statsWindowObj != (Object)null)
			{
				_statsWindowObj.SetActive(!flag);
			}
			if ((Object)(object)_questsWindow != (Object)null)
			{
				_questsWindow.SetActive(!flag);
			}
			if (flag)
			{
				GameOverDamageSourcesUi componentInChildren = _statsParent.GetComponentInChildren<GameOverDamageSourcesUi>();
				if ((Object)(object)componentInChildren != (Object)null)
				{
					componentInChildren.Start();
				}
				_chartMutated = true;
				RectTransform component = _statsParent.GetComponent<RectTransform>();
				if ((Object)(object)component != (Object)null)
				{
					if (!_origRtCaptured)
					{
						_origAnchorMin = component.anchorMin;
						_origAnchorMax = component.anchorMax;
						_origPivot = component.pivot;
						_origAnchoredPos = component.anchoredPosition;
						_origRtCaptured = true;
					}
					component.anchorMin = new Vector2(0f, 0.5f);
					component.anchorMax = new Vector2(0f, 0.5f);
					component.pivot = new Vector2(0f, 0.5f);
					component.anchoredPosition = new Vector2(20f, 0f);
				}
				Canvas val = _statsParent.GetComponent<Canvas>();
				if ((Object)(object)val == (Object)null)
				{
					val = _statsParent.AddComponent<Canvas>();
					_addedCanvas = true;
				}
				val.overrideSorting = true;
				val.sortingOrder = 30000;
				_damageScroll = null;
				Transform val2 = _statsParent.transform.Find("W_Damage/WindowLayers/Content/ScrollRect");
				if (!((Object)(object)val2 != (Object)null))
				{
					return;
				}
				ScrollRect component2 = ((Component)val2).GetComponent<ScrollRect>();
				if ((Object)(object)component2 != (Object)null)
				{
					component2.vertical = true;
					component2.horizontal = false;
					component2.movementType = (MovementType)2;
					RectTransform content = component2.content;
					if ((Object)(object)content != (Object)null)
					{
						LayoutRebuilder.ForceRebuildLayoutImmediate(content);
						component2.verticalNormalizedPosition = 1f;
					}
					_damageScroll = component2;
				}
				return;
			}
			_damageScroll = null;
			RectTransform component3 = _statsParent.GetComponent<RectTransform>();
			if ((Object)(object)component3 != (Object)null && _origRtCaptured)
			{
				component3.anchorMin = _origAnchorMin;
				component3.anchorMax = _origAnchorMax;
				component3.pivot = _origPivot;
				component3.anchoredPosition = _origAnchoredPos;
			}
			Canvas component4 = _statsParent.GetComponent<Canvas>();
			if ((Object)(object)component4 != (Object)null)
			{
				component4.overrideSorting = false;
				if (_addedCanvas)
				{
					Object.Destroy((Object)(object)component4);
				}
			}
			_addedCanvas = false;
			_chartMutated = false;
			_origRtCaptured = false;
		}
		catch
		{
		}
	}

	private void OnGUI()
	{
		//IL_0046: Unknown result type (might be due to invalid IL or missing references)
		//IL_0070: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
		//IL_0263: Unknown result type (might be due to invalid IL or missing references)
		//IL_0268: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e2: 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_0244: Unknown result type (might be due to invalid IL or missing references)
		//IL_015e: 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_0332: Unknown result type (might be due to invalid IL or missing references)
		//IL_0344: Unknown result type (might be due to invalid IL or missing references)
		//IL_0383: Unknown result type (might be due to invalid IL or missing references)
		//IL_0471: Unknown result type (might be due to invalid IL or missing references)
		//IL_03f1: Unknown result type (might be due to invalid IL or missing references)
		//IL_03e3: Unknown result type (might be due to invalid IL or missing references)
		//IL_04ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_03f6: Unknown result type (might be due to invalid IL or missing references)
		//IL_03f9: Unknown result type (might be due to invalid IL or missing references)
		//IL_0411: Unknown result type (might be due to invalid IL or missing references)
		//IL_0429: Unknown result type (might be due to invalid IL or missing references)
		//IL_0440: Unknown result type (might be due to invalid IL or missing references)
		//IL_04fe: Unknown result type (might be due to invalid IL or missing references)
		//IL_053a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0598: Unknown result type (might be due to invalid IL or missing references)
		//IL_05e5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0617: Unknown result type (might be due to invalid IL or missing references)
		//IL_0664: Unknown result type (might be due to invalid IL or missing references)
		//IL_06b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_06ed: Unknown result type (might be due to invalid IL or missing references)
		//IL_0743: Unknown result type (might be due to invalid IL or missing references)
		//IL_0776: Unknown result type (might be due to invalid IL or missing references)
		//IL_084e: Unknown result type (might be due to invalid IL or missing references)
		//IL_086b: Unknown result type (might be due to invalid IL or missing references)
		//IL_07ca: Unknown result type (might be due to invalid IL or missing references)
		//IL_0817: Unknown result type (might be due to invalid IL or missing references)
		ChaosMenu.Draw();
		MapScanner.Draw();
		AutoLevelPick.Draw();
		Toast.Draw();
		if (UpdateAvailable)
		{
			float num = 420f;
			float num2 = 36f;
			float num3 = ((float)Screen.width - num) / 2f;
			float num4 = 8f;
			GUI.Box(new Rect(num3, num4, num, num2), "");
			GUI.Label(new Rect(num3 + 8f, num4 + 8f, num - 16f, 20f), "!! MegaBonk Mod is outdated — please update to the latest version !!");
		}
		if (UnauthorizedMods.Count > 0)
		{
			float num5 = 520f;
			float num6 = 36f;
			float num7 = ((float)Screen.width - num5) / 2f;
			float num8 = 48f;
			GUI.Box(new Rect(num7, num8, num5, num6), "");
			string text = string.Join(", ", UnauthorizedMods);
			GUI.Label(new Rect(num7 + 8f, num8 + 8f, num5 - 16f, 20f), "!! Other mods detected — leaderboard disabled: " + text);
		}
		if (CheatsUsed && (Object)(object)EnemyManager.Instance != (Object)null)
		{
			float num9 = 520f;
			float num10 = 36f;
			float num11 = ((float)Screen.width - num9) / 2f;
			float num12 = ((UnauthorizedMods.Count > 0) ? 88f : 48f);
			GUI.Box(new Rect(num11, num12, num9, num10), "");
			GUI.Label(new Rect(num11 + 8f, num12 + 8f, num9 - 16f, 20f), "!! Mod menu used — leaderboard disabled for this run");
		}
		if (_promptVisible && !_authenticated)
		{
			float num13 = 240f;
			float num14 = 72f;
			float num15 = ((float)Screen.width - num13) / 2f;
			float num16 = ((float)Screen.height - num14) / 2f;
			GUI.Box(new Rect(num15, num16, num13, num14), "Mod Menu Password");
			GUI.Label(new Rect(num15 + 8f, num16 + 26f, num13 - 16f, 22f), new string('*', _passwordInput.Length));
			GUI.Label(new Rect(num15 + 8f, num16 + 50f, num13 - 16f, 18f), "Type password + Enter");
		}
		else
		{
			if (!_visible)
			{
				return;
			}
			Matrix4x4 old = _frame.Begin();
			float x = _frame.Pivot.x;
			float y = _frame.Pivot.y;
			float num17 = 424f;
			float num18 = x + 8f;
			bool enabled = (Object)(object)EnemyManager.Instance != (Object)null;
			float num19 = 32f;
			num19 += 22f;
			if (_powerupOpen)
			{
				num19 += 88f;
			}
			num19 += 26f;
			num19 += 26f;
			num19 += 26f;
			num19 += 26f;
			num19 += 26f;
			num19 += 26f;
			num19 += 26f;
			if (ShowHitboxes)
			{
				num19 += 26f;
			}
			num19 += 30f;
			UiTheme.Backdrop(new Rect(x, y, 440f, num19));
			GUI.Box(new Rect(x, y, 440f, num19), "MegaBonk Mod");
			float num20 = y + 22f + 6f;
			GUIStyle button = GUI.skin.button;
			_ = GUI.skin.toggle;
			_powerupOpen = GUI.Toggle(new Rect(num18, num20, num17, 22f), _powerupOpen, (_powerupOpen ? "[-] " : "[+] ") + "Spawn Powerup", button);
			num20 += 24f;
			if (_powerupOpen)
			{
				PickupManager instance = PickupManager.Instance;
				PlayerMovement instance2 = PlayerMovement.Instance;
				Vector3 pos = (((Object)(object)instance2 != (Object)null) ? ((Component)instance2).transform.position : Vector3.zero);
				SpawnPowerupRow(instance, pos, num18, ref num20, num17, (EPickup)2, "Health", (EPickup)3, "Nuke");
				SpawnPowerupRow(instance, pos, num18, ref num20, num17, (EPickup)4, "Clock", (EPickup)5, "Shield");
				SpawnPowerupRow(instance, pos, num18, ref num20, num17, (EPickup)6, "Rage", (EPickup)7, "Haste");
				SpawnPowerupRow(instance, pos, num18, ref num20, num17, (EPickup)8, "Stonks", (EPickup)9, "Magnet");
			}
			float num21 = (num17 - 4f) / 2f;
			GodMode = GUI.Toggle(new Rect(num18, num20, num21, 22f), GodMode, GodMode ? "God Mode: ON" : "God Mode: OFF", button);
			FlyMode = GUI.Toggle(new Rect(num18 + num21 + 4f, num20, num21, 22f), FlyMode, FlyMode ? "Fly Mode: ON" : "Fly Mode: OFF", button);
			if (GodMode || FlyMode)
			{
				CheatsUsed = true;
			}
			num20 += 26f;
			InstaKill = GUI.Toggle(new Rect(num18, num20, num21, 22f), InstaKill, InstaKill ? "Instakill: ON" : "Instakill: OFF", button);
			FreezeEnemies = GUI.Toggle(new Rect(num18 + num21 + 4f, num20, num21, 22f), FreezeEnemies, FreezeEnemies ? "Freeze Enemies: ON" : "Freeze Enemies: OFF", button);
			if (InstaKill || FreezeEnemies)
			{
				CheatsUsed = true;
			}
			num20 += 26f;
			float num22 = 70f;
			GUI.Label(new Rect(num18, num20 + 3f, num22, 22f), $"Fly Speed: {FlySpeed:F0}");
			FlySpeed = GUI.HorizontalSlider(new Rect(num18 + num22, num20 + 6f, num17 - num22, 18f), FlySpeed, 8f, 80f);
			num20 += 26f;
			if (GUI.Button(new Rect(num18, num20, num21, 22f), "+1000 XP"))
			{
				GameManager instance3 = GameManager.Instance;
				PlayerInventory val = ((instance3 != null) ? instance3.GetPlayerInventory() : null);
				if (val != null)
				{
					val.AddXp(1000);
					CheatsUsed = true;
				}
			}
			if (GUI.Button(new Rect(num18 + num21 + 4f, num20, num21, 22f), "+1000 Gold"))
			{
				GameManager instance4 = GameManager.Instance;
				PlayerInventory val2 = ((instance4 != null) ? instance4.GetPlayerInventory() : null);
				if (val2 != null)
				{
					val2.ChangeGold(1000);
					CheatsUsed = true;
				}
			}
			num20 += 26f;
			GUI.enabled = enabled;
			if (GUI.Button(new Rect(num18, num20, num21, 22f), "+1 Min (Stage Timer)"))
			{
				StageTimerHelper.Advance(60f);
				CheatsUsed = true;
			}
			if (GUI.Button(new Rect(num18 + num21 + 4f, num20, num21, 22f), "-1 Min (Stage Timer)"))
			{
				StageTimerHelper.Advance(-60f);
				CheatsUsed = true;
			}
			GUI.enabled = true;
			num20 += 26f;
			string text2 = (GiantBeeState.PhaseActive ? "Spawn BOMBUS (again)" : "Spawn BOMBUS");
			GUI.enabled = enabled;
			if (GUI.Button(new Rect(num18, num20, num17, 22f), text2))
			{
				GiantBeeState.Spawn(manualOverride: true);
				CheatsUsed = true;
			}
			GUI.enabled = true;
			num20 += 26f;
			ShowHitboxes = GUI.Toggle(new Rect(num18, num20, num17, 22f), ShowHitboxes, ShowHitboxes ? "Hitboxes: ON" : "Hitboxes: OFF", button);
			num20 += 26f;
			if (ShowHitboxes)
			{
				float num23 = 100f;
				GUI.Label(new Rect(num18, num20 + 3f, num23, 22f), $"HB Dist: {HitboxMaxDist:F0}");
				HitboxMaxDist = GUI.HorizontalSlider(new Rect(num18 + num23, num20 + 6f, num17 - num23, 18f), HitboxMaxDist, 100f, 1000f);
				num20 += 26f;
			}
			GUI.Label(new Rect(num18, num20 + 4f, num17, 22f), "F1 toggle | F2 chart | drag title | drag ↘ to resize");
			_lastWinH = num19;
			_frame.End(old);
			_frame.DrawGrip(440f, num19);
		}
	}

	private void OnRenderObject()
	{
		//IL_0042: Unknown result type (might be due to invalid IL or missing references)
		//IL_004c: Expected O, but got Unknown
		//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
		//IL_0147: Unknown result type (might be due to invalid IL or missing references)
		//IL_014c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0150: Unknown result type (might be due to invalid IL or missing references)
		//IL_0155: Unknown result type (might be due to invalid IL or missing references)
		//IL_0156: Unknown result type (might be due to invalid IL or missing references)
		//IL_015b: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_0187: Unknown result type (might be due to invalid IL or missing references)
		if (!ShowHitboxes || (Object)(object)Camera.current != (Object)(object)Camera.main)
		{
			return;
		}
		if ((Object)(object)_hitboxMat == (Object)null)
		{
			Shader val = Shader.Find("Hidden/Internal-Colored");
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			_hitboxMat = new Material(val);
			((Object)_hitboxMat).hideFlags = (HideFlags)61;
			_hitboxMat.SetInt("_SrcBlend", 5);
			_hitboxMat.SetInt("_DstBlend", 10);
			_hitboxMat.SetInt("_Cull", 0);
			_hitboxMat.SetInt("_ZWrite", 0);
			_hitboxMat.SetInt("_ZTest", 8);
		}
		if (Time.frameCount - _colliderCacheFrame > 30)
		{
			_cachedColliders = Il2CppArrayBase<Collider>.op_Implicit(Object.FindObjectsOfType<Collider>());
			_colliderCacheFrame = Time.frameCount;
		}
		if (_cachedColliders == null)
		{
			return;
		}
		Vector3 position = ((Component)Camera.main).transform.position;
		float num = HitboxMaxDist * HitboxMaxDist;
		_hitboxMat.SetPass(0);
		GL.PushMatrix();
		GL.Begin(1);
		try
		{
			Collider[] cachedColliders = _cachedColliders;
			foreach (Collider val2 in cachedColliders)
			{
				if ((Object)(object)val2 == (Object)null || !val2.enabled)
				{
					continue;
				}
				Bounds bounds = val2.bounds;
				Vector3 val3 = ((Bounds)(ref bounds)).center - position;
				if (((Vector3)(ref val3)).sqrMagnitude > num)
				{
					continue;
				}
				GL.Color(val2.isTrigger ? new Color(0f, 0.8f, 1f, 0.9f) : new Color(0f, 1f, 0f, 0.9f));
				BoxCollider val4 = ((Il2CppObjectBase)val2).TryCast<BoxCollider>();
				if ((Object)(object)val4 != (Object)null)
				{
					HbDrawBox(val4);
					continue;
				}
				SphereCollider val5 = ((Il2CppObjectBase)val2).TryCast<SphereCollider>();
				if ((Object)(object)val5 != (Object)null)
				{
					HbDrawSphere(val5);
					continue;
				}
				CapsuleCollider val6 = ((Il2CppObjectBase)val2).TryCast<CapsuleCollider>();
				if ((Object)(object)val6 != (Object)null)
				{
					HbDrawCapsule(val6);
				}
			}
		}
		catch
		{
		}
		GL.End();
		GL.PopMatrix();
	}

	private static void HbDrawBox(BoxCollider box)
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: 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_0018: Unknown result type (might be due to invalid IL or missing references)
		//IL_001d: Unknown result type (might be due to invalid IL or missing references)
		//IL_001f: 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_0027: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0035: Unknown result type (might be due to invalid IL or missing references)
		//IL_003a: Unknown result type (might be due to invalid IL or missing references)
		//IL_003f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0044: Unknown result type (might be due to invalid IL or missing references)
		//IL_0046: Unknown result type (might be due to invalid IL or missing references)
		//IL_0047: Unknown result type (might be due to invalid IL or missing references)
		//IL_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)
		//IL_005b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0060: Unknown result type (might be due to invalid IL or missing references)
		//IL_0065: Unknown result type (might be due to invalid IL or missing references)
		//IL_006a: Unknown result type (might be due to invalid IL or missing references)
		//IL_006c: 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_0073: Unknown result type (might be due to invalid IL or missing references)
		//IL_007a: 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_0085: Unknown result type (might be due to invalid IL or missing references)
		//IL_008a: 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_0092: Unknown result type (might be due to invalid IL or missing references)
		//IL_0093: Unknown result type (might be due to invalid IL or missing references)
		//IL_009a: 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)
		//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_00b1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
		//IL_0103: Unknown result type (might be due to invalid IL or missing references)
		//IL_0106: Unknown result type (might be due to invalid IL or missing references)
		//IL_0107: Unknown result type (might be due to invalid IL or missing references)
		//IL_010d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0113: Unknown result type (might be due to invalid IL or missing references)
		//IL_0119: Unknown result type (might be due to invalid IL or missing references)
		//IL_011e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0123: 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_012a: Unknown result type (might be due to invalid IL or missing references)
		//IL_012b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0132: 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_013e: 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_0148: Unknown result type (might be due to invalid IL or missing references)
		//IL_014d: Unknown result type (might be due to invalid IL or missing references)
		//IL_014f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0150: Unknown result type (might be due to invalid IL or missing references)
		//IL_0156: Unknown result type (might be due to invalid IL or missing references)
		//IL_0157: Unknown result type (might be due to invalid IL or missing references)
		//IL_015e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0160: Unknown result type (might be due to invalid IL or missing references)
		//IL_0167: Unknown result type (might be due to invalid IL or missing references)
		//IL_0169: Unknown result type (might be due to invalid IL or missing references)
		//IL_016f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0171: Unknown result type (might be due to invalid IL or missing references)
		//IL_0178: Unknown result type (might be due to invalid IL or missing references)
		//IL_017a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0181: Unknown result type (might be due to invalid IL or missing references)
		//IL_0183: Unknown result type (might be due to invalid IL or missing references)
		//IL_018a: Unknown result type (might be due to invalid IL or missing references)
		//IL_018c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0193: Unknown result type (might be due to invalid IL or missing references)
		//IL_0194: Unknown result type (might be due to invalid IL or missing references)
		//IL_019b: Unknown result type (might be due to invalid IL or missing references)
		//IL_019c: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
		Transform transform = ((Component)box).transform;
		Vector3 center = box.center;
		Vector3 val = box.size * 0.5f;
		Vector3 val2 = transform.TransformPoint(center + new Vector3(0f - val.x, 0f - val.y, 0f - val.z));
		Vector3 val3 = transform.TransformPoint(center + new Vector3(val.x, 0f - val.y, 0f - val.z));
		Vector3 val4 = transform.TransformPoint(center + new Vector3(val.x, 0f - val.y, val.z));
		Vector3 val5 = transform.TransformPoint(center + new Vector3(0f - val.x, 0f - val.y, val.z));
		Vector3 val6 = transform.TransformPoint(center + new Vector3(0f - val.x, val.y, 0f - val.z));
		Vector3 val7 = transform.TransformPoint(center + new Vector3(val.x, val.y, 0f - val.z));
		Vector3 val8 = transform.TransformPoint(center + new Vector3(val.x, val.y, val.z));
		Vector3 val9 = transform.TransformPoint(center + new Vector3(0f - val.x, val.y, val.z));
		HbLine(val2, val3);
		HbLine(val3, val4);
		HbLine(val4, val5);
		HbLine(val5, val2);
		HbLine(val6, val7);
		HbLine(val7, val8);
		HbLine(val8, val9);
		HbLine(val9, val6);
		HbLine(val2, val6);
		HbLine(val3, val7);
		HbLine(val4, val8);
		HbLine(val5, val9);
	}

	private static void HbDrawSphere(SphereCollider sphere)
	{
		//IL_0008: Unknown result type (might be due to invalid IL or missing references)
		//IL_000d: Unknown result type (might be due to invalid IL or missing references)
		//IL_001c: 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)
		//IL_0038: 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_0052: Unknown result type (might be due to invalid IL or missing references)
		//IL_0057: 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_005d: 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_006b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0070: Unknown result type (might be due to invalid IL or missing references)
		//IL_007d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0082: Unknown result type (might be due to invalid IL or missing references)
		Transform transform = ((Component)sphere).transform;
		Vector3 lossyScale = transform.lossyScale;
		float r = sphere.radius * Mathf.Max(new float[3]
		{
			Mathf.Abs(lossyScale.x),
			Mathf.Abs(lossyScale.y),
			Mathf.Abs(lossyScale.z)
		});
		Vector3 center = transform.TransformPoint(sphere.center);
		HbCircle(center, Vector3.right, Vector3.up, r);
		HbCircle(center, Vector3.right, Vector3.forward, r);
		HbCircle(center, Vector3.up, Vector3.forward, r);
	}

	private static void HbDrawCapsule(CapsuleCollider cap)
	{
		//IL_0008: Unknown result type (might be due to invalid IL or missing references)
		//IL_000d: Unknown result type (might be due to invalid IL or missing references)
		//IL_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)
		//IL_002c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0031: Unknown result type (might be due to invalid IL or missing references)
		//IL_0033: 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_003a: 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_0052: Unknown result type (might be due to invalid IL or missing references)
		//IL_0116: Unknown result type (might be due to invalid IL or missing references)
		//IL_011b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0120: 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_0124: Unknown result type (might be due to invalid IL or missing references)
		//IL_0129: Unknown result type (might be due to invalid IL or missing references)
		//IL_012e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0130: 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_01