Decompiled source of AutoUpgradeForked v1.4.0

AutoUpgrade.dll

Decompiled 2 weeks ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Text.Json;
using Assets.Scripts.Inventory__Items__Pickups;
using Assets.Scripts.Saves___Serialization.Progression.Achievements;
using Assets.Scripts.Saves___Serialization.Progression.Unlocks;
using AutoUpgradeMod.Core;
using AutoUpgradeMod.Models;
using AutoUpgradeMod.UI;
using AutoUpgradeMod.Utils;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using HarmonyLib;
using Il2CppInterop.Runtime.Injection;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSystem.Collections.Generic;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace AutoUpgradeMod
{
	[BepInPlugin("anro_AutoUpgrade", "AutoUpgrade", "1.4.0")]
	public class Plugin : BasePlugin
	{
		[HarmonyPatch(typeof(UpgradePicker), "ShuffleUpgrades")]
		public class UpgradePicker_ShuffleUpgrades_Patch
		{
			private static void Postfix(UpgradePicker __instance)
			{
				//IL_0013: Unknown result type (might be due to invalid IL or missing references)
				//IL_0019: Expected O, but got Unknown
				try
				{
					AutoUpgradeUI.QueueAutoSelection(__instance);
				}
				catch (Exception ex)
				{
					ManualLogSource log = Log;
					bool flag = default(bool);
					BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(30, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Error queuing auto-selection: ");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
					}
					log.LogError(val);
				}
			}
		}

		[HarmonyPatch(typeof(DeathScreen), "GoToMenu")]
		public class DeathScreen_GoToMenu_Patch
		{
			private static void Prefix()
			{
				//IL_0024: Unknown result type (might be due to invalid IL or missing references)
				//IL_002a: Expected O, but got Unknown
				try
				{
					if ((Object)(object)AutoUpgradeUI.Instance != (Object)null)
					{
						AutoUpgradeUI.Instance.ClearNotifications();
					}
				}
				catch (Exception ex)
				{
					ManualLogSource log = Plugin.log;
					bool flag = default(bool);
					BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(22, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("GoToMenu patch error: ");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
					}
					log.LogError(val);
				}
			}
		}

		[HarmonyPatch(typeof(PauseUi), "Restart")]
		public class PauseUi_Restart_Patch
		{
			private static void Prefix()
			{
				//IL_0024: Unknown result type (might be due to invalid IL or missing references)
				//IL_002a: Expected O, but got Unknown
				try
				{
					if ((Object)(object)AutoUpgradeUI.Instance != (Object)null)
					{
						AutoUpgradeUI.Instance.ClearNotifications();
					}
				}
				catch (Exception ex)
				{
					ManualLogSource log = Plugin.log;
					bool flag = default(bool);
					BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(21, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Restart patch error: ");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
					}
					log.LogError(val);
				}
			}
		}

		public const string MODNAME = "AutoUpgrade";

		public const string AUTHOR = "anro";

		public const string GUID = "anro_AutoUpgrade";

		public const string VERSION = "1.4.0";

		private const string LEGACY_CONFIG_FILE_NAME = "anro_AutoUpgrade.cfg";

		private const string CONFIG_FILE_NAME = "EDGE_AutoUpgrade.cfg";

		private static ManualLogSource log;

		private static Harmony harmony;

		public static ManualLogSource Log => log;

		public Plugin()
		{
			log = ((BasePlugin)this).Log;
		}

		public override void Load()
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Expected O, but got Unknown
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Expected O, but got Unknown
			ManualLogSource obj = log;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(14, 3, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Loading ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("AutoUpgrade");
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" v");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("1.4.0");
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" by ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("anro");
			}
			obj.LogInfo(val);
			ConfigFile configFile = CreatePluginConfig();
			PriorityManager.Initialize(Log);
			ConfigManager.Initialize(configFile, Log);
			AutoSelector.Initialize(Log);
			ConfigManager.LoadPriorityList();
			ClassInjector.RegisterTypeInIl2Cpp<AutoUpgradeUI>();
			AutoUpgradeUI.Initialize(Log);
			((BasePlugin)this).AddComponent<AutoUpgradeUI>();
			harmony = new Harmony("anro_AutoUpgrade");
			harmony.PatchAll();
			ManualLogSource obj2 = log;
			val = new BepInExInfoLogInterpolatedStringHandler(47, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Plugin ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("anro_AutoUpgrade");
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" is loaded with unified priority system!");
			}
			obj2.LogInfo(val);
		}

		private static ConfigFile CreatePluginConfig()
		{
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Expected O, but got Unknown
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Expected O, but got Unknown
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Expected O, but got Unknown
			string text = Path.Combine(Paths.ConfigPath, "EDGE_AutoUpgrade.cfg");
			string text2 = Path.Combine(Paths.ConfigPath, "anro_AutoUpgrade.cfg");
			bool flag = default(bool);
			try
			{
				if (!File.Exists(text) && File.Exists(text2))
				{
					File.Copy(text2, text);
					ManualLogSource val = log;
					if (val != null)
					{
						BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(25, 2, ref flag);
						if (flag)
						{
							((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Migrated config from ");
							((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>("anro_AutoUpgrade.cfg");
							((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" to ");
							((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>("EDGE_AutoUpgrade.cfg");
						}
						val.LogInfo(val2);
					}
				}
			}
			catch (Exception ex)
			{
				ManualLogSource val = log;
				if (val != null)
				{
					BepInExWarningLogInterpolatedStringHandler val3 = new BepInExWarningLogInterpolatedStringHandler(36, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("Failed to migrate config file name: ");
						((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(ex.Message);
					}
					val.LogWarning(val3);
				}
			}
			return new ConfigFile(text, true);
		}
	}
}
namespace AutoUpgradeMod.Utils
{
	public static class StyleHelper
	{
		private static GUIStyle _menuBox;

		private static GUIStyle _sectionBox;

		private static GUIStyle _headerLabel;

		private static GUIStyle _itemLabel;

		private static GUIStyle _button;

		private static GUIStyle _smallButton;

		private static GUIStyle _disabledButton;

		private static GUIStyle _windowStyle;

		private static GUIStyle _toggleStyle;

		private static GUIStyle _textField;

		public static GUIStyle MenuBox
		{
			get
			{
				//IL_0011: Unknown result type (might be due to invalid IL or missing references)
				//IL_001b: Expected O, but got Unknown
				//IL_0020: Unknown result type (might be due to invalid IL or missing references)
				//IL_0025: Unknown result type (might be due to invalid IL or missing references)
				//IL_002d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0035: Unknown result type (might be due to invalid IL or missing references)
				//IL_003d: Unknown result type (might be due to invalid IL or missing references)
				//IL_004a: Expected O, but got Unknown
				//IL_006a: Unknown result type (might be due to invalid IL or missing references)
				if (_menuBox == null)
				{
					_menuBox = new GUIStyle(GUI.skin.box);
					_menuBox.padding = new RectOffset
					{
						left = 15,
						right = 15,
						top = 15,
						bottom = 15
					};
					_menuBox.normal.background = MakeTex(2, 2, new Color(0.2f, 0.2f, 0.2f, 1f));
				}
				return _menuBox;
			}
		}

		public static GUIStyle SectionBox
		{
			get
			{
				//IL_0014: Unknown result type (might be due to invalid IL or missing references)
				//IL_001e: Expected O, but got Unknown
				//IL_0023: Unknown result type (might be due to invalid IL or missing references)
				//IL_0028: Unknown result type (might be due to invalid IL or missing references)
				//IL_0030: 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_0040: Unknown result type (might be due to invalid IL or missing references)
				//IL_004d: Expected O, but got Unknown
				//IL_0052: Unknown result type (might be due to invalid IL or missing references)
				//IL_0057: Unknown result type (might be due to invalid IL or missing references)
				//IL_005e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0065: Unknown result type (might be due to invalid IL or missing references)
				//IL_006c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0078: Expected O, but got Unknown
				//IL_0098: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
				//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d2: Expected O, but got Unknown
				if (_sectionBox == null)
				{
					_sectionBox = new GUIStyle(GUI.skin.box);
					_sectionBox.padding = new RectOffset
					{
						left = 10,
						right = 10,
						top = 10,
						bottom = 10
					};
					_sectionBox.margin = new RectOffset
					{
						left = 0,
						right = 0,
						top = 5,
						bottom = 5
					};
					_sectionBox.normal.background = MakeTex(2, 2, new Color(0.15f, 0.15f, 0.15f, 1f));
					_sectionBox.border = new RectOffset
					{
						left = 2,
						right = 2,
						top = 2,
						bottom = 2
					};
				}
				return _sectionBox;
			}
		}

		public static GUIStyle HeaderLabel
		{
			get
			{
				//IL_0014: Unknown result type (might be due to invalid IL or missing references)
				//IL_001e: Expected O, but got Unknown
				//IL_004e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0068: Unknown result type (might be due to invalid IL or missing references)
				//IL_006d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0074: Unknown result type (might be due to invalid IL or missing references)
				//IL_007b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0082: Unknown result type (might be due to invalid IL or missing references)
				//IL_008e: Expected O, but got Unknown
				if (_headerLabel == null)
				{
					_headerLabel = new GUIStyle(GUI.skin.label);
					_headerLabel.fontSize = 14;
					_headerLabel.fontStyle = (FontStyle)1;
					_headerLabel.normal.textColor = new Color(1f, 0.92f, 0.016f);
					_headerLabel.alignment = (TextAnchor)3;
					_headerLabel.padding = new RectOffset
					{
						left = 5,
						right = 5,
						top = 5,
						bottom = 5
					};
				}
				return _headerLabel;
			}
		}

		public static GUIStyle ItemLabel
		{
			get
			{
				//IL_0011: Unknown result type (might be due to invalid IL or missing references)
				//IL_001b: Expected O, but got Unknown
				//IL_0031: Unknown result type (might be due to invalid IL or missing references)
				//IL_004b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0050: Unknown result type (might be due to invalid IL or missing references)
				//IL_0057: Unknown result type (might be due to invalid IL or missing references)
				//IL_005e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0065: Unknown result type (might be due to invalid IL or missing references)
				//IL_0071: Expected O, but got Unknown
				if (_itemLabel == null)
				{
					_itemLabel = new GUIStyle(GUI.skin.label);
					_itemLabel.fontSize = 12;
					_itemLabel.normal.textColor = Color.white;
					_itemLabel.alignment = (TextAnchor)3;
					_itemLabel.padding = new RectOffset
					{
						left = 5,
						right = 5,
						top = 2,
						bottom = 2
					};
				}
				return _itemLabel;
			}
		}

		public static GUIStyle Button
		{
			get
			{
				//IL_0014: Unknown result type (might be due to invalid IL or missing references)
				//IL_001e: Expected O, but got Unknown
				//IL_0023: Unknown result type (might be due to invalid IL or missing references)
				//IL_0028: Unknown result type (might be due to invalid IL or missing references)
				//IL_0030: 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_003f: Unknown result type (might be due to invalid IL or missing references)
				//IL_004b: Expected O, but got Unknown
				//IL_0050: 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_005c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0063: Unknown result type (might be due to invalid IL or missing references)
				//IL_006a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0076: Expected O, but got Unknown
				//IL_0097: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
				//IL_0113: Unknown result type (might be due to invalid IL or missing references)
				if (_button == null)
				{
					_button = new GUIStyle(GUI.skin.button);
					_button.padding = new RectOffset
					{
						left = 10,
						right = 10,
						top = 6,
						bottom = 6
					};
					_button.margin = new RectOffset
					{
						left = 2,
						right = 2,
						top = 2,
						bottom = 2
					};
					_button.fontSize = 12;
					_button.fontStyle = (FontStyle)0;
					_button.normal.textColor = Color.white;
					_button.hover.textColor = new Color(1f, 0.92f, 0.016f);
					_button.normal.background = MakeTex(2, 2, new Color(0.3f, 0.3f, 0.3f, 1f));
					_button.hover.background = MakeTex(2, 2, new Color(0.4f, 0.4f, 0.4f, 1f));
				}
				return _button;
			}
		}

		public static GUIStyle SmallButton
		{
			get
			{
				//IL_0014: Unknown result type (might be due to invalid IL or missing references)
				//IL_001e: Expected O, but got Unknown
				//IL_0023: Unknown result type (might be due to invalid IL or missing references)
				//IL_0028: Unknown result type (might be due to invalid IL or missing references)
				//IL_002f: 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_003d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0049: Expected O, but got Unknown
				//IL_004e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0053: 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_0061: Unknown result type (might be due to invalid IL or missing references)
				//IL_0068: Unknown result type (might be due to invalid IL or missing references)
				//IL_0074: Expected O, but got Unknown
				//IL_0095: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b8: 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_0111: Unknown result type (might be due to invalid IL or missing references)
				if (_smallButton == null)
				{
					_smallButton = new GUIStyle(GUI.skin.button);
					_smallButton.padding = new RectOffset
					{
						left = 6,
						right = 6,
						top = 4,
						bottom = 4
					};
					_smallButton.margin = new RectOffset
					{
						left = 2,
						right = 2,
						top = 2,
						bottom = 2
					};
					_smallButton.fontSize = 11;
					_smallButton.fontStyle = (FontStyle)0;
					_smallButton.normal.textColor = Color.white;
					_smallButton.hover.textColor = new Color(1f, 0.92f, 0.016f);
					_smallButton.normal.background = MakeTex(2, 2, new Color(0.3f, 0.3f, 0.3f, 1f));
					_smallButton.hover.background = MakeTex(2, 2, new Color(0.4f, 0.4f, 0.4f, 1f));
				}
				return _smallButton;
			}
		}

		public static GUIStyle DisabledButton
		{
			get
			{
				//IL_0014: Unknown result type (might be due to invalid IL or missing references)
				//IL_001e: Expected O, but got Unknown
				//IL_0023: Unknown result type (might be due to invalid IL or missing references)
				//IL_0028: Unknown result type (might be due to invalid IL or missing references)
				//IL_002f: 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_003d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0049: Expected O, but got Unknown
				//IL_004e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0053: 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_0061: Unknown result type (might be due to invalid IL or missing references)
				//IL_0068: Unknown result type (might be due to invalid IL or missing references)
				//IL_0074: Expected O, but got Unknown
				//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
				//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
				//IL_012a: Unknown result type (might be due to invalid IL or missing references)
				if (_disabledButton == null)
				{
					_disabledButton = new GUIStyle(GUI.skin.button);
					_disabledButton.padding = new RectOffset
					{
						left = 6,
						right = 6,
						top = 4,
						bottom = 4
					};
					_disabledButton.margin = new RectOffset
					{
						left = 2,
						right = 2,
						top = 2,
						bottom = 2
					};
					_disabledButton.fontSize = 11;
					_disabledButton.fontStyle = (FontStyle)0;
					_disabledButton.normal.textColor = new Color(0.5f, 0.5f, 0.5f, 0.8f);
					_disabledButton.hover.textColor = new Color(0.5f, 0.5f, 0.5f, 0.8f);
					_disabledButton.normal.background = MakeTex(2, 2, new Color(0.2f, 0.2f, 0.2f, 0.8f));
					_disabledButton.hover.background = MakeTex(2, 2, new Color(0.2f, 0.2f, 0.2f, 0.8f));
				}
				return _disabledButton;
			}
		}

		public static GUIStyle WindowStyle
		{
			get
			{
				//IL_0014: Unknown result type (might be due to invalid IL or missing references)
				//IL_001e: Expected O, but got Unknown
				//IL_003e: Unknown result type (might be due to invalid IL or missing references)
				//IL_006d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0086: Unknown result type (might be due to invalid IL or missing references)
				//IL_009a: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b6: 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_00c6: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d3: Expected O, but got Unknown
				//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
				//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
				//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
				//IL_00fe: Expected O, but got Unknown
				if (_windowStyle == null)
				{
					_windowStyle = new GUIStyle(GUI.skin.window);
					_windowStyle.normal.background = MakeTex(2, 2, new Color(0.15f, 0.15f, 0.15f, 1f));
					_windowStyle.onNormal.background = MakeTex(2, 2, new Color(0.15f, 0.15f, 0.15f, 1f));
					_windowStyle.normal.textColor = Color.white;
					_windowStyle.onNormal.textColor = Color.white;
					_windowStyle.padding = new RectOffset
					{
						left = 10,
						right = 10,
						top = 25,
						bottom = 10
					};
					_windowStyle.border = new RectOffset
					{
						left = 4,
						right = 4,
						top = 4,
						bottom = 4
					};
					_windowStyle.fontSize = 14;
					_windowStyle.fontStyle = (FontStyle)1;
				}
				return _windowStyle;
			}
		}

		public static GUIStyle ToggleStyle
		{
			get
			{
				//IL_0014: Unknown result type (might be due to invalid IL or missing references)
				//IL_001e: Expected O, but got Unknown
				//IL_0043: Unknown result type (might be due to invalid IL or missing references)
				//IL_0066: Unknown result type (might be due to invalid IL or missing references)
				//IL_0089: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
				//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
				//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e2: Expected O, but got Unknown
				if (_toggleStyle == null)
				{
					_toggleStyle = new GUIStyle(GUI.skin.toggle);
					_toggleStyle.fontSize = 12;
					_toggleStyle.normal.textColor = new Color(1f, 0.4f, 0.4f);
					_toggleStyle.onNormal.textColor = new Color(0.4f, 1f, 0.4f);
					_toggleStyle.hover.textColor = new Color(1f, 0.5f, 0.5f);
					_toggleStyle.onHover.textColor = new Color(0.5f, 1f, 0.5f);
					_toggleStyle.padding = new RectOffset
					{
						left = 20,
						right = 5,
						top = 2,
						bottom = 2
					};
				}
				return _toggleStyle;
			}
		}

		public static GUIStyle TextField
		{
			get
			{
				//IL_0014: Unknown result type (might be due to invalid IL or missing references)
				//IL_001e: Expected O, but got Unknown
				//IL_0034: Unknown result type (might be due to invalid IL or missing references)
				//IL_0048: Unknown result type (might be due to invalid IL or missing references)
				//IL_0072: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
				//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
				//IL_00db: Expected O, but got Unknown
				if (_textField == null)
				{
					_textField = new GUIStyle(GUI.skin.textField);
					_textField.fontSize = 12;
					_textField.normal.textColor = Color.white;
					_textField.focused.textColor = Color.white;
					_textField.normal.background = MakeTex(2, 2, new Color(0.1f, 0.1f, 0.1f, 1f));
					_textField.focused.background = MakeTex(2, 2, new Color(0.12f, 0.12f, 0.12f, 1f));
					_textField.padding = new RectOffset
					{
						left = 6,
						right = 6,
						top = 4,
						bottom = 4
					};
				}
				return _textField;
			}
		}

		private static Texture2D MakeTex(int width, int height, Color col)
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Expected O, but got Unknown
			Color[] array = (Color[])(object)new Color[width * height];
			for (int i = 0; i < array.Length; i++)
			{
				array[i] = col;
			}
			Texture2D val = new Texture2D(width, height);
			val.SetPixels(Il2CppStructArray<Color>.op_Implicit(array));
			val.Apply();
			return val;
		}

		public static void ResetStyles()
		{
			_menuBox = null;
			_sectionBox = null;
			_headerLabel = null;
			_itemLabel = null;
			_button = null;
			_smallButton = null;
			_disabledButton = null;
			_windowStyle = null;
			_toggleStyle = null;
			_textField = null;
		}
	}
}
namespace AutoUpgradeMod.UI
{
	public class AutoUpgradeUI : MonoBehaviour
	{
		private class Notification
		{
			public string itemName;

			public string rarity;

			public int fromLevel;

			public int toLevel;

			public List<(string name, string rarity)> choices;

			public float timestamp;
		}

		private static ManualLogSource log;

		private static HashSet<string> discoveredWeapons = new HashSet<string>();

		private static HashSet<string> discoveredTomes = new HashSet<string>();

		private int discoveryRetryCount;

		private const int MAX_DISCOVERY_RETRIES = 5;

		private bool showMenu;

		private Rect menuRect = new Rect(100f, 50f, 950f, 850f);

		private const int WINDOW_ID = 99999;

		private bool autoSelectionEnabled = true;

		private string loadoutNameInput = "";

		private bool isEditingLoadoutName;

		private Vector2 mainScrollPosition = Vector2.zero;

		private Vector2 loadoutScrollPosition = Vector2.zero;

		private Vector2 priorityListScrollPosition = Vector2.zero;

		private string loadoutUiError = string.Empty;

		private List<SavedLoadout> cachedSavedLoadouts = new List<SavedLoadout>();

		private Vector2 weaponScrollPosition = Vector2.zero;

		private Vector2 tomeScrollPosition = Vector2.zero;

		private List<Notification> notifications = new List<Notification>();

		private const float NOTIFICATION_LIFETIME = 60f;

		private const int MAX_NOTIFICATIONS = 4;

		private Vector2 notificationScrollPosition = Vector2.zero;

		private GUIStyle cachedSelectedStyle;

		private GUIStyle cachedChoiceStyle;

		private float cachedChoicesPrefixWidth;

		private float cachedBulletWidth;

		private static UpgradePicker pendingPicker = null;

		private static float delayUntilTime = 0f;

		private static bool isProcessing = false;

		private const float NORMAL_DELAY = 0.005f;

		private const float RETRY_DELAY = 0.01f;

		private static bool lastSelectionWasManual = false;

		private static int retryCount = 0;

		private const int MAX_RETRIES = 2;

		private bool showMaxLevelDialog;

		private int currentEditingIndex = -1;

		private int tempMaxLevel = -1;

		private bool showOnlyUnlocked;

		public static AutoUpgradeUI Instance { get; private set; }

		public AutoUpgradeUI(IntPtr ptr)
			: base(ptr)
		{
		}//IL_0015: 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_0032: 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_003d: 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_0048: Unknown result type (might be due to invalid IL or missing references)
		//IL_004d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0069: Unknown result type (might be due to invalid IL or missing references)
		//IL_006e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0074: Unknown result type (might be due to invalid IL or missing references)
		//IL_0079: Unknown result type (might be due to invalid IL or missing references)
		//IL_008a: Unknown result type (might be due to invalid IL or missing references)
		//IL_008f: Unknown result type (might be due to invalid IL or missing references)


		private void AddSpace(float pixels)
		{
			GUILayout.Label("", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(pixels) });
		}

		public static void Initialize(ManualLogSource logger)
		{
			log = logger;
			log.LogInfo((object)"AutoUpgradeUI initialized");
		}

		private void Start()
		{
			Instance = this;
			autoSelectionEnabled = ConfigManager.GetAutoSelectionEnabled();
			loadoutNameInput = ConfigManager.GetActiveLoadoutName();
			showOnlyUnlocked = ConfigManager.GetShowOnlyUnlocked();
			RefreshSavedLoadouts();
			Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject);
			((MonoBehaviour)this).Invoke("DiscoverItems", 2f);
			ManualLogSource obj = log;
			if (obj != null)
			{
				obj.LogInfo((object)"AutoUpgradeUI component started");
			}
		}

		private void Update()
		{
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Expected O, but got Unknown
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Expected O, but got Unknown
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Expected O, but got Unknown
			HandleHotkeys();
			if (isProcessing || !((Object)(object)pendingPicker != (Object)null) || !(Time.time >= delayUntilTime) || !autoSelectionEnabled)
			{
				return;
			}
			isProcessing = true;
			UpgradePicker val = pendingPicker;
			pendingPicker = null;
			bool flag = default(bool);
			try
			{
				if (AutoSelector.ProcessAutoSelection(val))
				{
					ManualLogSource val2 = log;
					if (val2 != null)
					{
						BepInExInfoLogInterpolatedStringHandler val3 = new BepInExInfoLogInterpolatedStringHandler(36, 2, ref flag);
						if (flag)
						{
							((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("Manual selection triggered (retry ");
							((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<int>(retryCount);
							((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("/");
							((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<int>(2);
							((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(")");
						}
						val2.LogInfo(val3);
					}
					if (retryCount < 2 && (Object)(object)val != (Object)null)
					{
						retryCount++;
						pendingPicker = val;
						delayUntilTime = Time.time + 0.01f;
						val2 = log;
						if (val2 != null)
						{
							BepInExInfoLogInterpolatedStringHandler val3 = new BepInExInfoLogInterpolatedStringHandler(15, 1, ref flag);
							if (flag)
							{
								((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("Queuing retry #");
								((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<int>(retryCount);
							}
							val2.LogInfo(val3);
						}
						isProcessing = false;
					}
					else
					{
						lastSelectionWasManual = true;
					}
				}
				else
				{
					lastSelectionWasManual = false;
					retryCount = 0;
				}
			}
			catch (Exception ex)
			{
				ManualLogSource val2 = log;
				if (val2 != null)
				{
					BepInExErrorLogInterpolatedStringHandler val4 = new BepInExErrorLogInterpolatedStringHandler(25, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("Delayed selection error: ");
						((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<string>(ex.Message);
					}
					val2.LogError(val4);
				}
				if ((Object)(object)((val != null) ? val.levelupScreen : null) != (Object)null)
				{
					((Component)val.levelupScreen).gameObject.SetActive(true);
				}
			}
			finally
			{
				isProcessing = false;
			}
		}

		public static void QueueAutoSelection(UpgradePicker picker)
		{
			if ((Object)(object)picker == (Object)null)
			{
				return;
			}
			pendingPicker = picker;
			retryCount = 0;
			if (lastSelectionWasManual)
			{
				delayUntilTime = Time.time + 0.01f;
				ManualLogSource obj = log;
				if (obj != null)
				{
					obj.LogInfo((object)"Queued with extended delay (post-manual)");
				}
			}
			else
			{
				delayUntilTime = Time.time + 0.005f;
			}
		}

		private void HandleHotkeys()
		{
			//IL_0000: 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_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Expected O, but got Unknown
			try
			{
				if (Input.GetKeyDown(ConfigManager.GetToggleMenuHotkey()))
				{
					ToggleMenuVisibility();
				}
				if (Input.GetKeyDown(ConfigManager.GetToggleAutoSelectionHotkey()))
				{
					ToggleAutoSelection();
				}
			}
			catch (Exception ex)
			{
				ManualLogSource val = log;
				if (val != null)
				{
					bool flag = default(bool);
					BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(24, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Hotkey handling failed: ");
						((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex.Message);
					}
					val.LogWarning(val2);
				}
			}
		}

		private void ToggleMenuVisibility()
		{
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Expected O, but got Unknown
			showMenu = !showMenu;
			if (showMenu)
			{
				StyleHelper.ResetStyles();
				cachedSelectedStyle = null;
				cachedChoiceStyle = null;
				loadoutNameInput = (string.IsNullOrWhiteSpace(loadoutNameInput) ? ConfigManager.GetActiveLoadoutName() : loadoutNameInput);
				RefreshSavedLoadouts();
			}
			ManualLogSource val = log;
			if (val != null)
			{
				bool flag = default(bool);
				BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(5, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Menu ");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(showMenu ? "opened" : "closed");
				}
				val.LogInfo(val2);
			}
		}

		private void ToggleAutoSelection()
		{
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Expected O, but got Unknown
			autoSelectionEnabled = !autoSelectionEnabled;
			if (!autoSelectionEnabled)
			{
				pendingPicker = null;
			}
			ConfigManager.SetAutoSelectionEnabled(autoSelectionEnabled);
			AddNotification("Auto-selection " + (autoSelectionEnabled ? "enabled" : "disabled"));
			ManualLogSource val = log;
			if (val != null)
			{
				bool flag = default(bool);
				BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(26, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Auto-selection ");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(autoSelectionEnabled ? "enabled" : "disabled");
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" via hotkey");
				}
				val.LogInfo(val2);
			}
		}

		private void OnGUI()
		{
			//IL_0000: 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_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			GUI.color = Color.white;
			GUI.backgroundColor = Color.white;
			if (showMenu)
			{
				ClampMenuRectToScreen();
				menuRect = GUI.Window(99999, menuRect, WindowFunction.op_Implicit((Action<int>)DrawMainMenu), "AutoUpgrade - Unified Priority List", StyleHelper.WindowStyle);
			}
			if (showMaxLevelDialog)
			{
				DrawMaxLevelDialog();
			}
			DrawNotifications();
		}

		private void DrawMainMenu(int windowID)
		{
			//IL_0000: 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_0014: 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_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_018c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0191: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Expected O, but got Unknown
			GUI.color = Color.white;
			GUI.backgroundColor = Color.white;
			GUI.contentColor = Color.white;
			GUI.DragWindow(new Rect(0f, 0f, 10000f, 20f));
			GUILayout.BeginVertical(StyleHelper.MenuBox, Array.Empty<GUILayoutOption>());
			GUILayout.BeginHorizontal((Il2CppReferenceArray<GUILayoutOption>)null);
			GUILayout.Label("AutoUpgrade - Unified Priority List", StyleHelper.HeaderLabel, (Il2CppReferenceArray<GUILayoutOption>)null);
			GUILayout.FlexibleSpace();
			if (GUILayout.Button("X", StyleHelper.SmallButton, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(30f) }))
			{
				showMenu = false;
				ManualLogSource obj = log;
				if (obj != null)
				{
					obj.LogInfo((object)"Menu closed via [X] button");
				}
			}
			GUILayout.EndHorizontal();
			GUILayout.BeginHorizontal((Il2CppReferenceArray<GUILayoutOption>)null);
			string text = (autoSelectionEnabled ? " Auto-selection: ON" : " Auto-selection: OFF");
			bool flag = GUILayout.Toggle(autoSelectionEnabled, text, StyleHelper.ToggleStyle, (Il2CppReferenceArray<GUILayoutOption>)null);
			if (flag != autoSelectionEnabled)
			{
				autoSelectionEnabled = flag;
				if (!autoSelectionEnabled)
				{
					pendingPicker = null;
				}
				ConfigManager.SetAutoSelectionEnabled(autoSelectionEnabled);
				ManualLogSource val = log;
				if (val != null)
				{
					bool flag2 = default(bool);
					BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(15, 1, ref flag2);
					if (flag2)
					{
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Auto-selection ");
						((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(autoSelectionEnabled ? "enabled" : "disabled");
					}
					val.LogInfo(val2);
				}
			}
			GUILayout.EndHorizontal();
			AddSpace(10f);
			float num = Mathf.Max(220f, ((Rect)(ref menuRect)).height - 180f);
			mainScrollPosition = GUILayout.BeginScrollView(mainScrollPosition, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(num) });
			try
			{
				DrawLoadoutSection();
				AddSpace(10f);
				DrawPriorityListSection();
				AddSpace(10f);
				int weaponCount = PriorityManager.GetWeaponCount();
				int tomeCount = PriorityManager.GetTomeCount();
				int itemCount = PriorityManager.GetItemCount();
				GUILayout.Label($"{itemCount}/8 slots used - {weaponCount}W, {tomeCount}T", StyleHelper.ItemLabel, (Il2CppReferenceArray<GUILayoutOption>)null);
				AddSpace(10f);
				DrawAddItemsSection();
				AddSpace(10f);
			}
			finally
			{
				GUILayout.EndScrollView();
			}
			GUILayout.BeginHorizontal((Il2CppReferenceArray<GUILayoutOption>)null);
			if (GUILayout.Button("Clear All", StyleHelper.Button, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(100f) }))
			{
				PriorityManager.Clear();
				ConfigManager.SavePriorityList();
				ManualLogSource obj2 = log;
				if (obj2 != null)
				{
					obj2.LogInfo((object)"Priority list cleared via Clear All button");
				}
			}
			GUILayout.FlexibleSpace();
			if (GUILayout.Button("Close", StyleHelper.Button, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(100f) }))
			{
				showMenu = false;
				ManualLogSource obj3 = log;
				if (obj3 != null)
				{
					obj3.LogInfo((object)"Menu closed via Close button");
				}
			}
			GUILayout.EndHorizontal();
			GUILayout.EndVertical();
		}

		private void DrawLoadoutSection()
		{
			//IL_0406: Unknown result type (might be due to invalid IL or missing references)
			//IL_040d: Expected O, but got Unknown
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0200: Unknown result type (might be due to invalid IL or missing references)
			//IL_0218: Unknown result type (might be due to invalid IL or missing references)
			//IL_021d: Unknown result type (might be due to invalid IL or missing references)
			GUILayout.BeginVertical(StyleHelper.SectionBox, Array.Empty<GUILayoutOption>());
			try
			{
				HandleLoadoutNameInput(Event.current);
				GUILayout.Label("Loadouts", StyleHelper.HeaderLabel, (Il2CppReferenceArray<GUILayoutOption>)null);
				AddSpace(5f);
				string activeLoadoutName = ConfigManager.GetActiveLoadoutName();
				GUILayout.Label(string.IsNullOrWhiteSpace(activeLoadoutName) ? "Active: Custom / Unsaved" : ("Active: " + activeLoadoutName), StyleHelper.ItemLabel, (Il2CppReferenceArray<GUILayoutOption>)null);
				GUILayout.Label($"Hotkeys: Menu [{ConfigManager.GetToggleMenuHotkey()}], Toggle Auto [{ConfigManager.GetToggleAutoSelectionHotkey()}]", StyleHelper.ItemLabel, (Il2CppReferenceArray<GUILayoutOption>)null);
				if (!string.IsNullOrWhiteSpace(loadoutUiError))
				{
					GUILayout.Label("Loadout UI warning: " + loadoutUiError, StyleHelper.ItemLabel, (Il2CppReferenceArray<GUILayoutOption>)null);
				}
				AddSpace(5f);
				GUILayout.BeginHorizontal((Il2CppReferenceArray<GUILayoutOption>)null);
				try
				{
					GUILayout.Label("Name", StyleHelper.ItemLabel, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(50f) });
					string obj = (string.IsNullOrWhiteSpace(loadoutNameInput) ? "<type a name>" : loadoutNameInput);
					string text = (isEditingLoadoutName ? "_" : string.Empty);
					if (GUILayout.Button(obj + text, StyleHelper.Button, (GUILayoutOption[])(object)new GUILayoutOption[2]
					{
						GUILayout.Width(220f),
						GUILayout.Height(24f)
					}))
					{
						isEditingLoadoutName = true;
					}
					if (GUILayout.Button("Save Current", StyleHelper.SmallButton, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(100f) }))
					{
						SaveCurrentLoadout();
					}
					if (GUILayout.Button("Load Named", StyleHelper.SmallButton, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(100f) }))
					{
						LoadNamedLoadout(loadoutNameInput);
					}
				}
				finally
				{
					GUILayout.EndHorizontal();
				}
				if (cachedSavedLoadouts.Count == 0)
				{
					GUILayout.Label("No saved loadouts yet.", StyleHelper.ItemLabel, (Il2CppReferenceArray<GUILayoutOption>)null);
				}
				else
				{
					loadoutScrollPosition = GUILayout.BeginScrollView(loadoutScrollPosition, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(120f) });
					try
					{
						foreach (SavedLoadout cachedSavedLoadout in cachedSavedLoadouts)
						{
							bool flag = cachedSavedLoadout.name.Equals(activeLoadoutName, StringComparison.OrdinalIgnoreCase);
							GUILayout.BeginHorizontal(GUI.skin.box, Array.Empty<GUILayoutOption>());
							try
							{
								string value = (flag ? " (Active)" : string.Empty);
								GUILayout.Label($"{cachedSavedLoadout.name}{value} - {cachedSavedLoadout.items.Count} items", StyleHelper.ItemLabel, (Il2CppReferenceArray<GUILayoutOption>)null);
								GUILayout.FlexibleSpace();
								if (GUILayout.Button("Use Name", StyleHelper.SmallButton, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(70f) }))
								{
									loadoutNameInput = cachedSavedLoadout.name;
								}
								if (GUILayout.Button("Load", StyleHelper.SmallButton, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(55f) }))
								{
									LoadNamedLoadout(cachedSavedLoadout.name);
								}
								if (GUILayout.Button("Delete", StyleHelper.SmallButton, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(60f) }) && ConfigManager.DeleteLoadout(cachedSavedLoadout.name))
								{
									AddNotification("Deleted loadout '" + cachedSavedLoadout.name + "'");
									if (loadoutNameInput == cachedSavedLoadout.name)
									{
										loadoutNameInput = string.Empty;
									}
									RefreshSavedLoadouts();
								}
							}
							finally
							{
								GUILayout.EndHorizontal();
							}
						}
					}
					finally
					{
						GUILayout.EndScrollView();
					}
				}
				loadoutUiError = string.Empty;
			}
			catch (Exception ex)
			{
				loadoutUiError = ex.GetType().Name;
				ManualLogSource val = log;
				if (val != null)
				{
					bool flag2 = default(bool);
					BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(29, 1, ref flag2);
					if (flag2)
					{
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Loadout UI failed to render: ");
						((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<Exception>(ex);
					}
					val.LogError(val2);
				}
				GUILayout.Label("Loadouts temporarily unavailable. Check the log for details.", StyleHelper.ItemLabel, (Il2CppReferenceArray<GUILayoutOption>)null);
			}
			finally
			{
				GUILayout.EndVertical();
			}
		}

		private void HandleLoadoutNameInput(Event currentEvent)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Invalid comparison between Unknown and I4
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Invalid comparison between Unknown and I4
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Invalid comparison between Unknown and I4
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Invalid comparison between Unknown and I4
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Invalid comparison between Unknown and I4
			if (!isEditingLoadoutName || currentEvent == null || (int)currentEvent.type != 4)
			{
				return;
			}
			if ((int)currentEvent.keyCode == 27 || (int)currentEvent.keyCode == 13 || (int)currentEvent.keyCode == 271)
			{
				isEditingLoadoutName = false;
				currentEvent.Use();
				return;
			}
			if ((int)currentEvent.keyCode == 8)
			{
				if (!string.IsNullOrEmpty(loadoutNameInput))
				{
					loadoutNameInput = loadoutNameInput.Substring(0, loadoutNameInput.Length - 1);
				}
				currentEvent.Use();
				return;
			}
			char character = currentEvent.character;
			if (character != 0 && !char.IsControl(character))
			{
				if ((!char.IsLetterOrDigit(character) && " -_'()[]".IndexOf(character) < 0) || loadoutNameInput.Length >= 24)
				{
					currentEvent.Use();
					return;
				}
				loadoutNameInput += character;
				currentEvent.Use();
			}
		}

		private void ClampMenuRectToScreen()
		{
			float num = Mathf.Max(700f, (float)Screen.width - 20f);
			float num2 = Mathf.Max(500f, (float)Screen.height - 20f);
			((Rect)(ref menuRect)).width = Mathf.Min(((Rect)(ref menuRect)).width, num);
			((Rect)(ref menuRect)).height = Mathf.Min(((Rect)(ref menuRect)).height, num2);
			((Rect)(ref menuRect)).x = Mathf.Clamp(((Rect)(ref menuRect)).x, 0f, Mathf.Max(0f, (float)Screen.width - ((Rect)(ref menuRect)).width));
			((Rect)(ref menuRect)).y = Mathf.Clamp(((Rect)(ref menuRect)).y, 0f, Mathf.Max(0f, (float)Screen.height - ((Rect)(ref menuRect)).height));
		}

		private void RefreshSavedLoadouts()
		{
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Expected O, but got Unknown
			try
			{
				cachedSavedLoadouts = ConfigManager.GetSavedLoadouts() ?? new List<SavedLoadout>();
				loadoutUiError = string.Empty;
			}
			catch (Exception ex)
			{
				cachedSavedLoadouts = new List<SavedLoadout>();
				loadoutUiError = ex.GetType().Name;
				ManualLogSource val = log;
				if (val != null)
				{
					bool flag = default(bool);
					BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(34, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Failed to refresh saved loadouts: ");
						((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<Exception>(ex);
					}
					val.LogError(val2);
				}
			}
		}

		private void SaveCurrentLoadout()
		{
			string text = (loadoutNameInput ?? string.Empty).Trim();
			if (string.IsNullOrWhiteSpace(text))
			{
				AddNotification("Enter a loadout name first");
			}
			else if (ConfigManager.SaveCurrentAsLoadout(text))
			{
				loadoutNameInput = text;
				RefreshSavedLoadouts();
				AddNotification("Saved loadout '" + text + "'");
			}
		}

		private void LoadNamedLoadout(string loadoutName)
		{
			string text = (loadoutName ?? string.Empty).Trim();
			if (string.IsNullOrWhiteSpace(text))
			{
				AddNotification("Enter a loadout name first");
			}
			else if (ConfigManager.LoadLoadout(text))
			{
				loadoutNameInput = text;
				RefreshSavedLoadouts();
				AddNotification("Loaded loadout '" + text + "'");
			}
			else
			{
				AddNotification("Loadout '" + text + "' not found");
			}
		}

		private void DrawPriorityListSection()
		{
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_018c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0193: Expected O, but got Unknown
			//IL_0233: Unknown result type (might be due to invalid IL or missing references)
			//IL_023a: Expected O, but got Unknown
			//IL_02c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c7: Expected O, but got Unknown
			//IL_035b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0362: Expected O, but got Unknown
			GUILayout.BeginVertical(StyleHelper.SectionBox, Array.Empty<GUILayoutOption>());
			GUILayout.Label("Priority List", StyleHelper.HeaderLabel, (Il2CppReferenceArray<GUILayoutOption>)null);
			AddSpace(5f);
			List<PriorityItem> priorityList = PriorityManager.GetPriorityList();
			if (priorityList.Count == 0)
			{
				GUILayout.Label("No items in priority list. Click [+] below to add items.", StyleHelper.ItemLabel, (Il2CppReferenceArray<GUILayoutOption>)null);
			}
			else
			{
				priorityListScrollPosition = GUILayout.BeginScrollView(priorityListScrollPosition, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(210f) });
				try
				{
					bool flag = default(bool);
					for (int i = 0; i < priorityList.Count; i++)
					{
						PriorityItem priorityItem = priorityList[i];
						GUILayout.BeginHorizontal((i % 2 == 0) ? StyleHelper.SectionBox : GUI.skin.box, Array.Empty<GUILayoutOption>());
						string value = FormatItemName(priorityItem.itemName);
						GUILayout.Label($"#{i + 1}: {value} ({priorityItem.TypeLabel}) Max: {priorityItem.MaxLevelDisplay}", StyleHelper.ItemLabel, (Il2CppReferenceArray<GUILayoutOption>)null);
						GUILayout.FlexibleSpace();
						bool num = i == 0;
						GUIStyle val = (num ? StyleHelper.DisabledButton : StyleHelper.SmallButton);
						GUI.enabled = !num;
						if (GUILayout.Button("↑", val, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(30f) }))
						{
							PriorityManager.MoveUp(i);
							ConfigManager.SavePriorityList();
							RefreshSavedLoadouts();
							ManualLogSource val2 = log;
							if (val2 != null)
							{
								BepInExInfoLogInterpolatedStringHandler val3 = new BepInExInfoLogInterpolatedStringHandler(33, 1, ref flag);
								if (flag)
								{
									((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("Moved item '");
									((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(priorityItem.itemName);
									((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("' up in priority list");
								}
								val2.LogInfo(val3);
							}
						}
						GUI.enabled = true;
						bool num2 = i == priorityList.Count - 1;
						GUIStyle val4 = (num2 ? StyleHelper.DisabledButton : StyleHelper.SmallButton);
						GUI.enabled = !num2;
						if (GUILayout.Button("↓", val4, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(30f) }))
						{
							PriorityManager.MoveDown(i);
							ConfigManager.SavePriorityList();
							RefreshSavedLoadouts();
							ManualLogSource val2 = log;
							if (val2 != null)
							{
								BepInExInfoLogInterpolatedStringHandler val3 = new BepInExInfoLogInterpolatedStringHandler(35, 1, ref flag);
								if (flag)
								{
									((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("Moved item '");
									((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(priorityItem.itemName);
									((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("' down in priority list");
								}
								val2.LogInfo(val3);
							}
						}
						GUI.enabled = true;
						if (GUILayout.Button("Edit Max", StyleHelper.SmallButton, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(80f) }))
						{
							showMaxLevelDialog = true;
							currentEditingIndex = i;
							tempMaxLevel = priorityItem.maxLevel;
							ManualLogSource val2 = log;
							if (val2 != null)
							{
								BepInExInfoLogInterpolatedStringHandler val3 = new BepInExInfoLogInterpolatedStringHandler(31, 1, ref flag);
								if (flag)
								{
									((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("Opening max level dialog for '");
									((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(priorityItem.itemName);
									((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("'");
								}
								val2.LogInfo(val3);
							}
						}
						if (GUILayout.Button("Remove", StyleHelper.SmallButton, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(80f) }))
						{
							PriorityManager.RemoveItem(i);
							ConfigManager.SavePriorityList();
							RefreshSavedLoadouts();
							AddNotification("Removed '" + priorityItem.itemName + "' from priority list");
							ManualLogSource val2 = log;
							if (val2 != null)
							{
								BepInExInfoLogInterpolatedStringHandler val3 = new BepInExInfoLogInterpolatedStringHandler(34, 1, ref flag);
								if (flag)
								{
									((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("Removed item '");
									((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(priorityItem.itemName);
									((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("' from priority list");
								}
								val2.LogInfo(val3);
							}
						}
						GUILayout.EndHorizontal();
					}
				}
				finally
				{
					GUILayout.EndScrollView();
				}
			}
			GUILayout.EndVertical();
		}

		private void DrawAddItemsSection()
		{
			//IL_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0182: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Expected O, but got Unknown
			//IL_0313: Unknown result type (might be due to invalid IL or missing references)
			//IL_032b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0330: Unknown result type (might be due to invalid IL or missing references)
			//IL_024f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0256: Expected O, but got Unknown
			//IL_03f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ff: Expected O, but got Unknown
			GUILayout.BeginVertical(StyleHelper.SectionBox, Array.Empty<GUILayoutOption>());
			GUILayout.Label("Add Items", StyleHelper.HeaderLabel, (Il2CppReferenceArray<GUILayoutOption>)null);
			AddSpace(5f);
			int weaponCount = PriorityManager.GetWeaponCount();
			int tomeCount = PriorityManager.GetTomeCount();
			List<string> list = GetDiscoveredWeapons();
			List<string> list2 = GetDiscoveredTomes();
			GUILayout.BeginHorizontal((Il2CppReferenceArray<GUILayoutOption>)null);
			string text = (showOnlyUnlocked ? " Show Only Unlocked: ON" : " Show Only Unlocked: OFF (showing all)");
			bool flag = GUILayout.Toggle(showOnlyUnlocked, text, StyleHelper.ToggleStyle, (Il2CppReferenceArray<GUILayoutOption>)null);
			bool flag2 = default(bool);
			if (flag != showOnlyUnlocked)
			{
				showOnlyUnlocked = flag;
				ConfigManager.SetShowOnlyUnlocked(showOnlyUnlocked);
				ManualLogSource val = log;
				if (val != null)
				{
					BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(20, 1, ref flag2);
					if (flag2)
					{
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Show only unlocked: ");
						((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<bool>(showOnlyUnlocked);
					}
					val.LogInfo(val2);
				}
				DiscoverItems();
			}
			GUILayout.EndHorizontal();
			AddSpace(3f);
			GUILayout.BeginHorizontal((Il2CppReferenceArray<GUILayoutOption>)null);
			float num = Mathf.Max(220f, (((Rect)(ref menuRect)).width - 90f) / 2f);
			GUILayout.BeginVertical((GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(num) });
			GUILayout.Label($"WEAPONS ({weaponCount}/4)", StyleHelper.HeaderLabel, (Il2CppReferenceArray<GUILayoutOption>)null);
			AddSpace(3f);
			weaponScrollPosition = GUILayout.BeginScrollView(weaponScrollPosition, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(200f) });
			foreach (string item in list)
			{
				GUILayout.BeginHorizontal((Il2CppReferenceArray<GUILayoutOption>)null);
				string text2 = FormatItemName(item);
				GUILayout.Label(text2, StyleHelper.ItemLabel, (Il2CppReferenceArray<GUILayoutOption>)null);
				GUILayout.FlexibleSpace();
				bool num2 = PriorityManager.HasItem(text2);
				bool flag3 = !PriorityManager.CanAddWeapon();
				int num3;
				GUIStyle obj;
				if (!num2)
				{
					num3 = ((!flag3) ? 1 : 0);
					if (num3 != 0)
					{
						obj = StyleHelper.SmallButton;
						goto IL_01ef;
					}
				}
				else
				{
					num3 = 0;
				}
				obj = StyleHelper.DisabledButton;
				goto IL_01ef;
				IL_01ef:
				GUIStyle val3 = obj;
				GUI.enabled = (byte)num3 != 0;
				if (GUILayout.Button("+", val3, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(30f) }) && PriorityManager.TryAddItem(text2, isWeapon: true))
				{
					ConfigManager.SavePriorityList();
					AddNotification("Added " + text2 + " to priority list");
					ManualLogSource val = log;
					if (val != null)
					{
						BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(32, 1, ref flag2);
						if (flag2)
						{
							((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Added weapon '");
							((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(text2);
							((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("' to priority list");
						}
						val.LogInfo(val2);
					}
				}
				GUI.enabled = true;
				GUILayout.EndHorizontal();
			}
			GUILayout.EndScrollView();
			GUILayout.EndVertical();
			GUILayout.BeginVertical((GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(num) });
			GUILayout.Label($"TOMES ({tomeCount}/4)", StyleHelper.HeaderLabel, (Il2CppReferenceArray<GUILayoutOption>)null);
			AddSpace(3f);
			tomeScrollPosition = GUILayout.BeginScrollView(tomeScrollPosition, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(200f) });
			foreach (string item2 in list2)
			{
				GUILayout.BeginHorizontal((Il2CppReferenceArray<GUILayoutOption>)null);
				string text3 = FormatItemName(item2, isTome: true);
				GUILayout.Label(text3, StyleHelper.ItemLabel, (Il2CppReferenceArray<GUILayoutOption>)null);
				GUILayout.FlexibleSpace();
				bool num4 = PriorityManager.HasItem(text3);
				bool flag4 = !PriorityManager.CanAddTome();
				int num5;
				GUIStyle obj2;
				if (!num4)
				{
					num5 = ((!flag4) ? 1 : 0);
					if (num5 != 0)
					{
						obj2 = StyleHelper.SmallButton;
						goto IL_0398;
					}
				}
				else
				{
					num5 = 0;
				}
				obj2 = StyleHelper.DisabledButton;
				goto IL_0398;
				IL_0398:
				GUIStyle val4 = obj2;
				GUI.enabled = (byte)num5 != 0;
				if (GUILayout.Button("+", val4, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(30f) }) && PriorityManager.TryAddItem(text3, isWeapon: false))
				{
					ConfigManager.SavePriorityList();
					AddNotification("Added " + text3 + " to priority list");
					ManualLogSource val = log;
					if (val != null)
					{
						BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(30, 1, ref flag2);
						if (flag2)
						{
							((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Added tome '");
							((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(text3);
							((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("' to priority list");
						}
						val.LogInfo(val2);
					}
				}
				GUI.enabled = true;
				GUILayout.EndHorizontal();
			}
			GUILayout.EndScrollView();
			GUILayout.EndVertical();
			GUILayout.EndHorizontal();
			GUILayout.EndVertical();
		}

		private void DrawMaxLevelDialog()
		{
			//IL_0067: 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)
			float num = 500f;
			float num2 = 350f;
			float num3 = ((float)Screen.width - num) / 2f;
			float num4 = 100f;
			Rect val = default(Rect);
			((Rect)(ref val))..ctor(num3, num4, num, num2);
			List<PriorityItem> priorityList = PriorityManager.GetPriorityList();
			if (currentEditingIndex < 0 || currentEditingIndex >= priorityList.Count)
			{
				showMaxLevelDialog = false;
				return;
			}
			PriorityItem priorityItem = priorityList[currentEditingIndex];
			GUI.Window(100000, val, WindowFunction.op_Implicit((Action<int>)DrawMaxLevelDialogContent), $"Edit Max Level for: {FormatItemName(priorityItem.itemName, !priorityItem.isWeapon)} ({priorityItem.TypeLabel})", GUI.skin.window);
		}

		private void DrawMaxLevelDialogContent(int windowID)
		{
			//IL_0000: 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_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_04af: Expected O, but got Unknown
			//IL_043a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0441: Expected O, but got Unknown
			GUI.color = Color.white;
			GUI.backgroundColor = Color.white;
			GUI.contentColor = Color.white;
			GUILayout.BeginVertical(StyleHelper.MenuBox, Array.Empty<GUILayoutOption>());
			AddSpace(10f);
			GUILayout.Label((tempMaxLevel == -1) ? "Current: ∞" : $"Current: {tempMaxLevel}", StyleHelper.ItemLabel, (Il2CppReferenceArray<GUILayoutOption>)null);
			AddSpace(10f);
			GUILayout.Label("Increment:", StyleHelper.ItemLabel, (Il2CppReferenceArray<GUILayoutOption>)null);
			GUILayout.BeginHorizontal((Il2CppReferenceArray<GUILayoutOption>)null);
			if (GUILayout.Button("+1", StyleHelper.SmallButton, Array.Empty<GUILayoutOption>()))
			{
				if (tempMaxLevel == -1)
				{
					tempMaxLevel = 1;
				}
				else
				{
					tempMaxLevel++;
				}
			}
			if (GUILayout.Button("+5", StyleHelper.SmallButton, Array.Empty<GUILayoutOption>()))
			{
				if (tempMaxLevel == -1)
				{
					tempMaxLevel = 5;
				}
				else
				{
					tempMaxLevel += 5;
				}
			}
			if (GUILayout.Button("+10", StyleHelper.SmallButton, Array.Empty<GUILayoutOption>()))
			{
				if (tempMaxLevel == -1)
				{
					tempMaxLevel = 10;
				}
				else
				{
					tempMaxLevel += 10;
				}
			}
			if (GUILayout.Button("+25", StyleHelper.SmallButton, Array.Empty<GUILayoutOption>()))
			{
				if (tempMaxLevel == -1)
				{
					tempMaxLevel = 25;
				}
				else
				{
					tempMaxLevel += 25;
				}
			}
			GUILayout.EndHorizontal();
			AddSpace(10f);
			GUILayout.Label("Decrement:", StyleHelper.ItemLabel, (Il2CppReferenceArray<GUILayoutOption>)null);
			GUILayout.BeginHorizontal((Il2CppReferenceArray<GUILayoutOption>)null);
			if (GUILayout.Button("-1", StyleHelper.SmallButton, Array.Empty<GUILayoutOption>()))
			{
				if (tempMaxLevel == -1)
				{
					tempMaxLevel = 1;
				}
				else if (tempMaxLevel > 1)
				{
					tempMaxLevel--;
				}
			}
			if (GUILayout.Button("-5", StyleHelper.SmallButton, Array.Empty<GUILayoutOption>()))
			{
				if (tempMaxLevel == -1)
				{
					tempMaxLevel = 1;
				}
				else
				{
					tempMaxLevel = Math.Max(1, tempMaxLevel - 5);
				}
			}
			if (GUILayout.Button("-10", StyleHelper.SmallButton, Array.Empty<GUILayoutOption>()))
			{
				if (tempMaxLevel == -1)
				{
					tempMaxLevel = 1;
				}
				else
				{
					tempMaxLevel = Math.Max(1, tempMaxLevel - 10);
				}
			}
			if (GUILayout.Button("-25", StyleHelper.SmallButton, Array.Empty<GUILayoutOption>()))
			{
				if (tempMaxLevel == -1)
				{
					tempMaxLevel = 1;
				}
				else
				{
					tempMaxLevel = Math.Max(1, tempMaxLevel - 25);
				}
			}
			GUILayout.EndHorizontal();
			AddSpace(10f);
			GUILayout.Label("Quick Set:", StyleHelper.ItemLabel, (Il2CppReferenceArray<GUILayoutOption>)null);
			GUILayout.BeginHorizontal((Il2CppReferenceArray<GUILayoutOption>)null);
			if (GUILayout.Button("1", StyleHelper.Button, Array.Empty<GUILayoutOption>()))
			{
				tempMaxLevel = 1;
			}
			if (GUILayout.Button("5", StyleHelper.Button, Array.Empty<GUILayoutOption>()))
			{
				tempMaxLevel = 5;
			}
			if (GUILayout.Button("10", StyleHelper.Button, Array.Empty<GUILayoutOption>()))
			{
				tempMaxLevel = 10;
			}
			GUILayout.EndHorizontal();
			GUILayout.BeginHorizontal((Il2CppReferenceArray<GUILayoutOption>)null);
			if (GUILayout.Button("50", StyleHelper.Button, Array.Empty<GUILayoutOption>()))
			{
				tempMaxLevel = 50;
			}
			if (GUILayout.Button("100", StyleHelper.Button, Array.Empty<GUILayoutOption>()))
			{
				tempMaxLevel = 100;
			}
			if (GUILayout.Button("Unlimited", StyleHelper.Button, Array.Empty<GUILayoutOption>()))
			{
				tempMaxLevel = -1;
			}
			GUILayout.EndHorizontal();
			AddSpace(20f);
			GUILayout.BeginHorizontal((Il2CppReferenceArray<GUILayoutOption>)null);
			if (GUILayout.Button("Save", StyleHelper.Button, Array.Empty<GUILayoutOption>()))
			{
				bool flag = default(bool);
				if (tempMaxLevel >= 1 || tempMaxLevel == -1)
				{
					PriorityManager.SetMaxLevel(currentEditingIndex, tempMaxLevel);
					ConfigManager.SavePriorityList();
					List<PriorityItem> priorityList = PriorityManager.GetPriorityList();
					if (currentEditingIndex < priorityList.Count)
					{
						PriorityItem priorityItem = priorityList[currentEditingIndex];
						string text = ((tempMaxLevel == -1) ? "unlimited" : tempMaxLevel.ToString());
						string text2 = FormatItemName(priorityItem.itemName, !priorityItem.isWeapon);
						ManualLogSource val = log;
						if (val != null)
						{
							BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(28, 2, ref flag);
							if (flag)
							{
								((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Updated max level for '");
								((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(text2);
								((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("' to ");
								((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(text);
							}
							val.LogInfo(val2);
						}
						AddNotification("Updated max level for '" + text2 + "' to " + text);
					}
					showMaxLevelDialog = false;
				}
				else
				{
					ManualLogSource val = log;
					if (val != null)
					{
						BepInExWarningLogInterpolatedStringHandler val3 = new BepInExWarningLogInterpolatedStringHandler(60, 1, ref flag);
						if (flag)
						{
							((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("Invalid max level value: ");
							((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<int>(tempMaxLevel);
							((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(". Must be >= 1 or -1 for unlimited.");
						}
						val.LogWarning(val3);
					}
				}
			}
			GUILayout.FlexibleSpace();
			if (GUILayout.Button("Cancel", StyleHelper.Button, Array.Empty<GUILayoutOption>()))
			{
				showMaxLevelDialog = false;
				ManualLogSource obj = log;
				if (obj != null)
				{
					obj.LogInfo((object)"Max level dialog cancelled");
				}
			}
			GUILayout.EndHorizontal();
			GUILayout.EndVertical();
		}

		private string FormatItemName(string name, bool isTome = false)
		{
			if (string.IsNullOrWhiteSpace(name))
			{
				return name;
			}
			string text = name.Trim();
			bool num = text.StartsWith("Weapon", StringComparison.OrdinalIgnoreCase);
			bool flag = text.StartsWith("Tome", StringComparison.OrdinalIgnoreCase);
			bool flag2 = text.EndsWith("Tome", StringComparison.OrdinalIgnoreCase);
			if (num)
			{
				text = text.Substring(6);
			}
			else if (flag)
			{
				text = text.Substring(4);
				isTome = true;
			}
			text = text.Replace('_', ' ').Replace('-', ' ');
			text = NormalizeWhitespace(text);
			if (text.EndsWith(" Tome", StringComparison.OrdinalIgnoreCase))
			{
				text = text.Substring(0, text.Length - 5).Trim();
				isTome = true;
			}
			if (!text.Contains(" "))
			{
				text = SplitCamelCase(text);
				text = NormalizeWhitespace(text);
			}
			string itemKey = GetItemKey(text);
			if (itemKey == "lightningstaff")
			{
				text = "Lightning Staff";
			}
			else if (itemKey == "flamewalker")
			{
				text = "Flamewalker";
			}
			if ((isTome || flag2) && !text.EndsWith(" Tome", StringComparison.OrdinalIgnoreCase))
			{
				text += " Tome";
			}
			return text;
		}

		private static string NormalizeWhitespace(string input)
		{
			if (string.IsNullOrWhiteSpace(input))
			{
				return string.Empty;
			}
			StringBuilder stringBuilder = new StringBuilder(input.Length);
			bool flag = false;
			foreach (char c in input)
			{
				if (char.IsWhiteSpace(c))
				{
					if (!flag)
					{
						stringBuilder.Append(' ');
						flag = true;
					}
				}
				else
				{
					stringBuilder.Append(c);
					flag = false;
				}
			}
			return stringBuilder.ToString().Trim();
		}

		private static string SplitCamelCase(string input)
		{
			if (string.IsNullOrEmpty(input))
			{
				return input;
			}
			StringBuilder stringBuilder = new StringBuilder(input.Length + 8);
			for (int i = 0; i < input.Length; i++)
			{
				char c = input[i];
				if (i > 0)
				{
					char c2 = input[i - 1];
					bool flag = i + 1 < input.Length;
					char c3 = (flag ? input[i + 1] : '\0');
					bool flag2 = char.IsLower(c2) && char.IsUpper(c);
					bool flag3 = char.IsUpper(c2) && char.IsUpper(c) && flag && char.IsLower(c3);
					bool flag4 = char.IsLetter(c2) && char.IsDigit(c);
					bool flag5 = char.IsDigit(c2) && char.IsLetter(c);
					if (flag2 || flag3 || flag4 || flag5)
					{
						stringBuilder.Append(' ');
					}
				}
				stringBuilder.Append(c);
			}
			return stringBuilder.ToString();
		}

		private static string GetItemKey(string itemName)
		{
			if (string.IsNullOrWhiteSpace(itemName))
			{
				return string.Empty;
			}
			string text = itemName.Trim();
			if (text.StartsWith("Weapon", StringComparison.OrdinalIgnoreCase))
			{
				text = text.Substring(6).Trim();
			}
			else if (text.StartsWith("Tome", StringComparison.OrdinalIgnoreCase))
			{
				text = text.Substring(4).Trim();
			}
			if (text.EndsWith(" Tome", StringComparison.OrdinalIgnoreCase))
			{
				text = text.Substring(0, text.Length - 5).Trim();
			}
			else if (text.EndsWith("Tome", StringComparison.OrdinalIgnoreCase))
			{
				text = text.Substring(0, text.Length - 4).Trim();
			}
			StringBuilder stringBuilder = new StringBuilder();
			string text2 = text;
			foreach (char c in text2)
			{
				if (char.IsLetterOrDigit(c))
				{
					stringBuilder.Append(char.ToLowerInvariant(c));
				}
			}
			string text3 = stringBuilder.ToString();
			if (text3.EndsWith("s") && text3.Length > 3)
			{
				text3 = text3.Substring(0, text3.Length - 1);
			}
			if (text3 == "lightningbolt" || text3 == "lightningstaff")
			{
				text3 = "lightningstaff";
			}
			if (text3 == "flamewalkers" || text3 == "flamewalker")
			{
				text3 = "flamewalker";
			}
			return text3;
		}

		public void DiscoverItems()
		{
			//IL_018a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0191: Expected O, but got Unknown
			//IL_02c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cf: Expected O, but got Unknown
			//IL_03a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03aa: Expected O, but got Unknown
			//IL_04e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e8: Expected O, but got Unknown
			//IL_0653: Unknown result type (might be due to invalid IL or missing references)
			//IL_065a: Expected O, but got Unknown
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Expected O, but got Unknown
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Expected O, but got Unknown
			//IL_0539: Unknown result type (might be due to invalid IL or missing references)
			//IL_0540: Expected O, but got Unknown
			//IL_0569: Unknown result type (might be due to invalid IL or missing references)
			//IL_0570: Expected O, but got Unknown
			//IL_0255: Unknown result type (might be due to invalid IL or missing references)
			//IL_025c: Expected O, but got Unknown
			//IL_046e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0475: Expected O, but got Unknown
			//IL_05c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_05cb: Expected O, but got Unknown
			//IL_061f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0626: Expected O, but got Unknown
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Expected O, but got Unknown
			//IL_035c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0363: Expected O, but got Unknown
			bool flag = default(bool);
			try
			{
				ManualLogSource val;
				if ((Object)(object)DataManager.Instance == (Object)null)
				{
					discoveryRetryCount++;
					if (discoveryRetryCount < 5)
					{
						val = log;
						if (val != null)
						{
							BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(67, 2, ref flag);
							if (flag)
							{
								((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("DataManager not available yet, retrying in 2 seconds (attempt ");
								((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(discoveryRetryCount);
								((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("/");
								((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(5);
								((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(")...");
							}
							val.LogWarning(val2);
						}
						((MonoBehaviour)this).Invoke("DiscoverItems", 2f);
						return;
					}
					val = log;
					if (val != null)
					{
						BepInExErrorLogInterpolatedStringHandler val3 = new BepInExErrorLogInterpolatedStringHandler(48, 1, ref flag);
						if (flag)
						{
							((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("DataManager failed to initialize after ");
							((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<int>(5);
							((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" attempts");
						}
						val.LogError(val3);
					}
					return;
				}
				HashSet<string> hashSet = new HashSet<string>();
				HashSet<string> hashSet2 = new HashSet<string>();
				List<WeaponData> allWeapons = DataManager.Instance.GetAllWeapons();
				if (allWeapons != null)
				{
					Enumerator<WeaponData> enumerator = allWeapons.GetEnumerator();
					while (enumerator.MoveNext())
					{
						WeaponData current = enumerator.Current;
						if (!((Object)(object)current != (Object)null))
						{
							continue;
						}
						try
						{
							if (showOnlyUnlocked)
							{
								try
								{
									if (!MyAchievements.IsAvailable((UnlockableBase)(object)current))
									{
										val = log;
										if (val != null)
										{
											BepInExDebugLogInterpolatedStringHandler val4 = new BepInExDebugLogInterpolatedStringHandler(24, 1, ref flag);
											if (flag)
											{
												((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("Skipping locked weapon: ");
												((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<string>(((Object)current).name);
											}
											val.LogDebug(val4);
										}
										continue;
									}
								}
								catch (Exception ex)
								{
									val = log;
									if (val != null)
									{
										BepInExDebugLogInterpolatedStringHandler val4 = new BepInExDebugLogInterpolatedStringHandler(62, 2, ref flag);
										if (flag)
										{
											((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("MyAchievements.IsAvailable failed for weapon ");
											((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<string>(((Object)current).name);
											((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(": ");
											((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<string>(ex.Message);
											((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(" - including it");
										}
										val.LogDebug(val4);
									}
								}
							}
							string text = null;
							try
							{
								text = ((UnlockableBase)current).GetName();
							}
							catch
							{
							}
							string name = ((Object)current).name;
							string text2 = ((!string.IsNullOrEmpty(text)) ? text : name);
							if (string.IsNullOrEmpty(text2))
							{
								continue;
							}
							string text3 = FormatItemName(text2);
							ItemNameResolver.RegisterAliasGroup(text, name, text3);
							hashSet.Add(text3);
							val = log;
							if (val != null)
							{
								BepInExDebugLogInterpolatedStringHandler val4 = new BepInExDebugLogInterpolatedStringHandler(49, 3, ref flag);
								if (flag)
								{
									((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("Discovered weapon: '");
									((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<string>(text3);
									((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("' (display: '");
									((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<string>(text);
									((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("', internal: '");
									((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<string>(name);
									((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("')");
								}
								val.LogDebug(val4);
							}
						}
						catch (Exception ex2)
						{
							val = log;
							if (val != null)
							{
								BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(27, 1, ref flag);
								if (flag)
								{
									((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Failed to get weapon name: ");
									((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex2.Message);
								}
								val.LogWarning(val2);
							}
						}
					}
				}
				List<TomeData> allTomes = DataManager.Instance.GetAllTomes();
				if (allTomes != null)
				{
					Enumerator<TomeData> enumerator2 = allTomes.GetEnumerator();
					while (enumerator2.MoveNext())
					{
						TomeData current2 = enumerator2.Current;
						if (!((Object)(object)current2 != (Object)null))
						{
							continue;
						}
						try
						{
							if (showOnlyUnlocked)
							{
								try
								{
									if (!MyAchievements.IsAvailable((UnlockableBase)(object)current2))
									{
										val = log;
										if (val != null)
										{
											BepInExDebugLogInterpolatedStringHandler val4 = new BepInExDebugLogInterpolatedStringHandler(22, 1, ref flag);
											if (flag)
											{
												((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("Skipping locked tome: ");
												((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<string>(((Object)current2).name);
											}
											val.LogDebug(val4);
										}
										continue;
									}
								}
								catch (Exception ex3)
								{
									val = log;
									if (val != null)
									{
										BepInExDebugLogInterpolatedStringHandler val4 = new BepInExDebugLogInterpolatedStringHandler(60, 2, ref flag);
										if (flag)
										{
											((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("MyAchievements.IsAvailable failed for tome ");
											((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<string>(((Object)current2).name);
											((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(": ");
											((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<string>(ex3.Message);
											((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(" - including it");
										}
										val.LogDebug(val4);
									}
								}
							}
							string text4 = null;
							try
							{
								text4 = ((UnlockableBase)current2).GetName();
							}
							catch
							{
							}
							string name2 = ((Object)current2).name;
							string text5 = ((!string.IsNullOrEmpty(text4)) ? text4 : name2);
							if (string.IsNullOrEmpty(text5))
							{
								continue;
							}
							string text6 = FormatItemName(text5, isTome: true);
							ItemNameResolver.RegisterAliasGroup(text4, name2, text6);
							hashSet2.Add(text6);
							val = log;
							if (val != null)
							{
								BepInExDebugLogInterpolatedStringHandler val4 = new BepInExDebugLogInterpolatedStringHandler(47, 3, ref flag);
								if (flag)
								{
									((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("Discovered tome: '");
									((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<string>(text6);
									((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("' (display: '");
									((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<string>(text4);
									((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("', internal: '");
									((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<string>(name2);
									((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("')");
								}
								val.LogDebug(val4);
							}
						}
						catch (Exception ex4)
						{
							val = log;
							if (val != null)
							{
								BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(25, 1, ref flag);
								if (flag)
								{
									((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Failed to get tome name: ");
									((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex4.Message);
								}
								val.LogWarning(val2);
							}
						}
					}
				}
				discoveredWeapons = hashSet;
				discoveredTomes = hashSet2;
				val = log;
				if (val != null)
				{
					BepInExInfoLogInterpolatedStringHandler val5 = new BepInExInfoLogInterpolatedStringHandler(24, 0, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("=== DISCOVERED ITEMS ===");
					}
					val.LogInfo(val5);
				}
				val = log;
				if (val != null)
				{
					BepInExInfoLogInterpolatedStringHandler val5 = new BepInExInfoLogInterpolatedStringHandler(12, 2, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("Weapons (");
						((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<int>(hashSet.Count);
						((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("): ");
						((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<string>(string.Join(", ", hashSet));
					}
					val.LogInfo(val5);
				}
				val = log;
				if (val != null)
				{
					BepInExInfoLogInterpolatedStringHandler val5 = new BepInExInfoLogInterpolatedStringHandler(10, 2, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("Tomes (");
						((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<int>(hashSet2.Count);
						((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("): ");
						((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<string>(string.Join(", ", hashSet2));
					}
					val.LogInfo(val5);
				}
				val = log;
				if (val != null)
				{
					BepInExInfoLogInterpolatedStringHandler val5 = new BepInExInfoLogInterpolatedStringHandler(21, 0, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("=== END DISCOVERY ===");
					}
					val.LogInfo(val5);
				}
			}
			catch (Exception ex5)
			{
				ManualLogSource val = log;
				if (val != null)
				{
					BepInExErrorLogInterpolatedStringHandler val3 = new BepInExErrorLogInterpolatedStringHandler(21, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("DiscoverItems error: ");
						((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(ex5.Message);
					}
					val.LogError(val3);
				}
			}
		}

		public static List<string> GetDiscoveredWeapons()
		{
			return discoveredWeapons.OrderBy((string w) => w).ToList();
		}

		public static List<string> GetDiscoveredTomes()
		{
			return discoveredTomes.OrderBy((string t) => t).ToList();
		}

		public void AddNotification(string message)
		{
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Expected O, but got Unknown
			notifications.Add(new Notification
			{
				itemName = message,
				rarity = "Common",
				fromLevel = 0,
				toLevel = 0,
				choices = new List<(string, string)>(),
				timestamp = Time.time
			});
			ManualLogSource val = log;
			if (val != null)
			{
				bool flag = default(bool);
				BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(14, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Notification: ");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(message);
				}
				val.LogInfo(val2);
			}
		}

		public void AddNotificationWithRarity(string itemName, string rarity, int fromLevel, int toLevel, List<(string, string)> choices)
		{
			while (notifications.Count >= 4)
			{
				notifications.RemoveAt(0);
			}
			notifications.Add(new Notification
			{
				itemName = itemName,
				rarity = rarity,
				fromLevel = fromLevel,
				toLevel = toLevel,
				choices = choices,
				timestamp = Time.time
			});
		}

		private void DrawNotifications()
		{
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Expected O, but got Unknown
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Expected O, but got Unknown
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Expected O, but got Unknown
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Expected O, but got Unknown
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_031d: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_041c: 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_0460: Unknown result type (might be due to invalid IL or missing references)
			//IL_039f: 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)
			if (notifications.Count == 0)
			{
				return;
			}
			float currentTime = Time.time;
			if (notifications.Count > 0 && currentTime - notifications[0].timestamp > 60f)
			{
				notifications.RemoveAll((Notification n) => currentTime - n.timestamp > 60f);
				if (notifications.Count == 0)
				{
					return;
				}
			}
			if (cachedSelectedStyle == null)
			{
				cachedSelectedStyle = new GUIStyle(GUI.skin.label);
				cachedSelectedStyle.fontSize = 20;
				cachedSelectedStyle.fontStyle = (FontStyle)1;
				cachedSelectedStyle.wordWrap = false;
				cachedSelectedStyle.clipping = (TextClipping)0;
				cachedChoiceStyle = new GUIStyle(GUI.skin.label);
				cachedChoiceStyle.fontSize = 14;
				cachedChoiceStyle.fontStyle = (FontStyle)0;
				cachedChoiceStyle.clipping = (TextClipping)0;
				cachedChoicesPrefixWidth = cachedChoiceStyle.CalcSize(new GUIContent("Choices: ")).x;
				cachedBulletWidth = cachedChoiceStyle.CalcSize(new GUIContent(" • ")).x;
			}
			float num = 700f;
			float num2 = 280f;
			Rect val = default(Rect);
			((Rect)(ref val))..ctor(20f, (float)Screen.height - num2 - 120f, num, num2);
			Color backgroundColor = GUI.backgroundColor;
			GUI.backgroundColor = new Color(0f, 0f, 0f, 0.3f);
			GUI.Box(val, "", GUI.skin.box);
			GUI.backgroundColor = backgroundColor;
			int count = notifications.Count;
			float num3 = ((Rect)(ref val)).y + 25f;
			for (int num4 = count - 1; num4 >= 0; num4--)
			{
				Notification notification = notifications[num4];
				float num5 = currentTime - notification.timestamp;
				float num6 = 1f - num5 / 60f * 0.5f;
				string text = ((notification.toLevel > 0) ? $"→ {notification.itemName} (Lv{notification.fromLevel} → Lv{notification.toLevel})" : ("→ " + notification.itemName));
				cachedSelectedStyle.normal.textColor = new Color(0f, 0f, 0f, num6 * 0.7f);
				GUI.Label(new Rect(((Rect)(ref val)).x + 11f, num3 + 1f, num - 20f, 28f), text, cachedSelectedStyle);
				cachedSelectedStyle.normal.textColor = GetRarityColor(notification.rarity, num6);
				GUI.Label(new Rect(((Rect)(ref val)).x + 10f, num3, num - 20f, 28f), text, cachedSelectedStyle);
				num3 += 26f;
				if (notification.choices != null && notification.choices.Count > 0)
				{
					float num7 = ((Rect)(ref val)).x + 20f;
					for (int i = 0; i < notification.choices.Count; i++)
					{
						(string, string) tuple = notification.choices[i];
						if (i > 0)
						{
							cachedChoiceStyle.normal.textColor = new Color(0.5f, 0.5f, 0.5f, num6);
							GUI.Label(new Rect(num7, num3, 40f, 22f), "  •  ", cachedChoiceStyle);
							num7 += 32f;
						}
						cachedChoiceStyle.normal.textColor = new Color(0f, 0f, 0f, num6 * 0.7f);
						GUI.Label(new Rect(num7 + 1f, num3 + 1f, 280f, 22f), tuple.Item1, cachedChoiceStyle);
						cachedChoiceStyle.normal.textColor = GetRarityColor(tuple.Item2, num6);
						GUI.Label(new Rect(num7, num3, 280f, 22f), tuple.Item1, cachedChoiceStyle);
						num7 += (float)(tuple.Item1.Length * 8 + 10);
					}
					num3 += 22f;
				}
				num3 += 12f;
			}
		}

		private Color GetRarityColor(string rarity, float alpha)
		{
			//IL_019e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0172: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: 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_0146: 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)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: Unknown result type (might be due to invalid IL or missing references)
			return (Color)(rarity switch
			{
				"Common" => new Color(0.4f, 1f, 0.4f, alpha), 
				"Uncommon" => new Color(0.3f, 0.7f, 1f, alpha), 
				"Rare" => new Color(0.8f, 0.4f, 1f, alpha), 
				"Epic" => new Color(1f, 0.3f, 0.3f, alpha), 
				"Legendary" => new Color(1f, 0.9f, 0.2f, alpha), 
				"New" => new Color(1f, 1f, 1f, alpha), 
				"NotInList" => new Color(0.5f, 0.5f, 0.5f, alpha), 
				_ => new Color(0.5f, 0.5f, 0.5f, alpha), 
			});
		}

		public void ClearNotifications()
		{
			notifications.Clear();
			ManualLogSource obj = log;
			if (obj != null)
			{
				obj.LogInfo((object)"Notifications cleared");
			}
		}
	}
}
namespace AutoUpgradeMod.Models
{
	[Serializable]
	public class PriorityItem
	{
		public string itemName;

		public bool isWeapon;

		public int maxLevel;

		public string TypeLabel
		{
			get
			{
				if (!isWeapon)
				{
					return "T";
				}
				return "W";
			}
		}

		public string MaxLevelDisplay
		{
			get
			{
				if (maxLevel != -1)
				{
					return maxLevel.ToString();
				}
				return "∞";
			}
		}

		public PriorityItem()
		{
			itemName = string.Empty;
			isWeapon = true;
			maxLevel = -1;
		}

		public PriorityItem(string name, bool weapon, int max)
		{
			itemName = name;
			isWeapon = weapon;
			maxLevel = max;
		}
	}
	[Serializable]
	public class SavedLoadout
	{
		public string name;

		public List<PriorityItem> items;

		public SavedLoadout()
		{
			name = string.Empty;
			items = new List<PriorityItem>();
		}

		public SavedLoadout(string loadoutName, List<PriorityItem> priorityItems)
		{
			name = loadoutName;
			items = priorityItems ?? new List<PriorityItem>();
		}
	}
	public class SelectionWeights
	{
		public int PriorityOrderWeight { get; set; }

		public int RarityWeight { get; set; }

		public int NewItemWeight { get; set; }

		public int AtMaxPenalty { get; set; }
	}
}
namespace AutoUpgradeMod.Core
{
	public static class AutoSelector
	{
		private static ManualLogSource log;

		public static void Initialize(ManualLogSource logger)
		{
			log = logger;
			log.LogInfo((object)"AutoSelector initialized");
		}

		public static bool ProcessAutoSelection(UpgradePicker picker)
		{
			//IL_05a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a8: Expected O, but got Unknown
			//IL_052b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0532: Expected O, but got Unknown
			//IL_0561: Unknown result type (might be due to invalid IL or missing references)
			//IL_0568: Expected O, but got Unknown
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Expected O, but got Unknown
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_01af: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0205: Expected O, but got Unknown
			//IL_040b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0412: Expected O, but got Unknown
			//IL_0464: Unknown result type (might be due to invalid IL or missing references)
			bool flag = default(bool);
			try
			{
				if ((Object)(object)picker == (Object)null)
				{
					log.LogError((object)"AutoSelector: Picker is null, cannot process selection");
					return true;
				}
				Il2CppReferenceArray<UpgradeButton> buttons = picker.buttons;
				if (buttons == null || ((Il2CppArrayBase<UpgradeButton>)(object)buttons).Count == 0)
				{
					log.LogWarning((object)"AutoSelector: No upgrade buttons available");
					return true;
				}
				log.LogInfo((object)"=== LEVEL-UP CHOICES ===");
				BepInExInfoLogInterpolatedStringHandler val;
				foreach (UpgradeButton item in (Il2CppArrayBase<UpgradeButton>)(object)picker.buttons)
				{
					if ((Object)(object)item != (Object)null && !item.isItem)
					{
						string upgradeName = GetUpgradeName(item);
						ManualLogSource obj = log;
						val = new BepInExInfoLogInterpolatedStringHandler(21, 2, ref flag);
						if (flag)
						{
							((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Choice: '");
							((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(upgradeName);
							((BepInExLogInterpolatedStringHandler)val).AppendLiteral("' (rarity: ");
							((BepInExLogInterpolatedStringHandler)val).AppendFormatted<ERarity>(item.rarity);
							((BepInExLogInterpolatedStringHandler)val).AppendLiteral(")");
						}
						obj.LogInfo(val);
					}
				}
				log.LogInfo((object)"=== END CHOICES ===");
				List<PriorityItem> priorityList = PriorityManager.GetPriorityList();
				if (priorityList.Count == 0)
				{
					log.LogInfo((object)"AutoSelector: Priority list is empty - skipping auto-selection");
					EnsureLevelupScreenVisible(picker);
					return true;
				}
				List<(int, string, UpgradeButton, int)> list = new List<(int, string, UpgradeButton, int)>();
				List<(int priorityIndex, string itemName, UpgradeButton button, int rarityRank, bool atMaxLevel)> allAvailable = new List<(int, string, UpgradeButton, int, bool)>();
				for (int i = 0; i < priorityList.Count; i++)
				{
					PriorityItem priorityItem = priorityList[i];
					string itemName = priorityItem.itemName;
					int maxLevel = priorityItem.maxLevel;
					UpgradeButton val2 = IsItemAvailable(picker, itemName);
					if (!((Object)(object)val2 == (Object)null))
					{
						int currentLevel = GetCurrentLevel(picker, itemName);
						bool flag2 = IsAtMaxLevel(currentLevel, maxLevel);
						ERarity rarity = val2.rarity;
						string text = ((object)(ERarity)(ref rarity)).ToString();
						if (text == "New")
						{
							flag2 = false;
						}
						int rarityRank = GetRarityRank(text);
						allAvailable.Add((i, itemName, val2, rarityRank, flag2));
						ManualLogSource obj2 = log;
						val = new BepInExInfoLogInterpolatedStringHandler(40, 5, ref flag);
						if (flag)
						{
							((BepInExLogInterpolatedStringHandler)val).A