Decompiled source of Megabonk Community Patch v1.5.3

MegaBonkMod.dll

Decompiled a week ago
using System;
using System.Collections;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Net.Http;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
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.Text.RegularExpressions;
using System.Threading.Tasks;
using Actors.Enemies;
using Assets.Scripts.Actors;
using Assets.Scripts.Actors.Enemies;
using Assets.Scripts.Actors.Player;
using Assets.Scripts.Camera;
using Assets.Scripts.Game.Combat.ConstantAttacks;
using Assets.Scripts.Game.Combat.EnemyDebuffs;
using Assets.Scripts.Game.MapGeneration;
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.Progression;
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;
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.FullMap;
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.ShopItems;
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.SceneManagement;
using UnityEngine.UI;
using Utility;

[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 AnvilBridge
{
	internal static string StatusPath
	{
		get
		{
			try
			{
				return Path.Combine(Path.GetTempPath(), "megabonk_anvil.txt");
			}
			catch
			{
				return null;
			}
		}
	}

	internal static void Tick()
	{
		//IL_0091: Unknown result type (might be due to invalid IL or missing references)
		//IL_011d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0124: Expected I4, but got Unknown
		try
		{
			string statusPath = StatusPath;
			if (statusPath == null)
			{
				return;
			}
			bool flag = false;
			bool flag2 = false;
			int value = 0;
			int num = 0;
			int num2 = 0;
			int num3 = 0;
			try
			{
				flag = !MapController.IsMainMenu() && (Object)(object)PlayerMovement.Instance != (Object)null && (Object)(object)EnemyManager.Instance != (Object)null;
				value = MapGenerationController.mapSeed;
				flag2 = flag && !MapGenerationController.isGenerating;
			}
			catch
			{
			}
			if (flag2)
			{
				try
				{
					Il2CppArrayBase<InteractableMicrowave> val = Object.FindObjectsOfType<InteractableMicrowave>();
					if (val != null)
					{
						foreach (InteractableMicrowave item in val)
						{
							if ((Object)(object)item == (Object)null)
							{
								continue;
							}
							num2++;
							try
							{
								if ((int)item.rarity == 0)
								{
									num++;
								}
							}
							catch
							{
							}
						}
					}
				}
				catch
				{
				}
				try
				{
					Il2CppArrayBase<InteractableShadyGuy> val2 = Object.FindObjectsOfType<InteractableShadyGuy>();
					if (val2 != null)
					{
						foreach (InteractableShadyGuy item2 in val2)
						{
							if ((Object)(object)item2 == (Object)null || item2.items == null)
							{
								continue;
							}
							Enumerator<ItemData> enumerator3 = item2.items.GetEnumerator();
							while (enumerator3.MoveNext())
							{
								ItemData current3 = enumerator3.Current;
								if (!((Object)(object)current3 == (Object)null))
								{
									int num4 = 0;
									try
									{
										num4 = (int)current3.eItem;
									}
									catch
									{
										continue;
									}
									if (num4 == 41)
									{
										num3 = 1;
										break;
									}
								}
							}
							if (num3 == 1)
							{
								break;
							}
						}
					}
				}
				catch
				{
				}
			}
			string contents = $"ready={(flag2 ? 1 : 0)} common={num} total={num2} anvil={num3} run={(flag ? 1 : 0)} seed={value} tick={Time.frameCount}";
			try
			{
				File.WriteAllText(statusPath, contents);
			}
			catch
			{
			}
		}
		catch
		{
		}
	}
}
internal static class BOMBUSSpawner
{
	private static MethodInfo _spawnEnemy;

	private static Type _eEnemyType;

	private static Type _eFlagType;

	internal static bool Enabled = true;

	internal static bool PhaseActive = false;

	private static float _nextSpawnTime;

	private static int _spawnCount;

	private static bool _runActive;

	private static bool _firstSpawnDone;

	private static int _stageCount;

	private static int _lastLogMin = -1;

	private static readonly HashSet<int> _chestDropped = new HashSet<int>();

	private static float _nextCheckTime;

	private const float RepeatSpawnInterval = 300f;

	internal static ConfigEntry<float> BombusHpMultiplier;

	internal static void ResetRun()
	{
		//IL_004c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0052: Expected O, but got Unknown
		_spawnCount = 0;
		_firstSpawnDone = false;
		_stageCount = 0;
		_nextSpawnTime = 900f;
		_runActive = true;
		PhaseActive = false;
		_chestDropped.Clear();
		_nextCheckTime = 0f;
		_lastLogMin = -1;
		ManualLogSource log = Plugin.Log;
		bool flag = default(bool);
		BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(39, 2, ref flag);
		if (flag)
		{
			((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[BOMBUS] ResetRun: stageCount=");
			((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(_stageCount);
			((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", first=");
			((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(FirstSpawnTime());
			((BepInExLogInterpolatedStringHandler)val).AppendLiteral("s");
		}
		log.LogInfo(val);
	}

	internal static void EndRun()
	{
		_runActive = false;
		PhaseActive = false;
		_firstSpawnDone = false;
		_chestDropped.Clear();
	}

	internal static bool HasDroppedChest(Enemy enemy)
	{
		if ((Object)(object)enemy == (Object)null)
		{
			return true;
		}
		return _chestDropped.Contains(((Object)enemy).GetInstanceID());
	}

	internal static void MarkChestDropped(Enemy enemy)
	{
		if (!((Object)(object)enemy == (Object)null))
		{
			_chestDropped.Add(((Object)enemy).GetInstanceID());
		}
	}

	internal static void OnStageStarted()
	{
		//IL_002c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0032: Expected O, but got Unknown
		_stageCount++;
		_firstSpawnDone = false;
		_nextSpawnTime = FirstSpawnTime();
		_lastLogMin = -1;
		ManualLogSource log = Plugin.Log;
		bool flag = default(bool);
		BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(45, 2, ref flag);
		if (flag)
		{
			((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[BOMBUS] OnStageStarted: stageCount=");
			((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(_stageCount);
			((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", first=");
			((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(_nextSpawnTime, "F0");
			((BepInExLogInterpolatedStringHandler)val).AppendLiteral("s");
		}
		log.LogInfo(val);
	}

	private static float FirstSpawnTime()
	{
		int num = Mathf.Clamp(_stageCount, 1, 4);
		return 900f + (float)(num - 1) * 300f;
	}

	internal static void CheckOvertimeSpawn()
	{
		//IL_0072: Unknown result type (might be due to invalid IL or missing references)
		//IL_0078: Expected O, but got Unknown
		//IL_013f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0145: Expected O, but got Unknown
		if (!Enabled || !_runActive || Time.time < _nextCheckTime)
		{
			return;
		}
		_nextCheckTime = Time.time + 1f;
		if ((Object)(object)EnemyManager.Instance == (Object)null || (Object)(object)PlayerMovement.Instance == (Object)null)
		{
			return;
		}
		float finalSwarmTimer = StageTimerHelper.GetFinalSwarmTimer();
		int num = (int)(finalSwarmTimer / 60f);
		bool flag = default(bool);
		if (num != _lastLogMin)
		{
			_lastLogMin = num;
			ManualLogSource log = Plugin.Log;
			BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(38, 5, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[BOMBUS] t=");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(finalSwarmTimer, "F0");
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("s stage=");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(_stageCount);
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" first=");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(FirstSpawnTime(), "F0");
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" done=");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<bool>(_firstSpawnDone);
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" next=");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(_nextSpawnTime, "F0");
			}
			log.LogInfo(val);
		}
		if (!_firstSpawnDone)
		{
			float num2 = FirstSpawnTime();
			if (!(finalSwarmTimer < num2))
			{
				_firstSpawnDone = true;
				_nextSpawnTime = num2 + 300f;
				_spawnCount++;
				TrySpawn();
				ManualLogSource log2 = Plugin.Log;
				BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(44, 2, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[BOMBUS] FIRST SPAWN fired (stage=");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(_stageCount);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", first=");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(num2, "F0");
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("s)");
				}
				log2.LogInfo(val);
			}
		}
		else if (!(finalSwarmTimer < _nextSpawnTime))
		{
			_spawnCount++;
			TrySpawn();
			_nextSpawnTime += 300f;
		}
	}

	internal static void TrySpawn()
	{
		//IL_025c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0263: Expected O, but got Unknown
		//IL_02a0: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a7: Expected O, but got Unknown
		//IL_02eb: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f2: Expected O, but got Unknown
		//IL_0014: Unknown result type (might be due to invalid IL or missing references)
		//IL_0323: Unknown result type (might be due to invalid IL or missing references)
		//IL_003c: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ce: 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_009d: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e2: 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_00f7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
		//IL_0101: Unknown result type (might be due to invalid IL or missing references)
		//IL_0115: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c8: 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_019b: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f1: Expected O, but got Unknown
		bool flag = default(bool);
		try
		{
			EnemyManager instance = EnemyManager.Instance;
			if ((Object)(object)instance == (Object)null)
			{
				Toast.Show("EnemyManager not available", Color.red);
				return;
			}
			PlayerMovement instance2 = PlayerMovement.Instance;
			if ((Object)(object)instance2 == (Object)null)
			{
				Toast.Show("Player not in scene", Color.red);
				return;
			}
			if (_spawnEnemy == null)
			{
				Discover(instance);
			}
			if (_spawnEnemy == null)
			{
				Toast.Show("SpawnEnemy not found", Color.yellow);
				return;
			}
			DataManager instance3 = DataManager.Instance;
			if ((Object)(object)instance3 == (Object)null)
			{
				Toast.Show("DataManager not available", Color.red);
				return;
			}
			EnemyData enemyData = instance3.GetEnemyData((EEnemy)24);
			if ((Object)(object)enemyData == (Object)null)
			{
				Toast.Show("Bee EnemyData not found", Color.yellow);
				return;
			}
			Vector3 val = ((Component)instance2).transform.position + ((Component)instance2).transform.forward * 5f;
			object obj = _spawnEnemy.Invoke(instance, new object[7]
			{
				enemyData,
				val,
				0,
				true,
				(object)(EEnemyFlag)2,
				false,
				5f
			});
			if (obj == null)
			{
				Toast.Show("SpawnEnemy returned null", Color.yellow);
				return;
			}
			Enemy val2 = (Enemy)((obj is Enemy) ? obj : null);
			if ((Object)(object)val2 == (Object)null)
			{
				Toast.Show("Not an Enemy: " + obj.GetType().Name, Color.yellow);
				return;
			}
			((Object)((Component)val2).gameObject).name = "BOMBUS";
			PhaseActive = true;
			try
			{
				float hp = val2.hp;
				InvokeSetSwarmMultiplierHp(val2, BombusHpMultiplier.Value);
				ManualLogSource log = Plugin.Log;
				BepInExInfoLogInterpolatedStringHandler val3 = new BepInExInfoLogInterpolatedStringHandler(32, 3, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("[BOMBUS] spawnHp=");
					((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<float>(hp);
					((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" factor=");
					((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<float>(BombusHpMultiplier.Value);
					((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" -> HP=");
					((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<float>(hp * BombusHpMultiplier.Value);
				}
				log.LogInfo(val3);
			}
			catch (Exception ex)
			{
				ManualLogSource log2 = Plugin.Log;
				BepInExErrorLogInterpolatedStringHandler val4 = new BepInExErrorLogInterpolatedStringHandler(19, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("[BOMBUS] HP error: ");
					((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<Exception>(ex);
				}
				log2.LogError(val4);
			}
			try
			{
				FixMinimapIcon(((Component)val2).transform);
			}
			catch (Exception ex2)
			{
				ManualLogSource log3 = Plugin.Log;
				BepInExErrorLogInterpolatedStringHandler val4 = new BepInExErrorLogInterpolatedStringHandler(21, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("[BOMBUS] Icon error: ");
					((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<Exception>(ex2);
				}
				log3.LogError(val4);
			}
			Toast.Show("BOMBUS spawned!", Color.green);
		}
		catch (Exception ex3)
		{
			ManualLogSource log4 = Plugin.Log;
			BepInExErrorLogInterpolatedStringHandler val4 = new BepInExErrorLogInterpolatedStringHandler(9, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("[BOMBUS] ");
				((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<Exception>(ex3);
			}
			log4.LogError(val4);
			Toast.Show("BOMBUS error: " + ex3.Message, Color.red);
		}
	}

	internal static void Init(ConfigFile cfg)
	{
		BombusHpMultiplier = cfg.Bind<float>("BOMBUS", "HpMultiplier", 100f, "BOMBUS HP = (EnemyData.hp × stage mult) × this. Testers: tune, then we hardcode. Logged at spawn.");
	}

	private static void InvokeSetSwarmMultiplierHp(Enemy enemy, float mult)
	{
		//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bb: Expected O, but got Unknown
		//IL_007b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0081: Expected O, but got Unknown
		MethodInfo method = ((object)enemy).GetType().GetMethod("SetSwarmMultiplierHp", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
		if (method == null)
		{
			Plugin.Log.LogError((object)"[BOMBUS] SetSwarmMultiplierHp not found");
			return;
		}
		bool flag = default(bool);
		try
		{
			if (method.GetParameters().Length >= 2)
			{
				method.Invoke(enemy, new object[2] { mult, false });
			}
			else
			{
				method.Invoke(enemy, new object[1] { mult });
			}
			ManualLogSource log = Plugin.Log;
			BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(39, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[BOMBUS] SetSwarmMultiplierHp(");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(mult);
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(") applied");
			}
			log.LogInfo(val);
		}
		catch (Exception ex)
		{
			ManualLogSource log2 = Plugin.Log;
			BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(37, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[BOMBUS] SetSwarmMultiplierHp error: ");
				((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<Exception>(ex);
			}
			log2.LogError(val2);
		}
	}

	private static void FixMinimapIcon(Transform enemy)
	{
		//IL_0030: Unknown result type (might be due to invalid IL or missing references)
		//IL_0036: Expected O, but got Unknown
		//IL_00af: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b5: Expected O, but got Unknown
		bool flag = default(bool);
		for (int i = 0; i < enemy.childCount; i++)
		{
			Transform child = enemy.GetChild(i);
			if (((Component)child).gameObject.layer == 14)
			{
				MapIconManager.SetWorldUniformScale(((Component)child).gameObject);
				ManualLogSource log = Plugin.Log;
				BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(33, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[BOMBUS] Set minimap icon scale: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(((Object)child).name);
				}
				log.LogInfo(val);
				return;
			}
		}
		Transform val2 = ((IEnumerable<Transform>)((Component)enemy).GetComponentsInChildren<Transform>(true)).FirstOrDefault((Func<Transform, bool>)((Transform t) => (Object)(object)t != (Object)null && ((Component)t).gameObject.layer == 14));
		if ((Object)(object)val2 != (Object)null)
		{
			MapIconManager.SetWorldUniformScale(((Component)val2).gameObject);
			ManualLogSource log2 = Plugin.Log;
			BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(45, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[BOMBUS] Set minimap icon scale (recursive): ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(((Object)val2).name);
			}
			log2.LogInfo(val);
		}
	}

	private static void Discover(EnemyManager em)
	{
		try
		{
			MethodInfo methodInfo = ((object)em).GetType().GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic).FirstOrDefault((MethodInfo m) => m.Name == "SpawnEnemy" && m.GetParameters().Length == 7);
			if (!(methodInfo == null))
			{
				_spawnEnemy = methodInfo;
				ParameterInfo[] parameters = methodInfo.GetParameters();
				_eEnemyType = parameters.FirstOrDefault((ParameterInfo p) => p.ParameterType.IsEnum)?.ParameterType;
				_eFlagType = parameters.LastOrDefault((ParameterInfo p) => p.ParameterType.IsEnum)?.ParameterType;
			}
		}
		catch
		{
		}
	}
}
internal static class BushIconHelper
{
	private static readonly HashSet<int> _handled = new HashSet<int>();

	private static int _frameCounter;

	private static InteractableCharacterFight _fight;

	private static Mesh _templateMesh;

	private static Material _templateMat;

	internal static void Tick()
	{
		//IL_0552: Unknown result type (might be due to invalid IL or missing references)
		//IL_0559: Expected O, but got Unknown
		//IL_02bf: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c6: Expected O, but got Unknown
		//IL_02f4: Unknown result type (might be due to invalid IL or missing references)
		//IL_0314: Unknown result type (might be due to invalid IL or missing references)
		//IL_0325: Unknown result type (might be due to invalid IL or missing references)
		//IL_037c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0383: Expected O, but got Unknown
		//IL_039c: Unknown result type (might be due to invalid IL or missing references)
		//IL_03a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_03b7: Unknown result type (might be due to invalid IL or missing references)
		//IL_03bc: Unknown result type (might be due to invalid IL or missing references)
		//IL_03d2: Unknown result type (might be due to invalid IL or missing references)
		//IL_03d7: Unknown result type (might be due to invalid IL or missing references)
		//IL_03ed: Unknown result type (might be due to invalid IL or missing references)
		//IL_03f2: Unknown result type (might be due to invalid IL or missing references)
		//IL_0432: Unknown result type (might be due to invalid IL or missing references)
		//IL_0437: Unknown result type (might be due to invalid IL or missing references)
		//IL_0448: Unknown result type (might be due to invalid IL or missing references)
		//IL_044d: Unknown result type (might be due to invalid IL or missing references)
		//IL_045e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0463: Unknown result type (might be due to invalid IL or missing references)
		//IL_0474: Unknown result type (might be due to invalid IL or missing references)
		//IL_0479: Unknown result type (might be due to invalid IL or missing references)
		//IL_04a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_04b0: Expected O, but got Unknown
		//IL_04d8: Unknown result type (might be due to invalid IL or missing references)
		//IL_04df: Expected O, but got Unknown
		if (++_frameCounter % 60 != 0)
		{
			return;
		}
		try
		{
			if ((Object)(object)PlayerMovement.Instance == (Object)null)
			{
				_fight = null;
				if (_handled.Count > 0)
				{
					_handled.Clear();
				}
				return;
			}
			if ((Object)(object)_fight == (Object)null)
			{
				foreach (InteractableCharacterFight item in Object.FindObjectsOfType<InteractableCharacterFight>())
				{
					if ((Object)(object)item == (Object)null)
					{
						continue;
					}
					string text = "";
					try
					{
						CharacterData character = item.character;
						object obj = ((character == null) ? null : ((UnlockableBase)character).GetInternalName()?.ToLowerInvariant());
						if (obj == null)
						{
							CharacterData character2 = item.character;
							obj = ((character2 == null) ? null : ((Object)character2).name?.ToLowerInvariant()) ?? "";
						}
						text = (string)obj;
					}
					catch
					{
						continue;
					}
					if (text.Contains("bush"))
					{
						_fight = item;
						break;
					}
				}
				if ((Object)(object)_fight == (Object)null)
				{
					return;
				}
			}
			InteractableCharacterFight fight = _fight;
			Transform transform = ((Component)fight).transform;
			if ((Object)(object)transform == (Object)null)
			{
				_fight = null;
				return;
			}
			int instanceID = ((Object)fight).GetInstanceID();
			if (_handled.Contains(instanceID))
			{
				return;
			}
			bool flag = false;
			for (int i = 0; i < transform.childCount; i++)
			{
				if (((Component)transform.GetChild(i)).gameObject.layer == 14)
				{
					flag = true;
					break;
				}
			}
			if (flag)
			{
				_handled.Add(instanceID);
			}
			else
			{
				if (!MapIconManager.TryGet("bush", out var tex) || (Object)(object)tex == (Object)null)
				{
					return;
				}
				if ((Object)(object)_templateMesh == (Object)null || (Object)(object)_templateMat == (Object)null)
				{
					foreach (Transform item2 in Object.FindObjectsOfType<Transform>())
					{
						if (((Component)item2).gameObject.layer != 14)
						{
							continue;
						}
						MeshRenderer component = ((Component)item2).gameObject.GetComponent<MeshRenderer>();
						MeshFilter component2 = ((Component)item2).gameObject.GetComponent<MeshFilter>();
						if ((Object)(object)component != (Object)null && (Object)(object)component2 != (Object)null && (Object)(object)component2.sharedMesh != (Object)null && ((Object)component2.sharedMesh).name.Contains("Quad") && (Object)(object)((Renderer)component).sharedMaterial != (Object)null)
						{
							bool flag2 = false;
							try
							{
								flag2 = ((Renderer)component).sharedMaterial.HasProperty("_MainTex");
							}
							catch
							{
							}
							if (flag2)
							{
								_templateMesh = component2.sharedMesh;
								_templateMat = ((Renderer)component).sharedMaterial;
								break;
							}
						}
					}
				}
				Mesh templateMesh = _templateMesh;
				Material templateMat = _templateMat;
				GameObject val = new GameObject("MinimapIcon_Bush");
				val.layer = 14;
				val.transform.SetParent(transform, false);
				val.transform.localPosition = new Vector3(0f, 2f, 0f);
				val.transform.localRotation = Quaternion.Euler(90f, 0f, 0f);
				val.transform.localScale = Vector3.one;
				MeshFilter val2 = val.AddComponent<MeshFilter>();
				MeshRenderer val3 = val.AddComponent<MeshRenderer>();
				MinimapIcon obj4 = val.AddComponent<MinimapIcon>();
				obj4.isStatic = false;
				obj4.alignToCamera = false;
				MinimapIconUpdatePatch.Tag(val);
				MinimapIconRotationManager.Tag(val);
				if ((Object)(object)templateMesh != (Object)null)
				{
					val2.sharedMesh = templateMesh;
				}
				else
				{
					Mesh val4 = new Mesh();
					val4.vertices = Il2CppStructArray<Vector3>.op_Implicit((Vector3[])(object)new Vector3[4]
					{
						new Vector3(-0.5f, -0.5f, 0f),
						new Vector3(0.5f, -0.5f, 0f),
						new Vector3(0.5f, 0.5f, 0f),
						new Vector3(-0.5f, 0.5f, 0f)
					});
					val4.triangles = Il2CppStructArray<int>.op_Implicit(new int[6] { 0, 1, 2, 0, 2, 3 });
					val4.uv = Il2CppStructArray<Vector2>.op_Implicit((Vector2[])(object)new Vector2[4]
					{
						new Vector2(0f, 0f),
						new Vector2(1f, 0f),
						new Vector2(1f, 1f),
						new Vector2(0f, 1f)
					});
					val4.RecalculateNormals();
					val2.sharedMesh = val4;
				}
				if ((Object)(object)templateMat != (Object)null)
				{
					((Renderer)val3).sharedMaterial = new Material(templateMat);
				}
				else
				{
					Material val5 = new Material(Shader.Find("Custom/MinimapIconInstancedCutoutColor") ?? Shader.Find("Sprites/Default") ?? Shader.Find("Unlit/Transparent"));
					try
					{
						MinimapIcon val6 = Object.FindObjectOfType<MinimapIcon>();
						if ((Object)(object)val6 != (Object)null)
						{
							Renderer component3 = ((Component)val6).GetComponent<Renderer>();
							if ((Object)(object)component3 != (Object)null && (Object)(object)component3.sharedMaterial != (Object)null)
							{
								val5.CopyPropertiesFromMaterial(component3.sharedMaterial);
							}
						}
					}
					catch
					{
					}
					((Renderer)val3).sharedMaterial = val5;
				}
				MapIconManager.ApplyToIcon(val, tex);
				_handled.Add(instanceID);
			}
		}
		catch (Exception ex)
		{
			ManualLogSource log = Plugin.Log;
			bool flag3 = default(bool);
			BepInExWarningLogInterpolatedStringHandler val7 = new BepInExWarningLogInterpolatedStringHandler(29, 1, ref flag3);
			if (flag3)
			{
				((BepInExLogInterpolatedStringHandler)val7).AppendLiteral("[MapIcons] Bush tick failed: ");
				((BepInExLogInterpolatedStringHandler)val7).AppendFormatted<string>(ex.Message);
			}
			log.LogWarning(val7);
		}
	}

	internal static void Clear()
	{
		_handled.Clear();
	}
}
internal static class ChaosMenu
{
	private static readonly (string header, (int id, string name, bool def)[] stats)[] Sections = new(string, (int, string, bool)[])[5]
	{
		("Survival", new(int, string, bool)[7]
		{
			(0, "Max HP", true),
			(1, "Health Regen", false),
			(2, "Shield", false),
			(17, "Lifesteal", false),
			(4, "Armor", false),
			(5, "Evasion", false),
			(3, "Thorns", false)
		}),
		("Offense", new(int, string, bool)[5]
		{
			(12, "Damage %", true),
			(18, "Crit Chance", true),
			(19, "Crit Damage", true),
			(15, "Attack Speed", true),
			(16, "Projectiles", false)
		}),
		("Utility", new(int, string, bool)[6]
		{
			(9, "Size", true),
			(11, "Projectile Speed", false),
			(10, "Duration", true),
			(23, "Damage to Elites", true),
			(24, "Knockback", false),
			(25, "Movement Speed", true)
		}),
		("Mobility & Luck", new(int, string, bool)[4]
		{
			(46, "Extra Jumps", false),
			(26, "Jump Height", false),
			(30, "Luck", true),
			(38, "Difficulty", false)
		}),
		("Economy & Powerups", new(int, string, bool)[6]
		{
			(29, "Pickup Range", true),
			(32, "XP Gain", true),
			(31, "Gold Gain", true),
			(39, "Elite Spawn", true),
			(40, "Powerup Boost", true),
			(41, "Powerup Chance", true)
		})
	};

	private static readonly int[][] ColSections = new int[2][]
	{
		new int[2] { 0, 4 },
		new int[3] { 1, 2, 3 }
	};

	private static int[] _ids;

	private static string[] _names;

	private static bool[] _defs;

	private static ConfigEntry<bool>[] _allow;

	private static string[] _sectionHeaders;

	private static int[] _sectionStart;

	private static int[] _sectionCount;

	private static ConfigFile _cfg;

	internal static bool Visible;

	private const int TotalPoolSize = 28;

	private static string[] _onLabels;

	private static string[] _offLabels;

	private static ConfigEntry<bool> _horizontalEntry;

	private const float PadX = 12f;

	private const float LineH = 24f;

	private const float HeaderH = 22f;

	private const float WinWVert = 260f;

	private const float WinWHoriz = 500f;

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

	private static float _lastWinH;

	private const int MinEnabled = 3;

	internal static float RewardMultiplier { get; private set; } = 1f;

	private static bool Horizontal
	{
		get
		{
			if (_horizontalEntry != null)
			{
				return _horizontalEntry.Value;
			}
			return false;
		}
	}

	private static float WinW
	{
		get
		{
			if (!Horizontal)
			{
				return 260f;
			}
			return 500f;
		}
	}

	private static void Flatten()
	{
		int num = 0;
		(string, (int, string, bool)[])[] sections = Sections;
		for (int i = 0; i < sections.Length; i++)
		{
			(string, (int, string, bool)[]) tuple = sections[i];
			num += tuple.Item2.Length;
		}
		_ids = new int[num];
		_names = new string[num];
		_defs = new bool[num];
		_sectionHeaders = new string[Sections.Length];
		_sectionStart = new int[Sections.Length];
		_sectionCount = new int[Sections.Length];
		int num2 = 0;
		for (int j = 0; j < Sections.Length; j++)
		{
			_sectionHeaders[j] = Sections[j].header;
			_sectionStart[j] = num2;
			_sectionCount[j] = Sections[j].stats.Length;
			(int, string, bool)[] item = Sections[j].stats;
			for (int i = 0; i < item.Length; i++)
			{
				(int, string, bool) tuple2 = item[i];
				_ids[num2] = tuple2.Item1;
				_names[num2] = tuple2.Item2;
				_defs[num2] = tuple2.Item3;
				num2++;
			}
		}
	}

	private static float SectionH(int s)
	{
		return 22f + (float)_sectionCount[s] * 26f;
	}

	private static float ColumnH(int[] sectionIdx)
	{
		float num = 0f;
		foreach (int s in sectionIdx)
		{
			num += SectionH(s);
		}
		return num;
	}

	private static float WinHeight()
	{
		float num = 32f;
		num += 48f;
		if (Horizontal)
		{
			float num2 = 0f;
			int[][] colSections = ColSections;
			for (int i = 0; i < colSections.Length; i++)
			{
				float num3 = ColumnH(colSections[i]);
				if (num3 > num2)
				{
					num2 = num3;
				}
			}
			num += num2;
		}
		else
		{
			for (int j = 0; j < Sections.Length; j++)
			{
				num += SectionH(j);
			}
		}
		return num + 8f;
	}

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

	internal static void Init(ConfigFile cfg)
	{
		Flatten();
		_cfg = cfg;
		_frame.Init(cfg, "ChaosMenu");
		_horizontalEntry = cfg.Bind<bool>("ChaosStats", "HorizontalLayout", false, "Show the Chaos Tome stats menu in side-by-side column layout.");
		_allow = new ConfigEntry<bool>[_ids.Length];
		for (int i = 0; i < _ids.Length; i++)
		{
			_allow[i] = cfg.Bind<bool>("ChaosStats", _names[i], _defs[i], "Allow '" + _names[i] + "' to appear in the Chaos Tome / Gamble pool.");
		}
		RebuildLabels();
		ApplyAllToBlacklist();
	}

	private static void RebuildLabels()
	{
		_onLabels = new string[_ids.Length];
		_offLabels = new string[_ids.Length];
		for (int i = 0; i < _ids.Length; i++)
		{
			_onLabels[i] = "ON   " + _names[i];
			_offLabels[i] = "OFF  " + _names[i];
		}
	}

	private static void ApplyAllToBlacklist()
	{
		int num = 0;
		for (int i = 0; i < _ids.Length; i++)
		{
			if (_allow[i].Value)
			{
				Plugin.BlacklistedStats.Remove(_ids[i]);
				Plugin.BlacklistedShrineStats.Remove(_ids[i]);
				num++;
			}
			else
			{
				Plugin.BlacklistedStats.Add(_ids[i]);
				Plugin.BlacklistedShrineStats.Add(_ids[i]);
			}
		}
		RewardMultiplier = (float)num / 28f;
	}

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

	internal static void ResetFramePosition()
	{
		try
		{
			_frame.ResetPosition();
		}
		catch
		{
		}
	}

	private static void SetAllowed(int idx, bool allowed)
	{
		//IL_0121: 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_0133: Unknown result type (might be due to invalid IL or missing references)
		//IL_0154: 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_00df: 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_00f1: Unknown result type (might be due to invalid IL or missing references)
		//IL_0112: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
		if (_allow[idx].Value == allowed)
		{
			return;
		}
		if (!allowed)
		{
			int num = 0;
			for (int i = 0; i < _ids.Length; i++)
			{
				if (i != idx && _allow[i].Value)
				{
					num++;
				}
			}
			if (num < 3)
			{
				return;
			}
		}
		_allow[idx].Value = allowed;
		try
		{
			ConfigFile cfg = _cfg;
			if (cfg != null)
			{
				cfg.Save();
			}
		}
		catch
		{
		}
		int num2 = _ids[idx];
		if (allowed)
		{
			Plugin.BlacklistedStats.Remove(num2);
		}
		else
		{
			Plugin.BlacklistedStats.Add(num2);
		}
		if (allowed)
		{
			Plugin.BlacklistedShrineStats.Remove(num2);
		}
		else
		{
			Plugin.BlacklistedShrineStats.Add(num2);
		}
		int num3 = 0;
		for (int j = 0; j < _ids.Length; j++)
		{
			if (_allow[j].Value)
			{
				num3++;
			}
		}
		RewardMultiplier = (float)num3 / 28f;
		try
		{
			EStat val = (EStat)num2;
			List<EStat> upgradableStatsChaosAndGamble = EncounterUtility.upgradableStatsChaosAndGamble;
			if (upgradableStatsChaosAndGamble != null)
			{
				if (allowed)
				{
					if (!upgradableStatsChaosAndGamble.Contains(val))
					{
						upgradableStatsChaosAndGamble.Add(val);
					}
				}
				else if (upgradableStatsChaosAndGamble.Contains(val))
				{
					upgradableStatsChaosAndGamble.Remove(val);
				}
			}
		}
		catch
		{
		}
		try
		{
			EStat val2 = (EStat)num2;
			List<EStat> upgradableStatsShrines = EncounterUtility.upgradableStatsShrines;
			if (upgradableStatsShrines == null)
			{
				return;
			}
			if (allowed)
			{
				if (!upgradableStatsShrines.Contains(val2))
				{
					upgradableStatsShrines.Add(val2);
				}
			}
			else if (upgradableStatsShrines.Contains(val2))
			{
				upgradableStatsShrines.Remove(val2);
			}
		}
		catch
		{
		}
	}

	private static float DrawSection(float lx, float y, float cw, int sectionIdx, GUIStyle toggle)
	{
		//IL_000f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0021: Unknown result type (might be due to invalid IL or missing references)
		//IL_0032: 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)
		GUI.color = new Color(0.7f, 0.85f, 1f);
		GUI.Label(new Rect(lx, y, cw, 22f), _sectionHeaders[sectionIdx]);
		GUI.color = Color.white;
		y += 22f;
		int num = _sectionStart[sectionIdx];
		for (int i = 0; i < _sectionCount[sectionIdx]; i++)
		{
			bool value = _allow[num].Value;
			string text = (value ? _onLabels[num] : _offLabels[num]);
			bool flag = GUI.Toggle(new Rect(lx, y, cw, 24f), value, text, toggle);
			if (flag != value)
			{
				SetAllowed(num, flag);
			}
			y += 26f;
			num++;
		}
		return y;
	}

	internal static void Draw()
	{
		//IL_001f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_0048: Unknown result type (might be due to invalid IL or missing references)
		//IL_0056: 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)
		//IL_0163: Unknown result type (might be due to invalid IL or missing references)
		//IL_0190: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b2: Unknown result type (might be due to invalid IL or missing references)
		if (!Visible)
		{
			return;
		}
		float winW = WinW;
		float num = (_lastWinH = WinHeight());
		Matrix4x4 old = _frame.Begin();
		float x = _frame.Pivot.x;
		float y = _frame.Pivot.y;
		UiTheme.Backdrop(new Rect(x, y, winW, num));
		GUI.Box(new Rect(x, y, winW, num), $"Chaos Tome Stats ({RewardMultiplier:P0})");
		float num2 = winW - 24f;
		float num3 = x + 12f;
		float num4 = y + 24f + 2f;
		string text = (Horizontal ? "[H]" : "[V]");
		float num5 = 30f;
		if (GUI.Button(new Rect(x + winW - num5 - 4f, y + 2f, num5, 22f), text))
		{
			_horizontalEntry.Value = !_horizontalEntry.Value;
			try
			{
				ConfigFile cfg = _cfg;
				if (cfg != null)
				{
					cfg.Save();
				}
			}
			catch
			{
			}
		}
		int num6 = 0;
		for (int i = 0; i < _ids.Length; i++)
		{
			if (_allow[i].Value)
			{
				num6++;
			}
		}
		GUI.Label(new Rect(num3, num4, num2, 24f), "Toggle stats in the Chaos/Gamble pool:");
		num4 += 24f;
		if (num6 <= 3)
		{
			GUI.color = new Color(1f, 0.7f, 0.3f);
			GUI.Label(new Rect(num3, num4, num2, 24f), $"(min {3} to avoid crash)");
			GUI.color = Color.white;
		}
		num4 += 24f;
		GUIStyle button = GUI.skin.button;
		if (Horizontal)
		{
			float num7 = (num2 - 12f) / 2f;
			float[] array = new float[2]
			{
				num3,
				num3 + num7 + 12f
			};
			for (int j = 0; j < ColSections.Length; j++)
			{
				float y2 = num4;
				int[] array2 = ColSections[j];
				foreach (int sectionIdx in array2)
				{
					y2 = DrawSection(array[j], y2, num7, sectionIdx, button);
				}
			}
		}
		else
		{
			for (int l = 0; l < Sections.Length; l++)
			{
				num4 = DrawSection(num3, num4, num2, l, button);
			}
		}
		_frame.End(old);
		_frame.DrawGrip(winW, num);
	}
}
internal static class CharacterKits
{
	internal static readonly Dictionary<ECharacter, EItem[]> Kits;

	private static readonly Dictionary<EItem, string> Names;

	internal static void Grant(PlayerInventory inv)
	{
		//IL_0043: 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_004b: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			if (((inv != null) ? inv.itemInventory : null) == null)
			{
				return;
			}
			MyPlayer instance = MyPlayer.Instance;
			if ((Object)(object)instance == (Object)null || !Kits.TryGetValue(instance.character, out var value) || value == null)
			{
				return;
			}
			EItem[] array = value;
			foreach (EItem val in array)
			{
				try
				{
					inv.itemInventory.AddItem(val);
				}
				catch
				{
				}
			}
		}
		catch
		{
		}
	}

	internal static string Line(ECharacter character)
	{
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		if (!Kits.TryGetValue(character, out var value) || value == null || value.Length == 0)
		{
			return null;
		}
		string[] array = new string[value.Length];
		for (int i = 0; i < value.Length; i++)
		{
			array[i] = (Names.TryGetValue(value[i], out var value2) ? value2 : ((object)Unsafe.As<EItem, EItem>(ref value[i])/*cast due to .constrained prefix*/).ToString());
		}
		return "<color=#8860FF>BUILT-IN: starts every run with " + string.Join(", ", array) + ".</color>";
	}

	static CharacterKits()
	{
		Dictionary<ECharacter, EItem[]> dictionary = new Dictionary<ECharacter, EItem[]> { 
		{
			(ECharacter)0,
			(EItem[])(object)new EItem[1] { (EItem)22 }
		} };
		EItem[] array = new EItem[3];
		RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
		dictionary.Add((ECharacter)2, (EItem[])(object)array);
		EItem[] array2 = new EItem[4];
		RuntimeHelpers.InitializeArray(array2, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
		dictionary.Add((ECharacter)1, (EItem[])(object)array2);
		dictionary.Add((ECharacter)4, (EItem[])(object)new EItem[1] { (EItem)48 });
		dictionary.Add((ECharacter)5, (EItem[])(object)new EItem[1] { (EItem)3 });
		dictionary.Add((ECharacter)3, (EItem[])(object)new EItem[2]
		{
			(EItem)11,
			(EItem)9
		});
		EItem[] array3 = new EItem[3];
		RuntimeHelpers.InitializeArray(array3, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
		dictionary.Add((ECharacter)7, (EItem[])(object)array3);
		dictionary.Add((ECharacter)6, (EItem[])(object)new EItem[3]
		{
			default(EItem),
			(EItem)14,
			(EItem)23
		});
		dictionary.Add((ECharacter)11, (EItem[])(object)new EItem[2]
		{
			(EItem)26,
			(EItem)67
		});
		dictionary.Add((ECharacter)13, (EItem[])(object)new EItem[2]
		{
			(EItem)34,
			(EItem)7
		});
		dictionary.Add((ECharacter)9, (EItem[])(object)new EItem[2]
		{
			(EItem)12,
			(EItem)9
		});
		EItem[] array4 = new EItem[3];
		RuntimeHelpers.InitializeArray(array4, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
		dictionary.Add((ECharacter)8, (EItem[])(object)array4);
		dictionary.Add((ECharacter)12, (EItem[])(object)new EItem[2]
		{
			(EItem)70,
			(EItem)18
		});
		EItem[] array5 = new EItem[4];
		RuntimeHelpers.InitializeArray(array5, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
		dictionary.Add((ECharacter)14, (EItem[])(object)array5);
		EItem[] array6 = new EItem[3];
		RuntimeHelpers.InitializeArray(array6, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
		dictionary.Add((ECharacter)15, (EItem[])(object)array6);
		dictionary.Add((ECharacter)10, (EItem[])(object)new EItem[2]
		{
			(EItem)49,
			(EItem)7
		});
		EItem[] array7 = new EItem[4];
		RuntimeHelpers.InitializeArray(array7, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
		dictionary.Add((ECharacter)16, (EItem[])(object)array7);
		dictionary.Add((ECharacter)17, (EItem[])(object)new EItem[2]
		{
			(EItem)62,
			(EItem)61
		});
		dictionary.Add((ECharacter)19, (EItem[])(object)new EItem[2]
		{
			(EItem)16,
			(EItem)38
		});
		dictionary.Add((ECharacter)18, (EItem[])(object)new EItem[2]
		{
			(EItem)77,
			(EItem)78
		});
		EItem[] array8 = new EItem[3];
		RuntimeHelpers.InitializeArray(array8, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
		dictionary.Add((ECharacter)20, (EItem[])(object)array8);
		Kits = dictionary;
		Names = new Dictionary<EItem, string>
		{
			{
				(EItem)22,
				"Dragonfire"
			},
			{
				(EItem)2,
				"Spiky Shield"
			},
			{
				(EItem)37,
				"Rollerblades"
			},
			{
				(EItem)48,
				"Mirror"
			},
			{
				(EItem)3,
				"Big Bonk"
			},
			{
				(EItem)11,
				"Grandma's Secret Tonic"
			},
			{
				(EItem)68,
				"Cactus"
			},
			{
				(EItem)0,
				"Key"
			},
			{
				(EItem)26,
				"Overpowered Lamp"
			},
			{
				(EItem)34,
				"Backpack"
			},
			{
				(EItem)7,
				"Battery"
			},
			{
				(EItem)12,
				"Fork"
			},
			{
				(EItem)27,
				"Feather"
			},
			{
				(EItem)39,
				"Eagle Claw"
			},
			{
				(EItem)70,
				"Ice Crystal"
			},
			{
				(EItem)18,
				"Ice Cube"
			},
			{
				(EItem)13,
				"Cheese"
			},
			{
				(EItem)73,
				"Moldy Gloves"
			},
			{
				(EItem)53,
				"Toxic Barrel"
			},
			{
				(EItem)83,
				"Snek"
			},
			{
				(EItem)32,
				"Echo Shard"
			},
			{
				(EItem)49,
				"Joe's Dagger"
			},
			{
				(EItem)8,
				"Evasion Shroud"
			},
			{
				(EItem)4,
				"Slippery Ring"
			},
			{
				(EItem)62,
				"Bloody Cleaver"
			},
			{
				(EItem)16,
				"Chonkplate"
			},
			{
				(EItem)77,
				"Wrench"
			},
			{
				(EItem)78,
				"Beacon"
			},
			{
				(EItem)28,
				"Ghost"
			},
			{
				(EItem)46,
				"Bob (Dead)"
			},
			{
				(EItem)80,
				"Quin's Mask"
			},
			{
				(EItem)71,
				"Time Bracelet"
			},
			{
				(EItem)30,
				"Turbo Socks"
			},
			{
				(EItem)5,
				"Coward's Cloak"
			},
			{
				(EItem)14,
				"Golden Sneakers"
			},
			{
				(EItem)23,
				"Golden Glove"
			},
			{
				(EItem)9,
				"Forbidden Juice"
			},
			{
				(EItem)67,
				"Tactical Glasses"
			},
			{
				(EItem)31,
				"Shattered Wisdom"
			},
			{
				(EItem)61,
				"Unstable Transfusion"
			},
			{
				(EItem)38,
				"Skuleg"
			}
		};
	}
}
internal static class ChestMagnet
{
	private static ConfigEntry<bool> _enabled;

	private static ConfigEntry<bool> _tNormal;

	private static ConfigEntry<bool> _tCorrupt;

	private static ConfigEntry<bool> _tFree;

	private static ConfigEntry<bool> _tFreeCrypt;

	private static ConfigEntry<bool> _tGhost;

	private const float Speed = 18f;

	private static readonly List<InteractableChest> _tracked = new List<InteractableChest>();

	private static readonly List<OpenChest> _trackedOpen = new List<OpenChest>();

	private static readonly HashSet<int> _drops = new HashSet<int>();

	private static float _prevSuck = -1f;

	private static float _suckUntil = -1f;

	private static readonly Dictionary<int, Object> _live = new Dictionary<int, Object>();

	private static Action _onOpened;

	internal static void Register(Object chest)
	{
		try
		{
			if (chest != (Object)null)
			{
				_live[chest.GetInstanceID()] = chest;
			}
		}
		catch
		{
		}
	}

	internal static void NoteSpawnPre(out HashSet<int> snapshot)
	{
		snapshot = new HashSet<int>(_live.Keys);
	}

	private static void SnapGround(Transform t)
	{
		//IL_000c: 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_0012: 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_0031: Unknown result type (might be due to invalid IL or missing references)
		//IL_0036: Unknown result type (might be due to invalid IL or missing references)
		//IL_0037: 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_0044: Unknown result type (might be due to invalid IL or missing references)
		//IL_004a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0059: 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_006b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0071: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			if (!((Object)(object)t == (Object)null))
			{
				Vector3 position = t.position;
				Vector3 val = RaycastUtility.RayToGround(position + new Vector3(0f, 10f, 0f), 200f);
				if (val != Vector3.zero && val.y <= position.y + 0.5f)
				{
					t.position = new Vector3(val.x, val.y + 0.5f, val.z);
				}
			}
		}
		catch
		{
		}
	}

	internal static void NoteSpawnPost(HashSet<int> snapshot)
	{
		try
		{
			foreach (KeyValuePair<int, Object> item in _live)
			{
				int key = item.Key;
				if (snapshot == null || !snapshot.Contains(key))
				{
					Object value = item.Value;
					if (!(value == (Object)null))
					{
						_drops.Add(key);
						Component val = ((Il2CppObjectBase)value).TryCast<Component>();
						SnapGround(((Object)(object)val != (Object)null) ? val.transform : null);
					}
				}
			}
		}
		catch
		{
		}
	}

	internal static void Init(ConfigFile cfg)
	{
		try
		{
			if (_onOpened == null)
			{
				_onOpened = OnChestOpened;
			}
			InteractableChest.A_ChestOpened += Action.op_Implicit(_onOpened);
		}
		catch
		{
		}
		_enabled = cfg.Bind<bool>("ChestMagnet", "Enabled", true, "Sucky Magnet pulls matching drop chests toward you.");
		_tNormal = cfg.Bind<bool>("ChestMagnet", "PullNormal", true, "Pull Normal chests (boss/mob drops).");
		_tCorrupt = cfg.Bind<bool>("ChestMagnet", "PullCorrupt", true, "Pull Corrupt chests.");
		_tFree = cfg.Bind<bool>("ChestMagnet", "PullFree", true, "Pull Free chests.");
		_tFreeCrypt = cfg.Bind<bool>("ChestMagnet", "PullFreeCrypt", true, "Pull FreeCrypt chests.");
		_tGhost = cfg.Bind<bool>("ChestMagnet", "PullGhost", true, "Pull Ghost chests.");
		try
		{
			ConfigEntry<bool> val = cfg.Bind<bool>("ChestMagnet", "PullAllMigrated", false, "One-time migration to all-types-on.");
			if (!val.Value)
			{
				_tCorrupt.Value = true;
				_tFreeCrypt.Value = true;
				_tGhost.Value = true;
				val.Value = true;
				cfg.Save();
			}
		}
		catch
		{
		}
	}

	private static bool TypeOn(EChest t)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_0002: Expected I4, but got Unknown
		return (int)t switch
		{
			0 => _tNormal.Value, 
			1 => _tCorrupt.Value, 
			2 => _tFree.Value, 
			3 => _tFreeCrypt.Value, 
			4 => _tGhost.Value, 
			_ => false, 
		};
	}

	private static void OnChestOpened()
	{
		try
		{
			for (int num = _tracked.Count - 1; num >= 0; num--)
			{
				InteractableChest val = _tracked[num];
				if ((Object)(object)val == (Object)null || (Object)(object)((Component)val).gameObject == (Object)null || !((Component)val).gameObject.activeInHierarchy)
				{
					_tracked.RemoveAt(num);
				}
			}
			for (int num2 = _trackedOpen.Count - 1; num2 >= 0; num2--)
			{
				OpenChest val2 = _trackedOpen[num2];
				if ((Object)(object)val2 == (Object)null || (Object)(object)((Component)val2).gameObject == (Object)null || !((Component)val2).gameObject.activeInHierarchy)
				{
					_trackedOpen.RemoveAt(num2);
				}
			}
		}
		catch
		{
		}
	}

	private static bool HasMagnet()
	{
		try
		{
			GameManager instance = GameManager.Instance;
			object obj;
			if (instance == null)
			{
				obj = null;
			}
			else
			{
				PlayerInventory playerInventory = instance.GetPlayerInventory();
				obj = ((playerInventory != null) ? playerInventory.itemInventory : null);
			}
			ItemInventory val = (ItemInventory)obj;
			return val != null && val.GetAmount((EItem)33) > 0;
		}
		catch
		{
			return false;
		}
	}

	internal static void Tick()
	{
		//IL_0102: 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_015e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0164: Invalid comparison between Unknown and I4
		//IL_0168: Unknown result type (might be due to invalid IL or missing references)
		//IL_016e: Invalid comparison between Unknown and I4
		//IL_0172: Unknown result type (might be due to invalid IL or missing references)
		//IL_0178: Invalid comparison between Unknown and I4
		//IL_0245: Unknown result type (might be due to invalid IL or missing references)
		//IL_0198: Unknown result type (might be due to invalid IL or missing references)
		//IL_0266: 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_026d: Unknown result type (might be due to invalid IL or missing references)
		//IL_026f: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
		//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c1: 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_0293: Unknown result type (might be due to invalid IL or missing references)
		//IL_0295: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			PlayerMovement instance = PlayerMovement.Instance;
			if ((Object)(object)instance == (Object)null || (Object)(object)EnemyManager.Instance == (Object)null)
			{
				if (_tracked.Count > 0)
				{
					_tracked.Clear();
				}
				if (_trackedOpen.Count > 0)
				{
					_trackedOpen.Clear();
				}
				if (_drops.Count > 0)
				{
					_drops.Clear();
				}
				if (_live.Count > 0)
				{
					_live.Clear();
				}
				_prevSuck = -1f;
				_suckUntil = -1f;
				return;
			}
			if (!HasMagnet())
			{
				_tracked.Clear();
				_trackedOpen.Clear();
				return;
			}
			if (SuckFired())
			{
				_suckUntil = MyTime.time + 1.5f;
				Rescan(instance);
			}
			if (MyTime.time > _suckUntil || (_tracked.Count == 0 && _trackedOpen.Count == 0))
			{
				return;
			}
			Vector3 position = ((Component)instance).transform.position;
			float num = 18f * Time.deltaTime;
			for (int num2 = _tracked.Count - 1; num2 >= 0; num2--)
			{
				InteractableChest val = _tracked[num2];
				if ((Object)(object)val == (Object)null || (Object)(object)((Component)val).gameObject == (Object)null)
				{
					_tracked.RemoveAt(num2);
				}
				else
				{
					bool flag = (int)val.chestType == 2 || (int)val.chestType == 3 || (int)val.chestType == 4;
					if ((!_drops.Contains(((Object)val).GetInstanceID()) && !flag) || !TypeOn(val.chestType))
					{
						_tracked.RemoveAt(num2);
					}
					else
					{
						Vector3 position2 = ((Component)val).transform.position;
						if (Vector3.Distance(position2, position) < 2.5f)
						{
							_tracked.RemoveAt(num2);
						}
						else
						{
							((Component)val).transform.position = Vector3.MoveTowards(position2, position, num);
						}
					}
				}
			}
			for (int num3 = _trackedOpen.Count - 1; num3 >= 0; num3--)
			{
				OpenChest val2 = _trackedOpen[num3];
				if ((Object)(object)val2 == (Object)null || (Object)(object)((Component)val2).gameObject == (Object)null)
				{
					_trackedOpen.RemoveAt(num3);
				}
				else if (!TypeOn(val2.chestType))
				{
					_trackedOpen.RemoveAt(num3);
				}
				else
				{
					Vector3 position3 = ((Component)val2).transform.position;
					if (Vector3.Distance(position3, position) < 2.5f)
					{
						_trackedOpen.RemoveAt(num3);
					}
					else
					{
						((Component)val2).transform.position = Vector3.MoveTowards(position3, position, num);
					}
				}
			}
		}
		catch
		{
		}
	}

	private static ItemSuckyHoof Hoof()
	{
		try
		{
			GameManager instance = GameManager.Instance;
			object obj;
			if (instance == null)
			{
				obj = null;
			}
			else
			{
				PlayerInventory playerInventory = instance.GetPlayerInventory();
				obj = ((playerInventory != null) ? playerInventory.itemInventory : null);
			}
			object result;
			if (obj == null)
			{
				result = null;
			}
			else
			{
				ItemBase item = ((ItemInventory)obj).GetItem((EItem)33);
				result = ((item != null) ? ((Il2CppObjectBase)item).TryCast<ItemSuckyHoof>() : null);
			}
			return (ItemSuckyHoof)result;
		}
		catch
		{
			return null;
		}
	}

	private unsafe static float HoofRadius()
	{
		try
		{
			ItemSuckyHoof val = Hoof();
			if (val == null)
			{
				return 0f;
			}
			return *(float*)(void*)(((Il2CppObjectBase)val).Pointer + 48);
		}
		catch
		{
			return 0f;
		}
	}

	private unsafe static bool SuckFired()
	{
		try
		{
			ItemSuckyHoof val = Hoof();
			if (val == null)
			{
				return false;
			}
			float num = *(float*)(void*)(((Il2CppObjectBase)val).Pointer + 56);
			if (num != _prevSuck)
			{
				_prevSuck = num;
				return true;
			}
			return false;
		}
		catch
		{
			return false;
		}
	}

	private static void Rescan(PlayerMovement pm)
	{
		//IL_0042: 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_00be: Unknown result type (might be due to invalid IL or missing references)
		//IL_0136: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ea: 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_015c: Unknown result type (might be due to invalid IL or missing references)
		_tracked.Clear();
		_trackedOpen.Clear();
		if (!_enabled.Value || !HasMagnet())
		{
			return;
		}
		float num = HoofRadius();
		if (num <= 0f)
		{
			num = 30f;
		}
		Vector3 position = ((Component)pm).transform.position;
		List<int> list = null;
		foreach (KeyValuePair<int, Object> item in _live)
		{
			Object value = item.Value;
			if (value == (Object)null)
			{
				(list ?? (list = new List<int>())).Add(item.Key);
				continue;
			}
			InteractableChest val = ((Il2CppObjectBase)value).TryCast<InteractableChest>();
			if ((Object)(object)val != (Object)null)
			{
				InteractableChest val2 = val;
				if ((Object)(object)((Component)val2).gameObject == (Object)null || !TypeOn(val2.chestType) || !((Component)val2).gameObject.activeInHierarchy || Vector3.Distance(((Component)val2).transform.position, position) > num)
				{
					continue;
				}
				SnapGround(((Component)val2).transform);
				_tracked.Add(val2);
			}
			OpenChest val3 = ((Il2CppObjectBase)value).TryCast<OpenChest>();
			if ((Object)(object)val3 != (Object)null)
			{
				OpenChest val4 = val3;
				if (!((Object)(object)((Component)val4).gameObject == (Object)null) && TypeOn(val4.chestType) && ((Component)val4).gameObject.activeInHierarchy && !(Vector3.Distance(((Component)val4).transform.position, position) > num))
				{
					SnapGround(((Component)val4).transform);
					_trackedOpen.Add(val4);
				}
			}
		}
		if (list == null)
		{
			return;
		}
		foreach (int item2 in list)
		{
			_live.Remove(item2);
		}
	}
}
internal static class ChestOddsTracker
{
	internal static bool Visible;

	private static readonly GuiWindowFrame _frame = new GuiWindowFrame(new Vector2(10f, 500f));

	private const float PadX = 10f;

	private const float LineH = 20f;

	private const float BaseW_V = 190f;

	private const float BaseH_V = 156f;

	private const float BaseW_H = 420f;

	private const float BaseH_H = 56f;

	private static bool _horizontal;

	private static ConfigEntry<bool> _cfgHoriz;

	private static readonly string[] TierNames = new string[4] { "Common", "Rare", "Epic", "Legendary" };

	private static readonly string[] TierAbbr = new string[4] { "C", "R", "E", "L" };

	private static readonly float[] BaseWeights = new float[4] { 70f, 15f, 6f, 1.5f };

	private static readonly float A = 1.5f;

	private static float[] _cachedWeights;

	private static float _cachedLuck = -1f;

	private static int _cachedKeys = -1;

	private static readonly StringBuilder _sb = new StringBuilder(64);

	private static string _cPrefix = "";

	private static readonly string[] _cSegs = new string[4];

	private static readonly GUIContent[] _cContents = (GUIContent[])(object)new GUIContent[5];

	private static readonly string[] _cVLines = new string[6];

	private static float WinW
	{
		get
		{
			if (!_horizontal)
			{
				return 190f;
			}
			return 420f;
		}
	}

	private static float WinH
	{
		get
		{
			if (!_horizontal)
			{
				return 156f;
			}
			return 56f;
		}
	}

	internal static void Init(ConfigFile cfg)
	{
		_frame.Init(cfg, "ChestOddsTracker");
		_cfgHoriz = cfg.Bind<bool>("ChestOddsTracker", "Horizontal", false, "Show chest odds in a single horizontal line.");
		_horizontal = _cfgHoriz.Value;
	}

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

	internal static void ResetFramePosition()
	{
		try
		{
			_frame.ResetPosition();
		}
		catch
		{
		}
	}

	internal static void HandleInput()
	{
		if (Visible)
		{
			_frame.HandleInput(WinW, WinH, 24f);
		}
	}

	private static Color RarityColor(int i)
	{
		//IL_0027: 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_003e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0043: Unknown result type (might be due to invalid IL or missing references)
		//IL_0055: Unknown result type (might be due to invalid IL or missing references)
		//IL_005a: Unknown result type (might be due to invalid IL or missing references)
		//IL_006c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0071: Unknown result type (might be due to invalid IL or missing references)
		//IL_0089: Unknown result type (might be due to invalid IL or missing references)
		//IL_0083: Unknown result type (might be due to invalid IL or missing references)
		//IL_0088: Unknown result type (might be due to invalid IL or missing references)
		return (Color)(i switch
		{
			0 => new Color(1f, 1f, 1f), 
			1 => new Color(0.4f, 0.8f, 1f), 
			2 => new Color(0.7f, 0.4f, 1f), 
			3 => new Color(1f, 0.85f, 0.2f), 
			_ => new Color(1f, 1f, 1f), 
		});
	}

	private static float[] CalculateWeights(float luck)
	{
		float num = Mathf.Log(luck + 1f) * 1.5f;
		float[] array = new float[4];
		for (int i = 0; i < 4; i++)
		{
			array[i] = BaseWeights[i] * Mathf.Pow(A, (0f - (3f - (float)i)) * num);
		}
		return array;
	}

	private static void RebuildText(float luckPct, float freeChest, float[] weights, float total)
	{
		//IL_0059: Unknown result type (might be due to invalid IL or missing references)
		//IL_005f: Expected O, but got Unknown
		//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ad: Expected O, but got Unknown
		_cPrefix = "Luck: " + luckPct.ToString("F0") + "%  Free: " + (freeChest * 100f).ToString("F0") + "%  ";
		_cContents[0] = new GUIContent(_cPrefix);
		for (int i = 0; i < 4; i++)
		{
			float num = weights[i] / total * 100f;
			_cSegs[i] = TierAbbr[i] + ": " + num.ToString("F1") + "%  ";
			_cContents[i + 1] = new GUIContent(_cSegs[i]);
		}
		_sb.Clear();
		_sb.Append("Luck: ");
		_sb.Append(luckPct.ToString("F0"));
		_sb.Append('%');
		_cVLines[0] = _sb.ToString();
		_sb.Clear();
		_sb.Append("Free Chest: ");
		_sb.Append((freeChest * 100f).ToString("F0"));
		_sb.Append('%');
		_cVLines[1] = _sb.ToString();
		for (int j = 0; j < weights.Length && j < 4; j++)
		{
			float num2 = weights[j] / total * 100f;
			_sb.Clear();
			_sb.Append(TierNames[j]);
			int num3 = 12 - TierNames[j].Length;
			while (num3-- > 0)
			{
				_sb.Append(' ');
			}
			_sb.Append(' ');
			_sb.Append(num2.ToString("F1"));
			_sb.Append('%');
			_cVLines[j + 2] = _sb.ToString();
		}
	}

	internal static void Draw()
	{
		//IL_03b8: Unknown result type (might be due to invalid IL or missing references)
		//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_0042: Unknown result type (might be due to invalid IL or missing references)
		//IL_0050: Unknown result type (might be due to invalid IL or missing references)
		//IL_03d8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0391: Unknown result type (might be due to invalid IL or missing references)
		//IL_036b: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
		//IL_0203: Unknown result type (might be due to invalid IL or missing references)
		//IL_020f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0220: Unknown result type (might be due to invalid IL or missing references)
		//IL_02da: Unknown result type (might be due to invalid IL or missing references)
		//IL_023b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0240: Unknown result type (might be due to invalid IL or missing references)
		//IL_0242: Unknown result type (might be due to invalid IL or missing references)
		//IL_0249: Unknown result type (might be due to invalid IL or missing references)
		//IL_0257: 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_027c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0303: Unknown result type (might be due to invalid IL or missing references)
		//IL_030a: Unknown result type (might be due to invalid IL or missing references)
		//IL_031f: Unknown result type (might be due to invalid IL or missing references)
		if (!Visible)
		{
			return;
		}
		float winW = WinW;
		float winH = WinH;
		Matrix4x4 old = _frame.Begin();
		float x = _frame.Pivot.x;
		float y = _frame.Pivot.y;
		UiTheme.Backdrop(new Rect(x, y, winW, winH));
		GUI.Box(new Rect(x, y, winW, winH), "Chest Rarity Odds");
		float num = winW - 20f;
		float num2 = x + 10f;
		float num3 = y + 20f + 4f;
		float num4 = 24f;
		string text = (_horizontal ? "V" : "H");
		if (GUI.Button(new Rect(x + winW - num4 - 4f, y + 2f, num4, 18f), text))
		{
			_horizontal = !_horizontal;
			_cfgHoriz.Value = _horizontal;
		}
		try
		{
			float stat = PlayerStats.GetStat((EStat)30);
			float luckPct = stat * 100f;
			int num5 = 0;
			try
			{
				GameManager instance = GameManager.Instance;
				object obj;
				if (instance == null)
				{
					obj = null;
				}
				else
				{
					PlayerInventory playerInventory = instance.GetPlayerInventory();
					obj = ((playerInventory != null) ? playerInventory.itemInventory : null);
				}
				ItemInventory val = (ItemInventory)obj;
				if (val != null)
				{
					num5 = val.GetAmount((EItem)0);
				}
			}
			catch
			{
			}
			float freeChest = ((num5 > 0) ? StatScaling.HyperbolicScaling(0.2f * (float)num5, 1f, 1f) : 0f);
			bool flag = stat != _cachedLuck || num5 != _cachedKeys;
			if (flag)
			{
				_cachedLuck = stat;
				_cachedKeys = num5;
				_cachedWeights = CalculateWeights(stat);
			}
			float[] cachedWeights = _cachedWeights;
			if (cachedWeights != null)
			{
				float num6 = 0f;
				for (int i = 0; i < cachedWeights.Length; i++)
				{
					num6 += cachedWeights[i];
				}
				if (num6 > 0f)
				{
					if (flag)
					{
						RebuildText(luckPct, freeChest, cachedWeights, num6);
					}
					if (_horizontal)
					{
						GUIStyle label = GUI.skin.label;
						float num7 = num2;
						Vector2 val2 = label.CalcSize(_cContents[0]);
						GUI.Label(new Rect(num7, num3, val2.x, 20f), _cPrefix);
						num7 += val2.x;
						for (int j = 0; j < 4; j++)
						{
							val2 = label.CalcSize(_cContents[j + 1]);
							Color color = GUI.color;
							GUI.color = RarityColor(j);
							GUI.Label(new Rect(num7, num3, val2.x, 20f), _cSegs[j]);
							GUI.color = color;
							num7 += val2.x;
						}
						num3 += 20f;
					}
					else
					{
						GUI.Label(new Rect(num2, num3, num, 20f), _cVLines[0] ?? "");
						num3 += 20f;
						GUI.Label(new Rect(num2, num3, num, 20f), _cVLines[1] ?? "");
						num3 += 20f;
						for (int k = 0; k < cachedWeights.Length && k < 4; k++)
						{
							Color color2 = GUI.color;
							GUI.color = RarityColor(k);
							GUI.Label(new Rect(num2, num3, num, 20f), _cVLines[k + 2] ?? "");
							GUI.color = color2;
							num3 += 20f;
						}
					}
				}
				else
				{
					GUI.Label(new Rect(num2, num3, num, 20f), "No data available");
					num3 += 20f;
				}
			}
			else
			{
				GUI.Label(new Rect(num2, num3, num, 20f), "No data available");
				num3 += 20f;
			}
		}
		catch
		{
			GUI.Label(new Rect(num2, num3, num, 20f), "Start a run first.");
			num3 += 20f;
		}
		_frame.End(old);
		_frame.DrawGrip(winW, winH);
	}
}
internal static class ColorPickerPopup
{
	private struct POINT
	{
		public int X;

		public int Y;
	}

	internal static bool Open;

	private static string _key;

	private static string _title;

	private static int _set;

	private static float _h;

	private static float _s;

	private static float _v;

	private static int _r;

	private static int _g;

	private static int _b;

	private static string _hex = "#FFFFFFFF";

	private static bool _dropArmed;

	private static bool _hsvMode = true;

	private static int _sel = -1;

	private static Texture2D _wheel;

	private static Texture2D _vbar;

	private static Texture2D _gHue;

	private static Texture2D _gSat;

	private static Texture2D _gVal;

	private static Texture2D _gR;

	private static Texture2D _gG;

	private static Texture2D _gB;

	private static int _gSatKey = -1;

	private static int _gValKey = -1;

	private static int _gRgbKey = -1;

	private static readonly string[] _bufs = new string[3] { "", "", "" };

	private static string _hexBuf = "";

	private static int _editIdx = -1;

	private const int WheelPx = 220;

	private static readonly Color RowFlat = new Color(0.23f, 0.23f, 0.23f, 1f);

	private static readonly Color RowSel = new Color(0.25f, 0.42f, 0.75f, 1f);

	private static readonly Color TabSel = new Color(0.3f, 0.5f, 0.9f, 1f);

	private static readonly Color TabBg = new Color(0.28f, 0.28f, 0.28f, 1f);

	private static GUIStyle _rightField;

	private static GUIStyle _tabText;

	private static int _cursor;

	private static bool _selAll;

	private static float _unblockAt = -1f;

	private static readonly List<Rect> _fieldRects = new List<Rect>();

	private static readonly List<Rect> _newRects = new List<Rect>();

	[DllImport("user32.dll")]
	private static extern IntPtr GetDC(IntPtr hWnd);

	[DllImport("user32.dll")]
	private static extern int ReleaseDC(IntPtr hWnd, IntPtr hDC);

	[DllImport("gdi32.dll")]
	private static extern uint GetPixel(IntPtr hdc, int x, int y);

	[DllImport("user32.dll")]
	private static extern bool GetCursorPos(out POINT lpPoint);

	internal static void OpenFor(string key, int set)
	{
		//IL_009e: 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)
		_key = ((key != null) ? key.ToLowerInvariant() : "chest");
		if (_key.EndsWith("outline"))
		{
			_key = _key.Substring(0, _key.Length - 7);
		}
		string text = MapIconSettings.ResolveAlias(_key);
		if (text != null)
		{
			_key = text;
		}
		_set = set;
		_title = ((set == 0) ? "Vanilla — " : "Outline — ") + _key;
		_sel = -1;
		_editIdx = -1;
		SetFromColor((_set == 0) ? MapIconSettings.GetVanillaColorForKey(_key) : MapIconSettings.GetOutlineColorForKey(_key));
		_dropArmed = false;
		Open = true;
		_unblockAt = -1f;
		NativeSettings.SetInputBlocked(blocked: true);
		try
		{
			Hotkeys.Capturing = true;
		}
		catch
		{
		}
	}

	internal static void Close(bool save)
	{
		Open = false;
		_dropArmed = false;
		_unblockAt = Time.realtimeSinceStartup + 0.25f;
		try
		{
			Hotkeys.Capturing = false;
		}
		catch
		{
		}
		if (save && _key != null)
		{
			if (_set == 0)
			{
				MapIconSettings.SetVanillaHex(_key, _hex);
			}
			else
			{
				MapIconSettings.SetOutlineHex(_key, _hex);
			}
			MapIconSettings.Save();
			NativeSettings.RepaintIconRow(_key);
			MapIconManager.RefreshAllScales();
		}
	}

	private static void SetFromColor(Color c)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_0021: Unknown result type (might be due to invalid IL or missing references)
		//IL_0042: Unknown result type (might be due to invalid IL or missing references)
		_r = Mathf.Clamp(Mathf.RoundToInt(c.r * 255f), 0, 255);
		_g = Mathf.Clamp(Mathf.RoundToInt(c.g * 255f), 0, 255);
		_b = Mathf.Clamp(Mathf.RoundToInt(c.b * 255f), 0, 255);
		RgbToHsv(_r, _g, _b, out _h, out _s, out _v);
		_hex = $"#{_r:X2}{_g:X2}{_b:X2}";
		RefreshBufs();
	}

	private static void ApplyLive()
	{
		_hex = $"#{_r:X2}{_g:X2}{_b:X2}";
		if (_set == 0)
		{
			MapIconSettings.SetVanillaHex(_key, _hex);
		}
		else
		{
			MapIconSettings.SetOutlineHex(_key, _hex);
		}
		MapIconManager.RefreshAllScales();
		RefreshBufs();
	}

	private static void ApplyDefault()
	{
		//IL_0072: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			string text = MapIconSettings.GetDefaultHex(_key);
			if (string.IsNullOrEmpty(text))
			{
				text = "#FFFFFF";
			}
			if (!string.IsNullOrEmpty(text) && TryParseHex(text, out var r, out var g, out var b, out var _))
			{
				_r = r;
				_g = g;
				_b = b;
				RgbToHsv(_r, _g, _b, out _h, out _s, out _v);
				ApplyLive();
			}
			else
			{
				Toast.Show("No baked default for this icon.", Color.yellow);
			}
		}
		catch
		{
		}
	}

	private static float DispVal(bool hsv, int i)
	{
		if (hsv)
		{
			return i switch
			{
				1 => _s, 
				0 => _h, 
				_ => _v, 
			};
		}
		return (float)(i switch
		{
			1 => _g, 
			0 => _r, 
			_ => _b, 
		}) / 255f;
	}

	private static void SetRow(bool hsv, int i, float f)
	{
		if (f > 0.995f)
		{
			f = 1f;
		}
		else if (f < 0.005f)
		{
			f = 0f;
		}
		if (hsv)
		{
			f = Mathf.Clamp01(f);
			switch (i)
			{
			case 0:
				_h = f;
				break;
			case 1:
				_s = f;
				break;
			default:
				_v = f;
				break;
			}
			HsvToRgb(_h, _s, _v, out _r, out _g, out _b);
		}
		else
		{
			int num = Mathf.Clamp(Mathf.RoundToInt(f * 255f), 0, 255);
			switch (i)
			{
			case 0:
				_r = num;
				break;
			case 1:
				_g = num;
				break;
			default:
				_b = num;
				break;
			}
			RgbToHsv(_r, _g, _b, out _h, out _s, out _v);
		}
		_sel = i;
		ApplyLive();
	}

	private static void RefreshBufs()
	{
		for (int i = 0; i < 3; i++)
		{
			if (_editIdx != i)
			{
				_bufs[i] = (_hsvMode ? DispVal(hsv: true, i).ToString("F3", CultureInfo.InvariantCulture) : (i switch
				{
					1 => _g, 
					0 => _r, 
					_ => _b, 
				}).ToString());
			}
		}
		if (_editIdx != 3)
		{
			_hexBuf = _hex;
		}
	}

	private static void RgbToHsv(int r, int g, int b, out float h, out float s, out float v)
	{
		float num = (float)r / 255f;
		float num2 = (float)g / 255f;
		float num3 = (float)b / 255f;
		float num4 = Mathf.Max(num, Mathf.Max(num2, num3));
		float num5 = Mathf.Min(num, Mathf.Min(num2, num3));
		v = num4;
		float num6 = num4 - num5;
		s = ((num4 <= 0f) ? 0f : (num6 / num4));
		if (num6 <= 0f)
		{
			h = 0f;
			return;
		}
		if (num4 == num)
		{
			h = (num2 - num3) / num6 + ((num2 < num3) ? 6f : 0f);
		}
		else if (num4 == num2)
		{
			h = (num3 - num) / num6 + 2f;
		}
		else
		{
			h = (num - num2) / num6 + 4f;
		}
		h /= 6f;
	}

	private static void HsvToRgb(float h, float s, float v, out int r, out int g, out int b)
	{
		h -= Mathf.Floor(h);
		float num = v * s;
		float num2 = num * (1f - Mathf.Abs(h * 6f % 2f - 1f));
		float num3 = v - num;
		float num4 = 0f;
		float num5 = 0f;
		float num6 = 0f;
		float num7 = h * 6f;
		if (num7 < 1f)
		{
			num4 = num;
			num5 = num2;
		}
		else if (num7 < 2f)
		{
			num4 = num2;
			num5 = num;
		}
		else if (num7 < 3f)
		{
			num5 = num;
			num6 = num2;
		}
		else if (num7 < 4f)
		{
			num5 = num2;
			num6 = num;
		}
		else if (num7 < 5f)
		{
			num4 = num2;
			num6 = num;
		}
		else
		{
			num4 = num;
			num6 = num2;
		}
		r = Mathf.Clamp(Mathf.RoundToInt((num4 + num3) * 255f), 0, 255);
		g = Mathf.Clamp(Mathf.RoundToInt((num5 + num3) * 255f), 0, 255);
		b = Mathf.Clamp(Mathf.RoundToInt((num6 + num3) * 255f), 0, 255);
	}

	private static bool TryParseHex(string t, out int r, out int g, out int b, out int a)
	{
		r = (g = (b = 255));
		a = 255;
		try
		{
			t = t.Trim().TrimStart('#');
			if (t.Length != 6 && t.Length != 8)
			{
				return false;
			}
			r = Convert.ToInt32(t.Substring(0, 2), 16);
			g = Convert.ToInt32(t.Substring(2, 2), 16);
			b = Convert.ToInt32(t.Substring(4, 2), 16);
			if (t.Length == 8)
			{
				a = Convert.ToInt32(t.Substring(6, 2), 16);
			}
			return true;
		}
		catch
		{
			return false;
		}
	}

	private static Texture2D MkTex(int w, int h)
	{
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		//IL_000a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0012: Unknown result type (might be due to invalid IL or missing references)
		//IL_0019: Unknown result type (might be due to invalid IL or missing references)
		//IL_0021: Expected O, but got Unknown
		return new Texture2D(w, h, (TextureFormat)4, false, false)
		{
			hideFlags = (HideFlags)61,
			filterMode = (FilterMode)0,
			wrapMode = (TextureWrapMode)1
		};
	}

	private static Texture2D Wheel()
	{
		//IL_0115: Unknown result type (might be due to invalid IL or missing references)
		//IL_011a: 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)
		if ((Object)(object)_wheel != (Object)null)
		{
			return _wheel;
		}
		int num = 220;
		Texture2D val = MkTex(num, num);
		Color32[] array = (Color32[])(object)new Color32[num * num];
		for (int i = 0; i < num; i++)
		{
			for (int j = 0; j < num; j++)
			{
				float num2 = ((float)j - (float)num / 2f + 0.5f) / ((float)num / 2f);
				float num3 = ((float)num / 2f - (float)i - 0.5f) / ((float)num / 2f);
				float num4 = Mathf.Sqrt(num2 * num2 + num3 * num3);
				if (num4 <= 1f)
				{
					float num5 = Mathf.Atan2(num3, num2) / ((float)Math.PI * 2f);
					if (num5 < 0f)
					{
						num5 += 1f;
					}
					HsvToRgb(num5, num4, 1f, out var r, out var g, out var b);
					byte b2 = ((num4 > 0.94f) ? ((byte)((1f - num4) / 0.06f * 255f)) : byte.MaxValue);
					array[i * num + j] = new Color32((byte)r, (byte)g, (byte)b, b2);
				}
				else
				{
					array[i * num + j] = new Color32((byte)0, (byte)0, (byte)0, (byte)0);
				}
			}
		}
		val.SetPixels32(Il2CppStructArray<Color32>.op_Implicit(array));
		val.Apply(false, true);
		_wheel = val;
		return val;
	}

	private static Texture2D VBar()
	{
		//IL_0059: 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)
		if ((Object)(object)_vbar != (Object)null)
		{
			return _vbar;
		}
		int num = 24;
		int num2 = 220;
		Texture2D val = MkTex(num, num2);
		Color32[] array = (Color32[])(object)new Color32[num * num2];
		for (int i = 0; i < num2; i++)
		{
			byte b = (byte)(i * 255 / (num2 - 1));
			for (int j = 0; j < num; j++)
			{
				array[i * num + j] = new Color32(b, b, b, byte.MaxValue);
			}
		}
		val.SetPixels32(Il2CppStructArray<Color32>.op_Implicit(array));
		val.Apply(false, true);
		_vbar = val;
		return val;
	}

	private static Texture2D GradBar(ref Texture2D t, Func<float, Color32> fn)
	{
		//IL_0031: Unknown result type (might be due to invalid IL or missing references)
		//IL_0036: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)t == (Object)null)
		{
			t = MkTex(128, 1);
		}
		Color32[] array = (Color32[])(object)new Color32[128];
		for (int i = 0; i < 128; i++)
		{
			array[i] = fn((float)i / 127f);
		}
		t.SetPixels32(Il2CppStructArray<Color32>.op_Implicit(array));
		t.Apply(false, false);
		return t;
	}

	private static Texture2D RowGrad(bool hsv, int i)
	{
		if (!hsv)
		{
			int num = (_r << 16) | (_g << 8) | _b;
			if ((Object)(object)_gR == (Object)null || (Object)(object)_gG == (Object)null || (Object)(object)_gB == (Object)null || num != _gRgbKey)
			{
				_gRgbKey = num;
				int r = _r;
				int g = _g;
				int b = _b;
				GradBar(ref _gR, (float f) => new Color32((byte)(f * 255f), (byte)g, (byte)b, byte.MaxValue));
				GradBar(ref _gG, (float f) => new Color32((byte)r, (byte)(f * 255f), (byte)b, byte.MaxValue));
				GradBar(ref _gB, (float f) => new Color32((byte)r, (byte)g, (byte)(f * 255f), byte.MaxValue));
			}
			return (Texture2D)(i switch
			{
				1 => _gG, 
				0 => _gR, 
				_ => _gB, 
			});
		}
		switch (i)
		{
		case 0:
			if ((Object)(object)_gHue == (Object)null)
			{
				GradBar(ref _gHue, delegate(float f)
				{
					//IL_0021: Unknown result type (might be due to invalid IL or missing references)
					HsvToRgb(f, 1f, 1f, out var r2, out var g2, out var b2);
					return new Color32((byte)r2, (byte)g2, (byte)b2, byte.MaxValue);
				});
			}
			return _gHue;
		case 1:
		{
			int num3 = (Mathf.RoundToInt(_h * 255f) << 16) | (Mathf.RoundToInt(_v * 255f) << 8);
			if ((Object)(object)_gSat == (Object)null || num3 != _gSatKey)
			{
				_gSatKey = num3;
				float h2 = _h;
				float v = _v;
				GradBar(ref _gSat, delegate(float f)
				{
					//IL_0023: Unknown result type (might be due to invalid IL or missing references)
					HsvToRgb(h2, f, v, out var r2, out var g2, out var b2);
					return new Color32((byte)r2, (byte)g2, (byte)b2, byte.MaxValue);
				});
			}
			return _gSat;
		}
		default:
		{
			int num2 = (Mathf.RoundToInt(_h * 255f) << 16) | (Mathf.RoundToInt(_s * 255f) << 8);
			if ((Object)(object)_gVal == (Object)null || num2 != _gValKey)
			{
				_gValKey = num2;
				float h = _h;
				float s = _s;
				GradBar(ref _gVal, delegate(float f)
				{
					//IL_0023: Unknown result type (might be due to invalid IL or missing references)
					HsvToRgb(h, s, f, out var r2, out var g2, out var b2);
					return new Color32((byte)r2, (byte)g2, (byte)b2, byte.MaxValue);
				});
			}
			return _gVal;
		}
		}
	}

	private static bool TryPickScreen(Vector2 guiPos, out Color c)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_010c: 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_00a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e4: 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_0082: 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)
		c = Color.white;
		try
		{
			if (GetCursorPos(out var lpPoint))
			{
				IntPtr dC = GetDC(IntPtr.Zero);
				if (dC != IntPtr.Zero)
				{
					uint pixel = GetPixel(dC, lpPoint.X, lpPoint.Y);
					ReleaseDC(IntPtr.Zero, dC);
					if (pixel != uint.MaxValue)
					{
						c = new Color((float)(pixel & 0xFF) / 255f, (float)((pixel >> 8) & 0xFF) / 255f, (float)((pixel >> 16) & 0xFF) / 255f);
						return true;
					}
				}
			}
		}
		catch
		{
		}
		try
		{
			int num = (int)guiPos.x;
			int num2 = Screen.height - (int)guiPos.y;
			Texture2D val = MkTex(1, 1);
			val.ReadPixels(new Rect((float)num, (float)num2, 1f, 1f), 0, 0);
			val.Apply();
			c = val.GetPixel(0, 0);
			Object.Destroy((Object)(object)val);
			return true;
		}
		catch (Exception ex)
		{
			Toast.Show("Dropper unsupported: " + ex.Message, Color.red);
			return false;
		}
	}

	private static void Box(Rect r, Color c)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_0006: 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)
		GUI.color = c;
		GUI.DrawTexture(r, (Texture)(object)Texture2D.whiteTexture);
		GUI.color = Color.white;
	}

	private static void Field(Rect r, int idx, Func<string> get, Action<string> set)
	{
		//IL_04b2: Unknown result type (might be due to invalid IL or missing references)
		//IL_04b7: Unknown result type (might be due to invalid IL or missing references)
		//IL_001a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0021: Invalid comparison between Unknown and I4
		//IL_002a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0062: Unknown result type (might be due to invalid IL or missing references)
		//IL_0047: Unknown result type (might be due to invalid IL or missing references)
		//IL_0407: Unknown result type (might be due to invalid IL or missing references)
		//IL_03bc: Unknown result type (might be due to invalid IL or missing references)
		//IL_03d5: 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_0450: Unknown result type (might be due to invalid IL or missing references)
		//IL_045a: Expected O, but got Unknown
		//IL_0455: 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_00cd: Invalid comparison between Unknown and I4
		//IL_0085: 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_010c: Unknown result type (might be due to invalid IL or missing references)
		//IL_010f: Invalid comparison between Unknown and I4
		//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ff: Invalid comparison between Unknown and I4
		//IL_015a: Unknown result type (might be due to invalid IL or missing references)
		//IL_015e: Invalid comparison between Unknown and I4
		//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a7: Invalid comparison between Unknown and I4
		//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c7: Invalid comparison between Unknown and I4
		//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e7: Invalid comparison between Unknown and I4
		//IL_01fa: Unknown result type (might be due to invalid IL or missing references)
		//IL_0201: Invalid comparison between Unknown and I4
		//IL_0221: Unknown result type (might be due to invalid IL or missing references)
		//IL_0225: Invalid comparison between Unknown and I4
		//IL_0240: Unknown result type (might be due to invalid IL or missing references)
		//IL_0244: Invalid comparison between Unknown and I4
		//IL_0270: Unknown result type (might be due to invalid IL or missing references)
		//IL_0274: Invalid comparison between Unknown and I4
		string text = get() ?? "";
		Event current = Event.current;
		bool flag = current == null || (int)current.type != 12;
		Box(r, (_editIdx == idx) ? new Color(0.12f, 0.12f, 0.16f, 1f) : new Color(0.05f, 0.05f, 0.05f, 1f));
		if (flag && current != null && (int)current.type == 0 && current.button == 0 && ((Rect)(ref r)).Contains(current.mousePosition))
		{
			_editIdx = idx;
			_cursor = text.Length;
			_selAll = true;
			current.Use();
			return;
		}
		if (flag && _editIdx == idx && current != null && (int)current.type == 4)
		{
			KeyCode keyCode = current.keyCode;
			bool flag2 = true;
			_cursor = Mathf.Clamp(_cursor, 0, text.Length);
			if (current.control && (int)keyCode == 97)
			{
				_selAll = true;
			}
			else if ((int)keyCode == 8)
			{
				if (_selAll)
				{
					text = "";
					_cursor = 0;
					_selAll = false;
				}
				else if (_cursor > 0)
				{
					text = text.Remove(_cursor - 1, 1);
					_cursor--;
				}
			}
			else if ((int)keyCode == 127)
			{
				if (_selAll)
				{
					text = "";
					_cursor = 0;
					_selAll = false;
				}
				else if (_cursor < text.Length)
				{
					text = text.Remove(_cursor, 1);
				}
			}
			else if ((int)keyCode == 276)
			{
				_cursor--;
				_selAll = false;
			}
			else if ((int)keyCode == 275)
			{
				_cursor++;
				_selAll = false;
			}
			else if ((int)keyCode == 278)
			{
				_cursor = 0;
				_selAll = false;
			}
			else if ((int)keyCode == 279)
			{
				_cursor = text.Length;
				_selAll = false;
			}
			else if (current.control && (int)keyCode == 99)
			{
				try
				{
					GUIUtility.systemCopyBuffer = text;
				}
				catch
				{
				}
			}
			else if (current.control && (int)keyCode == 120)
			{
				try
				{
					GUIUtility.systemCopyBuffer = text;
				}
				catch
				{
				}
				text = "";
				_cursor = 0;
				_selAll = false;
			}
			else if (current.control && (int)keyCode == 118)
			{
				string text2 = "";
				try
				{
					text2 = GUIUtility.systemCopyBuffer;
				}
				catch
				{
				}
				if (!string.IsNullOrEmpty(text2))
				{
					if (_selAll)
					{
						text = text2;
						_cursor = text2.Length;
						_selAll = false;
					}
					else
					{
						text = text.Insert(_cursor, text2);
						_cursor += text2.Length;
					}
				}
			}
			else if (current.character >= ' ' && current.character != '\u007f')
			{
				if (_selAll)
				{
					text = current.character.ToString();
					_cursor = 1;
					_selAll = false;
				}
				else
				{
					text = text.Insert(_cursor, current.character.ToString());
					_cursor++;
				}
			}
			else
			{
				flag2 = false;
			}
			_cursor = Mathf.Clamp(_cursor, 0, text.Length);
			if (flag2)
			{
				set(text);
				current.Use();
				return;
			}
		}
		GUIStyle val = _rightField ?? GUI.skin.label;
		if (_editIdx == idx && _selAll)
		{
			Box(new Rect(((Rect)(ref r)).x + 2f, ((Rect)(ref r)).y + 2f, ((Rect)(ref r)).width - 4f, ((Rect)(ref r)).height - 4f), new Color(0.25f, 0.42f, 0.75f, 0.55f));
		}
		GUI.Label(new Rect(((Rect)(ref r)).x + 4f, ((Rect)(ref r)).y, ((Rect)(ref r)).width - 8f, ((Rect)(ref r)).height), text, val);
		if (_editIdx == idx && !_selAll && Time.realtimeSinceStartup % 1f < 0.6f)
		{
			float num = 0f;
			try
			{
				num = val.CalcSize(new GUIContent(text.Substring(_cursor))).x;
			}
			catch
			{
				num = (float)(text.Length - _cursor) * 8f;
			}
			Box(new Rect(((Rect)(ref r)).x + ((Rect)(ref r)).width - 6f - num, ((Rect)(ref r)).y + 4f, 1f, ((Rect)(ref r)).height - 8f), Color.white);
		}
	}

	internal static void Draw()
	{
		//IL_0afa: Unknown result type (might be due to invalid IL or missing references)
		//IL_0041: Unknown result type (might be due to invalid IL or missing references)
		//IL_004b: Expected O, but got Unknown
		//IL_010f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0114: Unknown result type (might be due to invalid IL or missing references)
		//IL_0115: 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_0074: Expected O, but got Unknown
		//IL_00be: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
		//IL_0160: Unknown result type (might be due to invalid IL or missing references)
		//IL_0176: 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_01c5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0298: Unknown result type (might be due to invalid IL or missing references)
		//IL_030e: 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_044f: Unknown result type (might be due to invalid IL or missing references)
		//IL_049a: Unknown result type (might be due to invalid IL or missing references)
		//IL_049f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0326: Unknown result type (might be due to invalid IL or missing references)
		//IL_058f: Unknown result type (might be due to invalid IL or missing references)
		//IL_05b1: Unknown result type (might be due to invalid IL or missing references)
		//IL_04b2: Unknown result type (might be due to invalid IL or missing references)
		//IL_032f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0335: Invalid comparison between Unknown and I4
		//IL_0202: Unknown result type (might be due to invalid IL or missing references)
		//IL_05d1: Unknown result type (might be due to invalid IL or missing references)
		//IL_05ca: Unknown result type (might be due to invalid IL or missing references)
		//IL_04bb: Unknown result type (might be due to invalid IL or missing references)
		//IL_04c1: Invalid comparison between Unknown and I4
		//IL_034a: Unknown result type (might be due to invalid IL or missing references)
		//IL_05db: Unknown result type (might be due to invalid IL or missing references)
		//IL_04d6: Unknown result type (might be due to invalid IL or missing references)
		//IL_035b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0377: Unknown result type (might be due to invalid IL or missing references)
		//IL_05fc: Unknown result type (might be due to invalid IL or missing references)
		//IL_05f5: Unknown result type (might be due to invalid IL or missing references)
		//IL_04e9: Unknown result type (might be due to invalid IL or missing references)
		//IL_0221: Unknown result type (might be due to invalid IL or missing references)
		//IL_0226: Unknown result type (might be due to invalid IL or missing references)
		//IL_022c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0628: Unknown result type (might be due to invalid IL or missing references)
		//IL_0706: Unknown result type (might be due to invalid IL or missing references)
		//IL_08c9: Unknown result type (might be due to invalid IL or missing references)
		//IL_0925: Unknown result type (might be due to invalid IL or missing references)
		//IL_094f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0718: Unknown result type (might be due to invalid IL or missing references)
		//IL_0711: Unknown result type (might be due to invalid IL or missing references)
		//IL_09b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_07c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_07d9: Unknown result type (might be due to invalid IL or missing references)
		//IL_081a: Unknown result type (might be due to invalid IL or missing references)
		//IL_081f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0847: Unknown result type (might be due to invalid IL or missing references)
		//IL_085b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0874: Unknown result type (might be due to invalid IL or missing references)
		//IL_0728: Unknown result type (might be due to invalid IL or missing references)
		//IL_09e7: Unknown result type (might be due to invalid IL or missing references)
		//IL_0731: Unknown result type (might be due to invalid IL or missing references)
		//IL_0737: Invalid comparison between Unknown and I4
		//IL_0746: Unknown result type (might be due to invalid IL or missing references)
		//IL_0758: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a6f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a75: Invalid comparison between Unknown and I4
		//IL_0a20: Unknown result type (might be due to invalid IL or missing references)
		//IL_0ac5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a79: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a80: Invalid comparison between Unknown and I4
		//IL_0aa9: Unknown result type (might be due to invalid IL or missing references)
		//IL_0ab0: Invalid comparison between Unknown and I4
		//IL_0a84: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a8b: Invalid comparison between Unknown and I4
		//IL_0a34: Unknown result type (might be due to invalid IL or missing references)
		//IL_0ad9: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a8f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a99: Invalid comparison between Unknown and I4
		//IL_0a42: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a50: Unknown result type (might be due to invalid IL or missing references)
		if (_unblockAt > 0f && Time.realtimeSinceStartup >= _unblockAt)
		{
			_unblockAt = -1f;
			NativeSettings.SetInputBlocked(blocked: false);
		}
		if (!Open)
		{
			return;
		}
		if (_rightField == null)
		{
			_rightField = new GUIStyle(GUI.skin.textField);
			_rightField.alignment = (TextAnchor)5;
		}
		if (_tabText == null)
		{
			_tabText = new GUIStyle(GUI.skin.button);
			_tabText.normal.background = null;
			_tabText.hover.background = null;
			_tabText.active.background = null;
			_tabText.focused.background = null;
			_tabText.normal.textColor = Color.white;
			_tabText.hover.textColor = Color.white;
			_tabText.active.textColor = Color.white;
			_tabText.focused.textColor = Color.white;
			_tabText.alignment = (TextAnchor)4;
		}
		Matrix4x4 matrix = GUI.matrix;
		GUI.matrix = Matrix4x4.identity;
		try
		{
			float num = 300f;
			float num2 = 454f;
			float num3 = Mathf.Round(((float)Screen.width - num) / 2f);
			float num4 = Mathf.Round(((float)Screen.height - num2) / 2f);
			Rect r = default(Rect);
			((Rect)(ref r))..ctor(num3, num4, num, num2);
			Box(r, new Color(0.07f, 0.07f, 0.07f, 0.97f));
			GUI.Label(new Rect(num3 + 10f, num4 + 6f, num - 80f, 24f), _title);
			if (GUI.Button(new Rect(num3 + num - 34f, num4 + 4f, 28f, 24f), "X"))
			{
				Close(save: true);
				return;
			}
			Event current = Event.current;
			if (current != null && (int)current.type == 0 && current.button == 0 && ((Rect)(ref r)).Contains(current.mousePosition))
			{
				bool flag = false;
				foreach (Rect fieldRect in _fieldRects)
				{
					Rect current2 = fieldRect;
					if (((Rect)(ref current2)).Contains(current.mouseP