Decompiled source of LoadoutPresets v1.0.0

LoadoutPresets.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.Json;
using Assets.Scripts.Actors.Player;
using Assets.Scripts.Inventory__Items__Pickups;
using Assets.Scripts.Managers;
using Assets.Scripts.Saves___Serialization.Progression.Achievements;
using BepInEx;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using HarmonyLib;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSystem;
using Il2CppSystem.Collections.Generic;
using Il2CppSystem.Reflection;
using Microsoft.CodeAnalysis;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("LoadoutPresets")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Adds a Loadout Presets Manager to Megabonk")]
[assembly: AssemblyFileVersion("0.1.4.0")]
[assembly: AssemblyInformationalVersion("0.1.4+42248037cd50f9385d8d576cea08e860e64059b0")]
[assembly: AssemblyProduct("LoadoutPresets")]
[assembly: AssemblyTitle("LoadoutPresets")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.4.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 LoadoutPresets
{
	internal static class ButtonFactory
	{
		public static Button CreateNativeButton(GameObject templateButton, string buttonName, string buttonText, string iconName, Transform customParent = null)
		{
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Expected O, but got Unknown
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Expected O, but got Unknown
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Expected O, but got Unknown
			GameObject val = Object.Instantiate<GameObject>(templateButton);
			((Object)val).name = buttonName;
			Transform val2 = customParent ?? templateButton.transform.parent;
			val.transform.SetParent(val2, false);
			bool flag = default(bool);
			if ((Object)(object)customParent == (Object)null)
			{
				val.transform.SetSiblingIndex(templateButton.transform.GetSiblingIndex());
				ManualLogSource logger = LoadoutPresets.Logger;
				BepInExDebugLogInterpolatedStringHandler val3 = new BepInExDebugLogInterpolatedStringHandler(62, 3, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("ButtonFactory: Set hierarchy for '");
					((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(buttonName);
					((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("' at SiblingIndex ");
					((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<int>(val.transform.GetSiblingIndex());
					((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" under '");
					((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(((Object)val2).name);
					((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("'.");
				}
				logger.LogDebug(val3);
			}
			else
			{
				ManualLogSource logger2 = LoadoutPresets.Logger;
				BepInExDebugLogInterpolatedStringHandler val3 = new BepInExDebugLogInterpolatedStringHandler(49, 2, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("ButtonFactory: Set custom parent for '");
					((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(buttonName);
					((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("' under '");
					((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(((Object)val2).name);
					((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("'.");
				}
				logger2.LogDebug(val3);
			}
			StripNonVisualComponents(val);
			Transform val4 = val.transform.Find("Icon");
			if (Object.op_Implicit((Object)(object)val4))
			{
				if (!string.IsNullOrEmpty(iconName))
				{
					SetButtonIcon(val4, iconName);
				}
				else
				{
					((Component)val4).gameObject.SetActive(false);
					ManualLogSource logger3 = LoadoutPresets.Logger;
					BepInExDebugLogInterpolatedStringHandler val3 = new BepInExDebugLogInterpolatedStringHandler(46, 0, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("ButtonFactory: No icon requested, hiding icon.");
					}
					logger3.LogDebug(val3);
				}
			}
			Button orAddComponent = val.GetOrAddComponent<Button>();
			SetupNativeBehavior(orAddComponent, templateButton, buttonText);
			return orAddComponent;
		}

		private static void StripNonVisualComponents(GameObject targetGameObject)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: 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
			Il2CppArrayBase<Component> components = targetGameObject.GetComponents<Component>();
			ManualLogSource logger = LoadoutPresets.Logger;
			bool flag = default(bool);
			BepInExDebugLogInterpolatedStringHandler val = new BepInExDebugLogInterpolatedStringHandler(57, 2, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("ButtonFactory: Analyzing ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(components.Length);
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" components for stripping on '");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(((Object)targetGameObject).name);
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("'.");
			}
			logger.LogDebug(val);
			foreach (Component item in components)
			{
				string name = ((MemberInfo)((Object)item).GetIl2CppType()).Name;
				switch (name)
				{
				case "RectTransform":
				case "CanvasRenderer":
				case "Image":
				case "Mask":
					continue;
				}
				ManualLogSource logger2 = LoadoutPresets.Logger;
				val = new BepInExDebugLogInterpolatedStringHandler(45, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("ButtonFactory: Stripping native component '");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(name);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("'.");
				}
				logger2.LogDebug(val);
				Object.DestroyImmediate((Object)(object)item);
			}
		}

		private static void SetButtonIcon(Transform iconTransform, string textureName)
		{
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Expected O, but got Unknown
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Expected O, but got Unknown
			if ((Object)(object)iconTransform == (Object)null)
			{
				return;
			}
			RawImage component = ((Component)iconTransform).GetComponent<RawImage>();
			if ((Object)(object)component == (Object)null)
			{
				return;
			}
			Texture2D val = ((IEnumerable<Texture2D>)Resources.FindObjectsOfTypeAll<Texture2D>()).FirstOrDefault((Func<Texture2D, bool>)((Texture2D t) => ((Object)t).name == textureName));
			bool flag = default(bool);
			if ((Object)(object)val != (Object)null)
			{
				component.texture = (Texture)(object)val;
				((Graphic)component).color = Color.white;
				((Component)iconTransform).gameObject.SetActive(true);
				ManualLogSource logger = LoadoutPresets.Logger;
				BepInExDebugLogInterpolatedStringHandler val2 = new BepInExDebugLogInterpolatedStringHandler(58, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("ButtonFactory: Assigned texture '");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(textureName);
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("' to icon and set active.");
				}
				logger.LogDebug(val2);
			}
			else
			{
				((Component)iconTransform).gameObject.SetActive(false);
				ManualLogSource logger2 = LoadoutPresets.Logger;
				BepInExWarningLogInterpolatedStringHandler val3 = new BepInExWarningLogInterpolatedStringHandler(32, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("Texture ");
					((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(textureName);
					((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" not found. Hiding icon.");
				}
				logger2.LogWarning(val3);
			}
		}

		private static void SetupNativeBehavior(Button targetButtonComponent, GameObject templateSourceGameObject, string newTextValue)
		{
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Expected O, but got Unknown
			//IL_01df: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e6: Expected O, but got Unknown
			//IL_0182: Unknown result type (might be due to invalid IL or missing references)
			//IL_0189: Expected O, but got Unknown
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Expected O, but got Unknown
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Expected O, but got Unknown
			//IL_0220: Unknown result type (might be due to invalid IL or missing references)
			//IL_022c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0247: Unknown result type (might be due to invalid IL or missing references)
			//IL_024e: Expected O, but got Unknown
			//IL_0261: Unknown result type (might be due to invalid IL or missing references)
			GameObject gameObject = ((Component)targetButtonComponent).gameObject;
			MyButtonNormal val = gameObject.AddComponent<MyButtonNormal>();
			MyButtonNormal component = templateSourceGameObject.GetComponent<MyButtonNormal>();
			Image component2 = ((Component)targetButtonComponent).GetComponent<Image>();
			bool flag = default(bool);
			BepInExDebugLogInterpolatedStringHandler val2;
			if (Object.op_Implicit((Object)(object)component2) && (Object)(object)component2.sprite == (Object)null)
			{
				Image component3 = templateSourceGameObject.GetComponent<Image>();
				if (Object.op_Implicit((Object)(object)component3) && (Object)(object)component3.sprite != (Object)null)
				{
					component2.sprite = component3.sprite;
					ManualLogSource logger = LoadoutPresets.Logger;
					val2 = new BepInExDebugLogInterpolatedStringHandler(70, 0, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("ButtonFactory: Assigned sprite from template to prevent layout errors.");
					}
					logger.LogDebug(val2);
				}
				else
				{
					Sprite val3 = ((IEnumerable<Sprite>)Resources.FindObjectsOfTypeAll<Sprite>()).FirstOrDefault();
					if ((Object)(object)val3 != (Object)null)
					{
						component2.sprite = val3;
						ManualLogSource logger2 = LoadoutPresets.Logger;
						val2 = new BepInExDebugLogInterpolatedStringHandler(68, 1, ref flag);
						if (flag)
						{
							((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("ButtonFactory: Assigned fallback sprite '");
							((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(((Object)val3).name);
							((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("' to prevent layout errors.");
						}
						logger2.LogDebug(val2);
					}
				}
			}
			val.background = (MaskableGraphic)(object)component2;
			((Selectable)targetButtonComponent).transition = (Transition)0;
			ManualLogSource logger3 = LoadoutPresets.Logger;
			val2 = new BepInExDebugLogInterpolatedStringHandler(79, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("ButtonFactory: Linked background image to '");
				((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(((Object)gameObject).name);
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("' and disabled standard transitions.");
			}
			logger3.LogDebug(val2);
			Transform val4 = ((Component)targetButtonComponent).transform.Find("T_Text");
			if (Object.op_Implicit((Object)(object)val4))
			{
				((MyButton)val).scaleOnHover = val4;
				if (Object.op_Implicit((Object)(object)component))
				{
					((MyButton)val).hoverScale = ((MyButton)component).hoverScale;
					ManualLogSource logger4 = LoadoutPresets.Logger;
					val2 = new BepInExDebugLogInterpolatedStringHandler(60, 2, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("ButtonFactory: Linked scaleOnHover to '");
						((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(((Object)val4).name);
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("' with scale factor ");
						((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<float>(((MyButton)val).hoverScale);
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(".");
					}
					logger4.LogDebug(val2);
				}
			}
			else
			{
				ManualLogSource logger5 = LoadoutPresets.Logger;
				BepInExWarningLogInterpolatedStringHandler val5 = new BepInExWarningLogInterpolatedStringHandler(63, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("ButtonFactory: Could not find 'T_Text' child for scaling on '");
					((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<string>(((Object)gameObject).name);
					((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("'.");
				}
				logger5.LogWarning(val5);
			}
			if (Object.op_Implicit((Object)(object)component))
			{
				val.defaultColor = component.defaultColor;
				val.hoverColor = component.hoverColor;
				val.colorInited = true;
				ManualLogSource logger6 = LoadoutPresets.Logger;
				val2 = new BepInExDebugLogInterpolatedStringHandler(53, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("ButtonFactory: Copied colors from template (Hover: ");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<Color>(val.hoverColor);
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(").");
				}
				logger6.LogDebug(val2);
			}
			UpdateTextComponent(((Component)targetButtonComponent).transform, newTextValue);
			SetupEventTriggers(targetButtonComponent);
		}

		private static void UpdateTextComponent(Transform buttonTransform, string newTextValue)
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Expected O, but got Unknown
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Expected O, but got Unknown
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Expected O, but got Unknown
			Transform val = buttonTransform.Find("T_Text");
			bool flag = default(bool);
			if (!Object.op_Implicit((Object)(object)val))
			{
				ManualLogSource logger = LoadoutPresets.Logger;
				BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(72, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("ButtonFactory: UpdateTextComponent failed - 'T_Text' not found under '");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(((Object)((Component)buttonTransform).gameObject).name);
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("'.");
				}
				logger.LogError(val2);
				return;
			}
			GameObject gameObject = ((Component)val).gameObject;
			((Object)gameObject).name = ((Object)((Component)buttonTransform).gameObject).name + "_Text_Protected";
			TextMeshProUGUI component = gameObject.GetComponent<TextMeshProUGUI>();
			if (Object.op_Implicit((Object)(object)component))
			{
				((TMP_Text)component).text = newTextValue;
				ManualLogSource logger2 = LoadoutPresets.Logger;
				BepInExDebugLogInterpolatedStringHandler val3 = new BepInExDebugLogInterpolatedStringHandler(66, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("ButtonFactory: Updated text value to '");
					((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(newTextValue);
					((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("' and protected object name.");
				}
				logger2.LogDebug(val3);
			}
			foreach (Component component2 in gameObject.GetComponents<Component>())
			{
				string name = ((MemberInfo)((Object)component2).GetIl2CppType()).Name;
				if (name.Contains("Localize"))
				{
					ManualLogSource logger3 = LoadoutPresets.Logger;
					BepInExDebugLogInterpolatedStringHandler val3 = new BepInExDebugLogInterpolatedStringHandler(76, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("ButtonFactory: Destroying localization component '");
						((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(name);
						((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("' to prevent text reverts.");
					}
					logger3.LogDebug(val3);
					Object.DestroyImmediate((Object)(object)component2);
				}
			}
		}

		private static void SetupEventTriggers(Button targetButtonComponent)
		{
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Expected O, but got Unknown
			EventTrigger triggerComponent = ((Component)targetButtonComponent).gameObject.AddComponent<EventTrigger>();
			AddTrigger(triggerComponent, (EventTriggerType)9, delegate
			{
				//IL_0035: Unknown result type (might be due to invalid IL or missing references)
				//IL_003b: Expected O, but got Unknown
				if ((Object)(object)targetButtonComponent == (Object)null || ((Il2CppObjectBase)targetButtonComponent).WasCollected)
				{
					LoadoutPresets.Logger.LogDebug((object)"Button Event [Select]: Button was destroyed, skipping.");
				}
				else
				{
					ManualLogSource logger4 = LoadoutPresets.Logger;
					bool flag4 = default(bool);
					BepInExDebugLogInterpolatedStringHandler val5 = new BepInExDebugLogInterpolatedStringHandler(26, 1, ref flag4);
					if (flag4)
					{
						((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("Button Event: '");
						((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<string>(((Object)((Component)targetButtonComponent).gameObject).name);
						((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("' Selected.");
					}
					logger4.LogDebug(val5);
					MyButtonNormal component3 = ((Component)targetButtonComponent).GetComponent<MyButtonNormal>();
					if (Object.op_Implicit((Object)(object)component3) && !((Il2CppObjectBase)component3).WasCollected)
					{
						((MyButton)component3).StartHover();
					}
				}
			});
			AddTrigger(triggerComponent, (EventTriggerType)10, delegate
			{
				//IL_0035: Unknown result type (might be due to invalid IL or missing references)
				//IL_003b: Expected O, but got Unknown
				if ((Object)(object)targetButtonComponent == (Object)null || ((Il2CppObjectBase)targetButtonComponent).WasCollected)
				{
					LoadoutPresets.Logger.LogDebug((object)"Button Event [Deselect]: Button was destroyed, skipping.");
				}
				else
				{
					ManualLogSource logger3 = LoadoutPresets.Logger;
					bool flag3 = default(bool);
					BepInExDebugLogInterpolatedStringHandler val3 = new BepInExDebugLogInterpolatedStringHandler(28, 1, ref flag3);
					if (flag3)
					{
						((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("Button Event: '");
						((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(((Object)((Component)targetButtonComponent).gameObject).name);
						((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("' Deselected.");
					}
					logger3.LogDebug(val3);
					MyButtonNormal component2 = ((Component)targetButtonComponent).GetComponent<MyButtonNormal>();
					if (Object.op_Implicit((Object)(object)component2) && !((Il2CppObjectBase)component2).WasCollected)
					{
						((MyButton)component2).StopHover();
					}
					Transform val4 = ((Component)targetButtonComponent).transform.Find("DisabledOverlay");
					if (Object.op_Implicit((Object)(object)val4))
					{
						((Component)val4).gameObject.SetActive(false);
					}
				}
			});
			AddTrigger(triggerComponent, (EventTriggerType)4, delegate
			{
				//IL_0035: Unknown result type (might be due to invalid IL or missing references)
				//IL_003b: Expected O, but got Unknown
				if ((Object)(object)targetButtonComponent == (Object)null || ((Il2CppObjectBase)targetButtonComponent).WasCollected)
				{
					LoadoutPresets.Logger.LogDebug((object)"Button Event [PointerClick]: Button was destroyed, skipping.");
				}
				else
				{
					ManualLogSource logger2 = LoadoutPresets.Logger;
					bool flag2 = default(bool);
					BepInExDebugLogInterpolatedStringHandler val2 = new BepInExDebugLogInterpolatedStringHandler(30, 1, ref flag2);
					if (flag2)
					{
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Button Event: '");
						((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(((Object)((Component)targetButtonComponent).gameObject).name);
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("' PointerClick.");
					}
					logger2.LogDebug(val2);
					MyButtonNormal component = ((Component)targetButtonComponent).GetComponent<MyButtonNormal>();
					if (Object.op_Implicit((Object)(object)component) && !((Il2CppObjectBase)component).WasCollected)
					{
						((MyButton)component).StartHover();
					}
				}
			});
			ManualLogSource logger = LoadoutPresets.Logger;
			bool flag = default(bool);
			BepInExDebugLogInterpolatedStringHandler val = new BepInExDebugLogInterpolatedStringHandler(80, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("ButtonFactory: Configured EventTriggers (Select, Deselect, PointerClick) for '");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(((Object)((Component)targetButtonComponent).gameObject).name);
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("'.");
			}
			logger.LogDebug(val);
		}

		private static void AddTrigger(EventTrigger triggerComponent, EventTriggerType triggerType, Action<BaseEventData> triggerAction)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Expected O, but got Unknown
			Entry val = new Entry
			{
				eventID = triggerType
			};
			((UnityEvent<BaseEventData>)(object)val.callback).AddListener(UnityAction<BaseEventData>.op_Implicit(triggerAction));
			triggerComponent.triggers.Add(val);
		}
	}
	internal static class CharacterSelectFactory
	{
		public static GameObject CloneCharacterSelect(GameObject characterSelectTemplate, Transform newParent)
		{
			if (!Object.op_Implicit((Object)(object)characterSelectTemplate))
			{
				LoadoutPresets.Logger.LogError((object)"CharacterSelectFactory: Character grid template is null.");
				return null;
			}
			GameObject obj = Object.Instantiate<GameObject>(characterSelectTemplate, newParent);
			((Object)obj).name = "W_LoadoutCharacterSelector";
			obj.SetActive(false);
			StripGameLogicFromMenu(obj);
			ModifyCharacterSelectStructure(obj);
			LoadoutPresets.Logger.LogDebug((object)"CharacterSelectFactory: Successfully cloned character grid for Loadouts menu.");
			return obj;
		}

		private static void StripGameLogicFromMenu(GameObject characterSelect)
		{
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Expected O, but got Unknown
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Expected O, but got Unknown
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Expected O, but got Unknown
			//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b5: Expected O, but got Unknown
			Transform val = characterSelect.transform.Find("Header/Header/B_Back");
			CharacterPrefabUI componentInChildren = characterSelect.GetComponentInChildren<CharacterPrefabUI>(true);
			Transform transform = characterSelect.transform;
			bool flag = default(bool);
			BepInExDebugLogInterpolatedStringHandler val2;
			for (int i = 0; i < transform.childCount; i++)
			{
				Transform child = transform.GetChild(i);
				if (((Object)child).name.Contains("W_Stats"))
				{
					((Component)child).gameObject.SetActive(false);
					ManualLogSource logger = LoadoutPresets.Logger;
					val2 = new BepInExDebugLogInterpolatedStringHandler(49, 0, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("CharacterSelectFactory: Deactivated W_Stats panel");
					}
					logger.LogDebug(val2);
					break;
				}
			}
			Il2CppArrayBase<Transform> componentsInChildren = characterSelect.GetComponentsInChildren<Transform>(true);
			ManualLogSource logger2 = LoadoutPresets.Logger;
			val2 = new BepInExDebugLogInterpolatedStringHandler(61, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("CharacterSelectFactory: Processing ");
				((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(componentsInChildren.Length);
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" GameObjects in hierarchy.");
			}
			logger2.LogDebug(val2);
			foreach (Transform item in componentsInChildren)
			{
				if ((Object)(object)item == (Object)null)
				{
					continue;
				}
				if (Object.op_Implicit((Object)(object)componentInChildren) && ((Object)(object)item == (Object)(object)((Component)componentInChildren).transform || item.IsChildOf(((Component)componentInChildren).transform)))
				{
					ManualLogSource logger3 = LoadoutPresets.Logger;
					val2 = new BepInExDebugLogInterpolatedStringHandler(66, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("CharacterSelectFactory: Skipping CharacterPrefabUI subtree for '");
						((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(((Object)item).name);
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("'.");
					}
					logger3.LogDebug(val2);
					continue;
				}
				foreach (Component component2 in ((Component)item).GetComponents<Component>())
				{
					if ((Object)(object)component2 == (Object)null)
					{
						continue;
					}
					string name = ((MemberInfo)((Object)component2).GetIl2CppType()).Name;
					if (name.Contains("Localize"))
					{
						ManualLogSource logger4 = LoadoutPresets.Logger;
						val2 = new BepInExDebugLogInterpolatedStringHandler(67, 2, ref flag);
						if (flag)
						{
							((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("CharacterSelectFactory: Destroying localization component '");
							((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(name);
							((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("' on '");
							((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(((Object)item).name);
							((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("'.");
						}
						logger4.LogDebug(val2);
						Object.DestroyImmediate((Object)(object)component2);
					}
				}
			}
			if (Object.op_Implicit((Object)(object)val))
			{
				Button component = ((Component)val).GetComponent<Button>();
				if (Object.op_Implicit((Object)(object)component))
				{
					((UnityEventBase)component.onClick).RemoveAllListeners();
					((UnityEvent)component.onClick).AddListener(UnityAction.op_Implicit((Action)LoadoutsMenu.CloseCharacterSelect));
					LoadoutPresets.Logger.LogDebug((object)"CharacterSelectFactory: Configured B_Back button with close handler.");
				}
			}
		}

		private static void ModifyCharacterSelectStructure(GameObject characterSelectMenu)
		{
			//IL_001d: 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_0047: 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_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Expected O, but got Unknown
			RectTransform component = characterSelectMenu.GetComponent<RectTransform>();
			if (!Object.op_Implicit((Object)(object)component))
			{
				return;
			}
			component.anchorMin = new Vector2(0f, 0.5f);
			component.anchorMax = new Vector2(0f, 0.5f);
			component.pivot = new Vector2(1f, 0.5f);
			component.anchoredPosition = new Vector2(-10f, 0f);
			RectTransform component2 = ((Component)characterSelectMenu.transform.parent).GetComponent<RectTransform>();
			if (Object.op_Implicit((Object)(object)component2))
			{
				Rect rect = component2.rect;
				float height = ((Rect)(ref rect)).height;
				component.sizeDelta = new Vector2(650f, height);
				ManualLogSource logger = LoadoutPresets.Logger;
				bool flag = default(bool);
				BepInExDebugLogInterpolatedStringHandler val = new BepInExDebugLogInterpolatedStringHandler(62, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("CharacterSelect: Positioned to left - Width: 400px, Height: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(height);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("px");
				}
				logger.LogDebug(val);
			}
			else
			{
				component.sizeDelta = new Vector2(650f, 800f);
				LoadoutPresets.Logger.LogDebug((object)"CharacterSelect: Positioned to left - Width: 400px, Height: 600px (fixed)");
			}
		}
	}
	internal static class Constants
	{
		public static class Scenes
		{
			public const string MAINMENU = "MainMenu";
		}

		public static class ObjectNames
		{
			public const string UI = "UI";
		}

		public static class ButtonNames
		{
			public const string LOADOUTS_BUTTON = "B_LoadoutPresets";

			public const string SETTINGS_BUTTON = "B_Settings";
		}

		public static class ComponentNames
		{
			public const string ICON = "Icon";

			public const string TEXT = "T_Text";

			public const string DISABLED_OVERLAY = "DisabledOverlay";

			public const string CHARACTER_SELECTED_OVERLAY = "CharacterSelectedOverlay";

			public const string RANK_TEXT = "T_Rank";

			public const string STAR = "Star";

			public const string REQUIRES_PURCHASE = "RequiresPurchase (1)";
		}

		public static class UnityComponentTypes
		{
			public const string RECT_TRANSFORM = "RectTransform";

			public const string CANVAS_RENDERER = "CanvasRenderer";

			public const string IMAGE = "Image";

			public const string MASK = "Mask";

			public const string LOCALIZE = "Localize";
		}

		public static class TransformPaths
		{
			public const string TABS = "Tabs";

			public const string MENU = "Menu";

			public const string CREDITS_MENU = "Tabs/W_Credits";

			public const string CHARACTER_SELECT = "Tabs/Character/W_Character";

			public const string HEADER_TITLE = "Header/Header/T_Title";

			public const string HEADER_BACK_BUTTON = "Header/Header/B_Back";

			public const string WINDOW_CONTENT = "WindowLayers/Content";

			public const string CONTENT_SCROLL_RECT = "WindowLayers/Content/ScrollRect";

			public const string CONTENT_ENTRIES = "WindowLayers/Content/ScrollRect/ContentEntries";

			public const string MENU_EXTRA_BUTTONS = "Menu/Content/Main/ExtraButtons";

			public const string TAB_BUTTONS = "TabButtons";
		}

		public static class MenuNames
		{
			public const string LOADOUT_PRESETS = "W_LoadoutPresets";

			public const string LOADOUT_CHARACTER_SELECTOR = "W_LoadoutCharacterSelector";
		}

		public static class UIText
		{
			public const string LOADOUT_MANAGER_TITLE = "Loadout Manager";

			public const string NEW_LOADOUT_PLACEHOLDER = "New loadout name...";

			public const string NAME_REQUIRED = "Name Required";

			public const string TEXT_PROTECTED_SUFFIX = "_Text_Protected";
		}

		public const string MODNAME = "LoadoutPresets";

		public const string AUTHOR = "ZeusesNeckMeat";

		public const string GUID = "ZeusesNeckMeat_LoadoutPresets";

		public const string VERSION = "0.1.3";
	}
	internal static class GameObjectExtensions
	{
		public static T GetOrAddComponent<T>(this GameObject gameObject) where T : Component
		{
			return gameObject.GetComponent<T>() ?? gameObject.AddComponent<T>();
		}
	}
	internal static class CharacterDataExtensions
	{
		public static ECharacter? GetEnumFromDisplayName(this string displayName)
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			if (string.IsNullOrEmpty(displayName))
			{
				return null;
			}
			for (int i = 0; i < DataManager.Instance.unsortedCharacterData.Count; i++)
			{
				CharacterData val = DataManager.Instance.unsortedCharacterData[i];
				if (((UnlockableBase)val).GetName() == displayName)
				{
					return val.eCharacter;
				}
			}
			return null;
		}

		public static string GetDisplayName(this ECharacter? characterEnum)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			if (!characterEnum.HasValue)
			{
				return string.Empty;
			}
			CharacterData characterData = characterEnum.Value.GetCharacterData();
			return ((characterData != null) ? ((UnlockableBase)characterData).GetName() : null) ?? string.Empty;
		}

		public static string GetDisplayName(this ECharacter characterEnum)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			CharacterData characterData = characterEnum.GetCharacterData();
			return ((characterData != null) ? ((UnlockableBase)characterData).GetName() : null) ?? string.Empty;
		}

		public static CharacterData GetCharacterData(this ECharacter? characterEnum)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			if (!characterEnum.HasValue)
			{
				return null;
			}
			return characterEnum.Value.GetCharacterData();
		}

		public static CharacterData GetCharacterData(this ECharacter characterEnum)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			CharacterData result = default(CharacterData);
			if (DataManager.Instance.characterData.TryGetValue(characterEnum, ref result))
			{
				return result;
			}
			return null;
		}
	}
	internal static class LoadoutListFactory
	{
		private static GameObject _buttonTemplate;

		private static readonly Dictionary<string, GameObject> _cachedLoadoutItems = new Dictionary<string, GameObject>();

		public static void SetButtonTemplate(GameObject template)
		{
			_buttonTemplate = template;
		}

		public static bool TryUpdateLoadoutListItemCharacter(string loadoutName, ECharacter? linkedCharacter)
		{
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Expected O, but got Unknown
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Expected O, but got Unknown
			bool flag = default(bool);
			if (_cachedLoadoutItems.TryGetValue(loadoutName, out var value) && (Object)(object)value != (Object)null)
			{
				ManualLogSource logger = LoadoutPresets.Logger;
				BepInExDebugLogInterpolatedStringHandler val = new BepInExDebugLogInterpolatedStringHandler(58, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("LoadoutListFactory: Updating character for cached item '");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(loadoutName);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("'.");
				}
				logger.LogDebug(val);
				UpdateLoadoutItem(value, loadoutName, linkedCharacter);
				return true;
			}
			ManualLogSource logger2 = LoadoutPresets.Logger;
			BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(77, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("LoadoutListFactory: Cannot update character for '");
				((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(loadoutName);
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("' - item not found in cache.");
			}
			logger2.LogWarning(val2);
			return false;
		}

		public static bool TryRemoveLoadoutListItem(string loadoutName)
		{
			//IL_01df: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e6: Expected O, but got Unknown
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Expected O, but got Unknown
			//IL_018e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: Expected O, but got Unknown
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Expected O, but got Unknown
			bool flag = default(bool);
			if (_cachedLoadoutItems.TryGetValue(loadoutName, out var value) && (Object)(object)value != (Object)null)
			{
				Il2CppArrayBase<MyButton> componentsInChildren = value.GetComponentsInChildren<MyButton>(true);
				ManualLogSource logger = LoadoutPresets.Logger;
				BepInExDebugLogInterpolatedStringHandler val = new BepInExDebugLogInterpolatedStringHandler(69, 3, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("LoadoutListFactory: Removing cached item '");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(loadoutName);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("' with ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(componentsInChildren.Length);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" buttons. | Names - ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(string.Join(", ", ((IEnumerable<MyButton>)componentsInChildren)?.Select((MyButton x) => ((Object)x).name) ?? Array.Empty<string>()));
				}
				logger.LogDebug(val);
				foreach (MyButton item in componentsInChildren)
				{
					ManualLogSource logger2 = LoadoutPresets.Logger;
					val = new BepInExDebugLogInterpolatedStringHandler(66, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Attempting to remove button '");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(((Object)item).name);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("' from active window's button list...");
					}
					logger2.LogDebug(val);
					if (WindowManager.activeWindow.allButtons.Contains(item))
					{
						ManualLogSource logger3 = LoadoutPresets.Logger;
						val = new BepInExDebugLogInterpolatedStringHandler(52, 1, ref flag);
						if (flag)
						{
							((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Removing button '");
							((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(((Object)item).name);
							((BepInExLogInterpolatedStringHandler)val).AppendLiteral("' from active window's button list.");
						}
						logger3.LogDebug(val);
						WindowManager.activeWindow.allButtons.Remove(item);
					}
				}
				ManualLogSource logger4 = LoadoutPresets.Logger;
				val = new BepInExDebugLogInterpolatedStringHandler(44, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("LoadoutListFactory: Removing cached item '");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(loadoutName);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("'.");
				}
				logger4.LogDebug(val);
				value.SetActive(false);
				Object.Destroy((Object)(object)value);
				_cachedLoadoutItems.Remove(loadoutName);
				return true;
			}
			ManualLogSource logger5 = LoadoutPresets.Logger;
			BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(63, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("LoadoutListFactory: Cannot remove '");
				((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(loadoutName);
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("' - item not found in cache.");
			}
			logger5.LogWarning(val2);
			return false;
		}

		public static GameObject CreateLoadoutListItem(string loadoutName, ECharacter? linkedCharacter, Transform container, TextMeshProUGUI titleTextReference)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Expected O, but got Unknown
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: 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 logger = LoadoutPresets.Logger;
			bool flag = default(bool);
			BepInExDebugLogInterpolatedStringHandler val = new BepInExDebugLogInterpolatedStringHandler(82, 2, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("LoadoutListFactory: Request to create/update item for '");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(loadoutName);
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("' with linked character '");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<ECharacter?>(linkedCharacter);
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("'.");
			}
			logger.LogDebug(val);
			if (!Object.op_Implicit((Object)(object)_buttonTemplate))
			{
				LoadoutPresets.Logger.LogWarning((object)"LoadoutListFactory: No button template available.");
				return null;
			}
			ManualLogSource logger2 = LoadoutPresets.Logger;
			val = new BepInExDebugLogInterpolatedStringHandler(44, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("LoadoutListFactory: Checking cache for '");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(loadoutName);
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("'...");
			}
			logger2.LogDebug(val);
			if (_cachedLoadoutItems.TryGetValue(loadoutName, out var value) && (Object)(object)value != (Object)null)
			{
				ManualLogSource logger3 = LoadoutPresets.Logger;
				val = new BepInExDebugLogInterpolatedStringHandler(45, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("LoadoutListFactory: Using cached item for '");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(loadoutName);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("'.");
				}
				logger3.LogDebug(val);
				value.transform.SetParent(container, false);
				value.SetActive(true);
				UpdateLoadoutItem(value, loadoutName, linkedCharacter);
				return value;
			}
			ManualLogSource logger4 = LoadoutPresets.Logger;
			val = new BepInExDebugLogInterpolatedStringHandler(45, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("LoadoutListFactory: Creating new item for '");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(loadoutName);
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("'.");
			}
			logger4.LogDebug(val);
			GameObject val2 = CreateNewLoadoutItem(loadoutName, linkedCharacter, container, titleTextReference);
			_cachedLoadoutItems[loadoutName] = val2;
			return val2;
		}

		private static GameObject CreateNewLoadoutItem(string loadoutName, ECharacter? linkedCharacter, Transform container, TextMeshProUGUI titleTextReference)
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Expected O, but got Unknown
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: 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_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dd: Invalid comparison between Unknown and I4
			//IL_023a: 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_025a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0264: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02da: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03df: Unknown result type (might be due to invalid IL or missing references)
			//IL_0334: Unknown result type (might be due to invalid IL or missing references)
			//IL_0354: Unknown result type (might be due to invalid IL or missing references)
			//IL_0424: Unknown result type (might be due to invalid IL or missing references)
			//IL_0444: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("LoadoutItem_" + loadoutName);
			val.transform.SetParent(container, false);
			val.AddComponent<RectTransform>();
			LayoutElement obj = val.AddComponent<LayoutElement>();
			obj.minHeight = 70f;
			obj.preferredHeight = 70f;
			obj.flexibleHeight = 0f;
			obj.minWidth = -1f;
			obj.preferredWidth = -1f;
			obj.flexibleWidth = 1f;
			((Graphic)val.AddComponent<Image>()).color = new Color(0.12f, 0.12f, 0.12f, 0.9f);
			GameObject val2 = new GameObject("LoadoutName");
			val2.transform.SetParent(val.transform, false);
			RectTransform obj2 = val2.AddComponent<RectTransform>();
			obj2.anchorMin = new Vector2(0.02f, 0f);
			obj2.anchorMax = new Vector2(0.3f, 1f);
			obj2.anchoredPosition = Vector2.zero;
			obj2.sizeDelta = Vector2.zero;
			TextMeshProUGUI val3 = val2.AddComponent<TextMeshProUGUI>();
			((TMP_Text)val3).text = loadoutName;
			((TMP_Text)val3).fontSize = 20f;
			((TMP_Text)val3).alignment = (TextAlignmentOptions)4097;
			((Graphic)val3).color = Color.white;
			((TMP_Text)val3).margin = new Vector4(10f, 0f, 5f, 0f);
			if (Object.op_Implicit((Object)(object)titleTextReference))
			{
				((TMP_Text)val3).font = ((TMP_Text)titleTextReference).font;
			}
			CharacterData characterData = linkedCharacter.GetCharacterData();
			string buttonText = linkedCharacter.GetDisplayName() ?? "None";
			object obj3;
			if (characterData == null)
			{
				obj3 = null;
			}
			else
			{
				Texture icon = characterData.icon;
				obj3 = ((icon != null) ? ((Object)icon).name : null);
			}
			string iconName = (string)obj3;
			Button val4 = ButtonFactory.CreateNativeButton(_buttonTemplate, "B_CharacterSelector", buttonText, iconName, val.transform);
			EventTrigger component = ((Component)val4).gameObject.GetComponent<EventTrigger>();
			Entry val5 = null;
			for (int i = 0; i < component.triggers.Count; i++)
			{
				if ((int)component.triggers[i].eventID == 4)
				{
					val5 = component.triggers[i];
					break;
				}
			}
			if (val5 != null)
			{
				((UnityEvent<BaseEventData>)(object)val5.callback).AddListener(UnityAction<BaseEventData>.op_Implicit((Action<BaseEventData>)delegate(BaseEventData eventData)
				{
					//IL_000c: Unknown result type (might be due to invalid IL or missing references)
					//IL_005b: Unknown result type (might be due to invalid IL or missing references)
					//IL_0061: Invalid comparison between Unknown and I4
					//IL_001d: Unknown result type (might be due to invalid IL or missing references)
					//IL_0023: Expected O, but got Unknown
					//IL_006d: Unknown result type (might be due to invalid IL or missing references)
					//IL_0073: Expected O, but got Unknown
					PointerEventData val10 = ((Il2CppObjectBase)eventData).TryCast<PointerEventData>();
					if (val10 != null)
					{
						bool flag = default(bool);
						if ((int)val10.button == 0)
						{
							ManualLogSource logger = LoadoutPresets.Logger;
							BepInExDebugLogInterpolatedStringHandler val11 = new BepInExDebugLogInterpolatedStringHandler(59, 1, ref flag);
							if (flag)
							{
								((BepInExLogInterpolatedStringHandler)val11).AppendLiteral("LoadoutListFactory: Character selector left-clicked for '");
								((BepInExLogInterpolatedStringHandler)val11).AppendFormatted<string>(loadoutName);
								((BepInExLogInterpolatedStringHandler)val11).AppendLiteral("'.");
							}
							logger.LogDebug(val11);
							OnCharacterSelectorClicked(loadoutName);
						}
						else if ((int)val10.button == 1)
						{
							ManualLogSource logger2 = LoadoutPresets.Logger;
							BepInExDebugLogInterpolatedStringHandler val11 = new BepInExDebugLogInterpolatedStringHandler(60, 1, ref flag);
							if (flag)
							{
								((BepInExLogInterpolatedStringHandler)val11).AppendLiteral("LoadoutListFactory: Character selector right-clicked for '");
								((BepInExLogInterpolatedStringHandler)val11).AppendFormatted<string>(loadoutName);
								((BepInExLogInterpolatedStringHandler)val11).AppendLiteral("'.");
							}
							logger2.LogDebug(val11);
							OnCharacterSelectorRightClicked(loadoutName);
						}
					}
				}));
			}
			RectTransform component2 = ((Component)val4).GetComponent<RectTransform>();
			component2.anchorMin = new Vector2(0.32f, 0.1f);
			component2.anchorMax = new Vector2(0.63f, 0.9f);
			component2.anchoredPosition = Vector2.zero;
			component2.sizeDelta = Vector2.zero;
			Button obj4 = ButtonFactory.CreateNativeButton(_buttonTemplate, "B_Load", "LOAD", "psd_checkmark", val.transform);
			((UnityEventBase)obj4.onClick).RemoveAllListeners();
			((UnityEvent)obj4.onClick).AddListener(UnityAction.op_Implicit((Action)delegate
			{
				OnLoadClicked(loadoutName);
			}));
			RectTransform component3 = ((Component)obj4).GetComponent<RectTransform>();
			component3.anchorMin = new Vector2(0.63f, 0.1f);
			component3.anchorMax = new Vector2(0.79f, 0.9f);
			component3.anchoredPosition = Vector2.zero;
			component3.sizeDelta = Vector2.zero;
			Transform val6 = ((Component)obj4).transform.Find("Icon");
			RawImage val7 = ((val6 != null) ? ((Component)val6).GetComponent<RawImage>() : null);
			if (Object.op_Implicit((Object)(object)val7))
			{
				((Graphic)val7).color = new Color(0.3f, 0.8f, 0.3f);
				((Component)val6).gameObject.GetOrAddComponent<RectTransform>().sizeDelta = new Vector2(30f, 30f);
			}
			Button obj5 = ButtonFactory.CreateNativeButton(_buttonTemplate, "B_Delete", "DELETE", "Prototype_symbol_cross_32x32px", val.transform);
			((UnityEventBase)obj5.onClick).RemoveAllListeners();
			((UnityEvent)obj5.onClick).AddListener(UnityAction.op_Implicit((Action)delegate
			{
				OnDeleteClicked(loadoutName);
			}));
			RectTransform component4 = ((Component)obj5).GetComponent<RectTransform>();
			component4.anchorMin = new Vector2(0.79f, 0.1f);
			component4.anchorMax = new Vector2(0.98f, 0.9f);
			component4.anchoredPosition = Vector2.zero;
			component4.sizeDelta = Vector2.zero;
			Transform val8 = ((Component)obj5).transform.Find("Icon");
			RawImage val9 = ((val8 != null) ? ((Component)val8).GetComponent<RawImage>() : null);
			if (Object.op_Implicit((Object)(object)val9))
			{
				((Graphic)val9).color = new Color(0.9f, 0.3f, 0.3f);
				((Component)val8).gameObject.GetOrAddComponent<RectTransform>().sizeDelta = new Vector2(30f, 30f);
			}
			val.SetActive(true);
			return val;
		}

		private static void OnCharacterSelectorClicked(string loadoutName)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			ManualLogSource logger = LoadoutPresets.Logger;
			bool flag = default(bool);
			BepInExDebugLogInterpolatedStringHandler val = new BepInExDebugLogInterpolatedStringHandler(54, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("LoadoutListFactory: Character selector clicked for '");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(loadoutName);
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("'.");
			}
			logger.LogDebug(val);
			LoadoutsMenu.OpenCharacterSelect(loadoutName);
		}

		private static void OnCharacterSelectorRightClicked(string loadoutName)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			ManualLogSource logger = LoadoutPresets.Logger;
			bool flag = default(bool);
			BepInExDebugLogInterpolatedStringHandler val = new BepInExDebugLogInterpolatedStringHandler(88, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("LoadoutListFactory: Character selector right-clicked for '");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(loadoutName);
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("' - removing linked character.");
			}
			logger.LogDebug(val);
			LoadoutPresets.RemoveLoadoutCharacter(loadoutName);
		}

		private static void OnLoadClicked(string loadoutName)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			ManualLogSource logger = LoadoutPresets.Logger;
			bool flag = default(bool);
			BepInExDebugLogInterpolatedStringHandler val = new BepInExDebugLogInterpolatedStringHandler(41, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("LoadoutListFactory: Loading loadout '");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(loadoutName);
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("'...");
			}
			logger.LogDebug(val);
			LoadoutPresets.ActivateLoadout(loadoutName);
			LoadoutsMenu.CloseMenu();
		}

		private static void OnDeleteClicked(string loadoutName)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			ManualLogSource logger = LoadoutPresets.Logger;
			bool flag = default(bool);
			BepInExDebugLogInterpolatedStringHandler val = new BepInExDebugLogInterpolatedStringHandler(42, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("LoadoutListFactory: Deleting loadout '");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(loadoutName);
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("'...");
			}
			logger.LogDebug(val);
			LoadoutPresets.DeleteLoadout(loadoutName);
			TryRemoveLoadoutListItem(loadoutName);
		}

		private static void UpdateLoadoutItem(GameObject itemObj, string loadoutName, ECharacter? linkedCharacter)
		{
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Expected O, but got Unknown
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Expected O, but got Unknown
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ba: Expected O, but got Unknown
			//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e8: Expected O, but got Unknown
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0193: Expected O, but got Unknown
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Expected O, but got Unknown
			Transform val = itemObj.transform.Find("B_CharacterSelector");
			bool flag = default(bool);
			if (!Object.op_Implicit((Object)(object)val))
			{
				ManualLogSource logger = LoadoutPresets.Logger;
				BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(60, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("UpdateLoadoutItem: Could not find B_CharacterSelector for '");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(loadoutName);
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("'");
				}
				logger.LogError(val2);
				return;
			}
			ManualLogSource logger2 = LoadoutPresets.Logger;
			BepInExDebugLogInterpolatedStringHandler val3 = new BepInExDebugLogInterpolatedStringHandler(48, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("UpdateLoadoutItem: Found character button for '");
				((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(loadoutName);
				((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("'");
			}
			logger2.LogDebug(val3);
			CharacterData val4 = null;
			if (linkedCharacter.HasValue)
			{
				DataManager.Instance.characterData.TryGetValue(linkedCharacter.Value, ref val4);
			}
			Transform val5 = val.Find("B_CharacterSelector_Text_Protected");
			if (Object.op_Implicit((Object)(object)val5))
			{
				TextMeshProUGUI component = ((Component)val5).GetComponent<TextMeshProUGUI>();
				string text = ((val4 != null) ? ((UnlockableBase)val4).GetName() : null) ?? "None";
				if (Object.op_Implicit((Object)(object)component) && !string.Equals(((TMP_Text)component).text, text, StringComparison.OrdinalIgnoreCase))
				{
					ManualLogSource logger3 = LoadoutPresets.Logger;
					val3 = new BepInExDebugLogInterpolatedStringHandler(53, 3, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("UpdateLoadoutItem: Updating text from '");
						((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(((TMP_Text)component).text);
						((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("' to '");
						((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(text);
						((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("' for '");
						((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(loadoutName);
						((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("'");
					}
					logger3.LogDebug(val3);
					((TMP_Text)component).text = text;
				}
				else if (!Object.op_Implicit((Object)(object)component))
				{
					ManualLogSource logger4 = LoadoutPresets.Logger;
					BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(75, 0, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("UpdateLoadoutItem: No TextMeshProUGUI on B_CharacterSelector_Text_Protected");
					}
					logger4.LogError(val2);
				}
			}
			else
			{
				ManualLogSource logger5 = LoadoutPresets.Logger;
				BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(68, 0, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("UpdateLoadoutItem: Could not find B_CharacterSelector_Text_Protected");
				}
				logger5.LogError(val2);
			}
			TrySetIcon(val, val4, loadoutName);
			ManualLogSource logger6 = LoadoutPresets.Logger;
			BepInExInfoLogInterpolatedStringHandler val6 = new BepInExInfoLogInterpolatedStringHandler(35, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val6).AppendLiteral("UpdateLoadoutItem: Completed for '");
				((BepInExLogInterpolatedStringHandler)val6).AppendFormatted<string>(loadoutName);
				((BepInExLogInterpolatedStringHandler)val6).AppendLiteral("'");
			}
			logger6.LogInfo(val6);
		}

		private static void TrySetIcon(Transform transform, CharacterData characterData, string loadoutName)
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Expected O, but got Unknown
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Expected O, but got Unknown
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Expected O, but got Unknown
			//IL_0172: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: Expected O, but got Unknown
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Expected O, but got Unknown
			Transform val = transform.Find("Icon");
			bool flag = default(bool);
			if (!Object.op_Implicit((Object)(object)val))
			{
				ManualLogSource logger = LoadoutPresets.Logger;
				BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(48, 0, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("UpdateLoadoutItem: Could not find Icon transform");
				}
				logger.LogError(val2);
				return;
			}
			RawImage component = ((Component)val).GetComponent<RawImage>();
			if (!Object.op_Implicit((Object)(object)component))
			{
				ManualLogSource logger2 = LoadoutPresets.Logger;
				BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(38, 0, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("UpdateLoadoutItem: No RawImage on Icon");
				}
				logger2.LogError(val2);
				return;
			}
			if ((Object)(object)characterData == (Object)null)
			{
				((Component)val).gameObject.SetActive(false);
				ManualLogSource logger3 = LoadoutPresets.Logger;
				BepInExDebugLogInterpolatedStringHandler val3 = new BepInExDebugLogInterpolatedStringHandler(55, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("UpdateLoadoutItem: No icon for '");
					((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(loadoutName);
					((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("' (no character linked)");
				}
				logger3.LogDebug(val3);
				return;
			}
			Texture icon = characterData.icon;
			string text = ((icon != null) ? ((Object)icon).name : null) ?? "NULL";
			if ((Object)(object)icon != (Object)null)
			{
				component.texture = icon;
				((Graphic)component).color = Color.white;
				((Component)val).gameObject.SetActive(true);
				ManualLogSource logger4 = LoadoutPresets.Logger;
				BepInExDebugLogInterpolatedStringHandler val3 = new BepInExDebugLogInterpolatedStringHandler(44, 2, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("UpdateLoadoutItem: Updated icon to '");
					((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(text);
					((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("' for '");
					((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(loadoutName);
					((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("'");
				}
				logger4.LogDebug(val3);
			}
			else
			{
				((Component)val).gameObject.SetActive(false);
				ManualLogSource logger5 = LoadoutPresets.Logger;
				BepInExWarningLogInterpolatedStringHandler val4 = new BepInExWarningLogInterpolatedStringHandler(46, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("UpdateLoadoutItem: Icon texture is null for '");
					((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<string>(loadoutName);
					((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("'");
				}
				logger5.LogWarning(val4);
			}
		}
	}
	[BepInPlugin("ZeusesNeckMeat_LoadoutPresets", "LoadoutPresets", "0.1.3")]
	public class LoadoutPresets : BasePlugin
	{
		private static string _loadoutPresetsFolder;

		private static ManualLogSource _logger;

		private static readonly Dictionary<string, LoadoutData> _loadoutCacheByLoadoutName = new Dictionary<string, LoadoutData>();

		public static ManualLogSource Logger => _logger;

		public LoadoutPresets()
		{
			_logger = ((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_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Expected O, but got Unknown
			ManualLogSource logger = _logger;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(14, 3, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Loading ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("LoadoutPresets");
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" v");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("0.1.3");
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" by ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("ZeusesNeckMeat");
			}
			logger.LogInfo(val);
			_loadoutPresetsFolder = Path.Combine(Paths.ConfigPath, "LoadoutPresets");
			if (!Directory.Exists(_loadoutPresetsFolder))
			{
				Directory.CreateDirectory(_loadoutPresetsFolder);
				ManualLogSource logger2 = _logger;
				val = new BepInExInfoLogInterpolatedStringHandler(34, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Created LoadoutPresets folder at: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(_loadoutPresetsFolder);
				}
				logger2.LogInfo(val);
			}
			new Harmony("ZeusesNeckMeat_LoadoutPresets").PatchAll();
			SceneManager.sceneLoaded += UnityAction<Scene, LoadSceneMode>.op_Implicit((Action<Scene, LoadSceneMode>)SceneManager_sceneLoaded);
		}

		public static string GetLoadoutPresetsFolder()
		{
			return _loadoutPresetsFolder;
		}

		private void SceneManager_sceneLoaded(Scene scene, LoadSceneMode mode)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			ManualLogSource logger = _logger;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(14, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Scene loaded: ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(((Scene)(ref scene)).name);
			}
			logger.LogInfo(val);
			if (((Scene)(ref scene)).name == "MainMenu")
			{
				Il2CppReferenceArray<GameObject> rootGameObjects = ((Scene)(ref scene)).GetRootGameObjects();
				LoadoutsButton.CreateLoadoutsButton(rootGameObjects);
				LoadoutsMenu.CreateLoadoutsMenu(rootGameObjects);
			}
		}

		public static void SaveLoadoutFromInput(TMP_InputField inputField)
		{
			//IL_0039: 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_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Expected O, but got Unknown
			string text = inputField.text.Trim();
			if (string.IsNullOrEmpty(text))
			{
				_logger.LogWarning((object)"Cannot save loadout: No name provided.");
				TextMeshProUGUI component = ((Component)inputField.placeholder).GetComponent<TextMeshProUGUI>();
				((TMP_Text)component).text = "Name Required";
				((Graphic)component).color = Color.red;
				return;
			}
			TextMeshProUGUI component2 = ((Component)inputField.placeholder).GetComponent<TextMeshProUGUI>();
			if ((Object)(object)component2 != (Object)null)
			{
				((TMP_Text)component2).text = "New loadout name...";
				((Graphic)component2).color = new Color(0.5f, 0.5f, 0.5f, 0.5f);
			}
			text = Path.GetInvalidFileNameChars().Aggregate(text, (string current, char c) => current.Replace(c, '_'));
			SaveCurrentLoadout(text);
			inputField.text = "";
			ManualLogSource logger = _logger;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(30, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Loadout '");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(text);
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("' saved successfully.");
			}
			logger.LogInfo(val);
		}

		public static void OpenLoadoutPresetsFolder()
		{
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Expected O, but got Unknown
			try
			{
				if (!Directory.Exists(_loadoutPresetsFolder))
				{
					Directory.CreateDirectory(_loadoutPresetsFolder);
				}
				Application.OpenURL(_loadoutPresetsFolder);
				_logger.LogInfo((object)"Opened LoadoutPresets folder");
			}
			catch (Exception ex)
			{
				ManualLogSource logger = _logger;
				bool flag = default(bool);
				BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(38, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Failed to open LoadoutPresets folder: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
				}
				logger.LogError(val);
			}
		}

		private static void SaveCurrentLoadout(string loadoutName)
		{
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Expected O, but got Unknown
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Expected O, but got Unknown
			if (!Object.op_Implicit((Object)(object)SaveManager.Instance))
			{
				_logger.LogError((object)"SaveManager is null, cannot save loadout");
				return;
			}
			LoadoutData loadoutData = new LoadoutData();
			loadoutData.Name = loadoutName;
			loadoutData.SavedAt = DateTime.Now;
			LoadoutData loadoutData2 = loadoutData;
			HashSet<string> inactivated = SaveManager.Instance.progression.inactivated;
			List<string> list = new List<string>(inactivated.Count);
			Enumerator<string> enumerator = inactivated.GetEnumerator();
			while (enumerator.MoveNext())
			{
				string current = enumerator.Current;
				list.Add(current);
			}
			loadoutData2.InactivatedUnlockables = list;
			LoadoutData value = loadoutData;
			string path = Path.Combine(_loadoutPresetsFolder, loadoutName + ".json");
			string contents = JsonSerializer.Serialize(value, new JsonSerializerOptions
			{
				WriteIndented = true
			});
			File.WriteAllText(path, contents);
			ManualLogSource logger = _logger;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(15, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Loadout saved: ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(loadoutName);
			}
			logger.LogInfo(val);
			_loadoutCacheByLoadoutName[loadoutName] = value;
			ManualLogSource logger2 = _logger;
			BepInExDebugLogInterpolatedStringHandler val2 = new BepInExDebugLogInterpolatedStringHandler(26, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Added loadout '");
				((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(loadoutName);
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("' in cache.");
			}
			logger2.LogDebug(val2);
			LoadoutsMenu.AddLoadoutListItem(loadoutName);
		}

		public static void UpdateLoadoutCharacter(string loadoutName, ECharacter character)
		{
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Expected O, but got Unknown
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Expected O, but got Unknown
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: Expected O, but got Unknown
			LoadoutData loadoutData = LoadLoadoutData(loadoutName);
			bool flag = default(bool);
			if (loadoutData == null)
			{
				ManualLogSource logger = _logger;
				BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(47, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Cannot update character - loadout '");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(loadoutName);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("' not found.");
				}
				logger.LogError(val);
				return;
			}
			string characterDisplayName = character.GetDisplayName();
			loadoutData.LinkedCharacter = characterDisplayName;
			string path = Path.Combine(_loadoutPresetsFolder, loadoutName + ".json");
			string contents = JsonSerializer.Serialize(loadoutData, new JsonSerializerOptions
			{
				WriteIndented = true
			});
			File.WriteAllText(path, contents);
			ManualLogSource logger2 = _logger;
			BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(39, 2, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Updated loadout '");
				((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(loadoutName);
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("' - linked character: ");
				((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(characterDisplayName ?? "None");
			}
			logger2.LogInfo(val2);
			LoadoutsMenu.UpdateLoadoutListItemCharacter(loadoutName, character);
			if (_loadoutCacheByLoadoutName.ContainsKey(loadoutName))
			{
				_loadoutCacheByLoadoutName[loadoutName].LinkedCharacter = characterDisplayName;
				ManualLogSource logger3 = _logger;
				BepInExDebugLogInterpolatedStringHandler val3 = new BepInExDebugLogInterpolatedStringHandler(48, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("Updated linked character in cache for loadout '");
					((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(loadoutName);
					((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("'");
				}
				logger3.LogDebug(val3);
			}
			IEnumerable<KeyValuePair<string, LoadoutData>> enumerable = from x in _loadoutCacheByLoadoutName
				where x.Value.LinkedCharacter == characterDisplayName
				where x.Key != loadoutName
				select x;
			if (!enumerable.Any())
			{
				return;
			}
			foreach (KeyValuePair<string, LoadoutData> item in enumerable)
			{
				item.Value.LinkedCharacter = null;
				string path2 = Path.Combine(_loadoutPresetsFolder, item.Key + ".json");
				contents = JsonSerializer.Serialize(item.Value, new JsonSerializerOptions
				{
					WriteIndented = true
				});
				File.WriteAllText(path2, contents);
				LoadoutsMenu.UpdateLoadoutListItemCharacter(item.Key, null);
			}
		}

		public static void RemoveLoadoutCharacter(string loadoutName)
		{
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Expected O, but got Unknown
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Expected O, but got Unknown
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Expected O, but got Unknown
			LoadoutData loadoutData = LoadLoadoutData(loadoutName);
			bool flag = default(bool);
			if (loadoutData == null)
			{
				ManualLogSource logger = _logger;
				BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(47, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Cannot remove character - loadout '");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(loadoutName);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("' not found.");
				}
				logger.LogError(val);
				return;
			}
			loadoutData.LinkedCharacter = null;
			string path = Path.Combine(_loadoutPresetsFolder, loadoutName + ".json");
			string contents = JsonSerializer.Serialize(loadoutData, new JsonSerializerOptions
			{
				WriteIndented = true
			});
			File.WriteAllText(path, contents);
			ManualLogSource logger2 = _logger;
			BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(40, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Removed linked character from loadout '");
				((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(loadoutName);
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("'");
			}
			logger2.LogInfo(val2);
			LoadoutsMenu.UpdateLoadoutListItemCharacter(loadoutName, null);
			if (_loadoutCacheByLoadoutName.ContainsKey(loadoutName))
			{
				_loadoutCacheByLoadoutName[loadoutName].LinkedCharacter = null;
				ManualLogSource logger3 = _logger;
				BepInExDebugLogInterpolatedStringHandler val3 = new BepInExDebugLogInterpolatedStringHandler(55, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("Updated cache for loadout '");
					((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(loadoutName);
					((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("' - removed linked character");
				}
				logger3.LogDebug(val3);
			}
		}

		public static LoadoutData LoadLoadoutData(string loadoutName)
		{
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Expected O, but got Unknown
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Expected O, but got Unknown
			bool flag = default(bool);
			if (_loadoutCacheByLoadoutName.TryGetValue(loadoutName, out var value))
			{
				ManualLogSource logger = _logger;
				BepInExDebugLogInterpolatedStringHandler val = new BepInExDebugLogInterpolatedStringHandler(41, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Loadout data for '");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(loadoutName);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("' retrieved from cache.");
				}
				logger.LogDebug(val);
				return value;
			}
			string path = Path.Combine(_loadoutPresetsFolder, loadoutName + ".json");
			if (!File.Exists(path))
			{
				return null;
			}
			try
			{
				return JsonSerializer.Deserialize<LoadoutData>(File.ReadAllText(path));
			}
			catch (Exception ex)
			{
				ManualLogSource logger2 = _logger;
				BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(36, 2, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Failed to load loadout data for '");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(loadoutName);
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("': ");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex.Message);
				}
				logger2.LogError(val2);
				return null;
			}
		}

		public static void ActivateLoadout(string loadoutName)
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Expected O, but got Unknown
			if (!Object.op_Implicit((Object)(object)SaveManager.Instance))
			{
				_logger.LogError((object)"SaveManager is null, cannot load loadout");
				return;
			}
			LoadoutData loadoutData = LoadLoadoutData(loadoutName);
			bool flag = default(bool);
			if (loadoutData == null)
			{
				ManualLogSource logger = _logger;
				BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(34, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Failed to load loadout data for '");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(loadoutName);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("'");
				}
				logger.LogError(val);
				return;
			}
			SaveManager.Instance.progression.inactivated.Clear();
			foreach (string inactivatedUnlockable in loadoutData.InactivatedUnlockables)
			{
				SaveManager.Instance.progression.inactivated.Add(inactivatedUnlockable);
			}
			ManualLogSource logger2 = _logger;
			BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(60, 2, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Loadout '");
				((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(loadoutName);
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("' loaded successfully. Restored ");
				((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(loadoutData.InactivatedUnlockables.Count);
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" inactivated items.");
			}
			logger2.LogInfo(val2);
			SaveManager.Instance.SaveProgression();
		}

		public static void DeleteLoadout(string loadoutName)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Expected O, but got Unknown
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Expected O, but got Unknown
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Expected O, but got Unknown
			bool flag = default(bool);
			if (_loadoutCacheByLoadoutName.ContainsKey(loadoutName))
			{
				_loadoutCacheByLoadoutName.Remove(loadoutName);
				ManualLogSource logger = _logger;
				BepInExDebugLogInterpolatedStringHandler val = new BepInExDebugLogInterpolatedStringHandler(22, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Removed '");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(loadoutName);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("' from cache.");
				}
				logger.LogDebug(val);
			}
			string text = Path.Combine(_loadoutPresetsFolder, loadoutName + ".json");
			if (!File.Exists(text))
			{
				ManualLogSource logger2 = _logger;
				BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(40, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Cannot delete - loadout file not found: ");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(text);
				}
				logger2.LogWarning(val2);
				return;
			}
			File.Delete(text);
			ManualLogSource logger3 = _logger;
			BepInExInfoLogInterpolatedStringHandler val3 = new BepInExInfoLogInterpolatedStringHandler(17, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("Deleted loadout: ");
				((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(loadoutName);
			}
			logger3.LogInfo(val3);
		}

		public static IEnumerable<LoadoutData> LoadoutDatasCache()
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Expected O, but got Unknown
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Expected O, but got Unknown
			bool flag = default(bool);
			if (_loadoutCacheByLoadoutName.Count > 0)
			{
				ManualLogSource logger = _logger;
				BepInExDebugLogInterpolatedStringHandler val = new BepInExDebugLogInterpolatedStringHandler(46, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Returning all loadouts from cache (");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(_loadoutCacheByLoadoutName.Count);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" loadouts).");
				}
				logger.LogDebug(val);
				return _loadoutCacheByLoadoutName.Values;
			}
			if (!Directory.Exists(_loadoutPresetsFolder))
			{
				return Array.Empty<LoadoutData>();
			}
			string[] files = Directory.GetFiles(_loadoutPresetsFolder, "*.json");
			for (int i = 0; i < files.Length; i++)
			{
				string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(files[i]);
				LoadoutData loadoutData = LoadLoadoutData(fileNameWithoutExtension);
				if (loadoutData != null)
				{
					_loadoutCacheByLoadoutName[fileNameWithoutExtension] = loadoutData;
					ManualLogSource logger2 = _logger;
					BepInExDebugLogInterpolatedStringHandler val = new BepInExDebugLogInterpolatedStringHandler(34, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Loaded loadout '");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(fileNameWithoutExtension);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("' into collection.");
					}
					logger2.LogDebug(val);
				}
			}
			return _loadoutCacheByLoadoutName.Values;
		}

		public static void ActivateLoadoutFromCharacter(ECharacter? eCharacter)
		{
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Expected O, but got Unknown
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Expected O, but got Unknown
			if (!eCharacter.HasValue)
			{
				Logger.LogWarning((object)"ActivateLoadoutFromCharacter called with null character.");
				return;
			}
			string characterName = eCharacter.GetDisplayName();
			LoadoutData loadoutData = LoadoutDatasCache().FirstOrDefault((LoadoutData ld) => string.Equals(ld.LinkedCharacter, characterName, StringComparison.OrdinalIgnoreCase));
			bool flag = default(bool);
			if (loadoutData == null)
			{
				ManualLogSource logger = Logger;
				BepInExDebugLogInterpolatedStringHandler val = new BepInExDebugLogInterpolatedStringHandler(61, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("No loadout linked to character ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(characterName);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", skipping loadout activation.");
				}
				logger.LogDebug(val);
				return;
			}
			ManualLogSource logger2 = Logger;
			BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(45, 2, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Activating loadout '");
				((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(loadoutData.Name);
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("' linked to character '");
				((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(characterName);
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("'.");
			}
			logger2.LogInfo(val2);
			ActivateLoadout(loadoutData.Name);
		}
	}
	[Serializable]
	public class LoadoutData
	{
		public string Name { get; set; }

		public DateTime SavedAt { get; set; }

		public string LinkedCharacter { get; set; }

		public List<string> InactivatedUnlockables { get; set; }
	}
	internal static class LoadoutsButton
	{
		private static Button _loadoutsButton;

		public static void CreateLoadoutsButton(Il2CppReferenceArray<GameObject> rootGameObjects)
		{
			if (TryGetSettingsButtonToClone(((IEnumerable<GameObject>)rootGameObjects).FirstOrDefault((Func<GameObject, bool>)((GameObject gameObject) => string.Equals(((Object)gameObject).name, "UI", StringComparison.OrdinalIgnoreCase))), out var _, out var settingsButtonComponent))
			{
				_loadoutsButton = ButtonFactory.CreateNativeButton(((Component)settingsButtonComponent).gameObject, "B_LoadoutPresets", "LOADOUTS", "toggler");
				((UnityEvent)_loadoutsButton.onClick).AddListener(UnityAction.op_Implicit((Action)OpenLoadoutPresetsMenu));
			}
		}

		private static bool TryGetSettingsButtonToClone(GameObject uiRootGameObject, out Transform settingsTransform, out Button settingsButtonComponent)
		{
			settingsTransform = null;
			settingsButtonComponent = null;
			if (!Object.op_Implicit((Object)(object)uiRootGameObject))
			{
				return false;
			}
			Transform val = uiRootGameObject.transform.Find("Tabs/Menu/Content/Main/ExtraButtons");
			if (!Object.op_Implicit((Object)(object)val))
			{
				return false;
			}
			if (Object.op_Implicit((Object)(object)val.Find("B_LoadoutPresets")))
			{
				return false;
			}
			settingsTransform = val.Find("B_Settings");
			if (!Object.op_Implicit((Object)(object)settingsTransform))
			{
				return false;
			}
			settingsButtonComponent = ((Component)settingsTransform).GetComponent<Button>();
			return Object.op_Implicit((Object)(object)settingsButtonComponent);
		}

		private static void OpenLoadoutPresetsMenu()
		{
			LoadoutPresets.Logger.LogDebug((object)"Opening Loadout Presets Menu...");
			LoadoutsMenu.OpenMenu();
		}
	}
	internal static class LoadoutsMenu
	{
		private static GameObject _loadoutsMenuPanel;

		private static GameObject _mainMenuPanel;

		private static Transform _loadoutListContainer;

		private static TMP_InputField _loadoutNameInput;

		private static GameObject _characterSelect;

		private static string _loadoutBeingEdited;

		public static void CreateLoadoutsMenu(Il2CppReferenceArray<GameObject> rootGameObjects)
		{
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Expected O, but got Unknown
			GameObject val = ((IEnumerable<GameObject>)rootGameObjects).FirstOrDefault((Func<GameObject, bool>)((GameObject obj) => string.Equals(((Object)obj).name, "UI", StringComparison.OrdinalIgnoreCase)));
			if (!Object.op_Implicit((Object)(object)val))
			{
				LoadoutPresets.Logger.LogError((object)"LoadoutsMenu: Could not find UI root.");
				return;
			}
			Transform val2 = val.transform.Find("Tabs/W_Credits");
			if (!Object.op_Implicit((Object)(object)val2))
			{
				LoadoutPresets.Logger.LogError((object)"LoadoutsMenu: Could not find Credits menu template.");
				return;
			}
			_loadoutsMenuPanel = LoadoutsMenuFactory.CloneCreditsAsLoadoutsMenu(((Component)val2).gameObject, val.transform.Find("Tabs"));
			Transform obj2 = _loadoutsMenuPanel.transform.parent.Find("Menu");
			_mainMenuPanel = ((obj2 != null) ? ((Component)obj2).gameObject : null);
			_loadoutListContainer = _loadoutsMenuPanel.transform.Find("WindowLayers/Content/ScrollRect/ContentEntries");
			if (Object.op_Implicit((Object)(object)_loadoutListContainer))
			{
				ManualLogSource logger = LoadoutPresets.Logger;
				bool flag = default(bool);
				BepInExDebugLogInterpolatedStringHandler val3 = new BepInExDebugLogInterpolatedStringHandler(44, 0, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("LoadoutsMenu: Found ContentEntries container");
				}
				logger.LogDebug(val3);
			}
			else
			{
				LoadoutPresets.Logger.LogWarning((object)"LoadoutsMenu: Could not find container. Using fallback.");
				ScrollRect componentInChildren = _loadoutsMenuPanel.GetComponentInChildren<ScrollRect>();
				if (Object.op_Implicit((Object)(object)componentInChildren) && Object.op_Implicit((Object)(object)componentInChildren.content))
				{
					_loadoutListContainer = (Transform)(object)componentInChildren.content;
					LoadoutPresets.Logger.LogDebug((object)"LoadoutsMenu: Using ScrollRect.content as container.");
				}
			}
			((HorizontalOrVerticalLayoutGroup)((Component)_loadoutListContainer).gameObject.GetOrAddComponent<VerticalLayoutGroup>()).childControlHeight = true;
			_characterSelect = CharacterSelectFactory.CloneCharacterSelect(((Component)val.transform.Find("Tabs/Character/W_Character")).gameObject, _loadoutsMenuPanel.transform);
			LoadoutPresets.Logger.LogDebug((object)"LoadoutsMenu: Menu created successfully.");
		}

		public static void SetLoadoutNameInput(TMP_InputField inputField)
		{
			_loadoutNameInput = inputField;
		}

		public static void OpenMenu()
		{
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)_loadoutsMenuPanel))
			{
				LoadoutPresets.Logger.LogError((object)"LoadoutsMenu: Cannot open menu - panel not initialized.");
				return;
			}
			_characterSelect.SetActive(false);
			Transform obj = _loadoutsMenuPanel.transform.parent.Find("Menu");
			if (obj != null)
			{
				((Component)obj).gameObject.SetActive(false);
			}
			if (Object.op_Implicit((Object)(object)_loadoutNameInput))
			{
				_loadoutNameInput.text = "";
				Graphic placeholder = _loadoutNameInput.placeholder;
				TextMeshProUGUI val = ((placeholder != null) ? ((Component)placeholder).GetComponent<TextMeshProUGUI>() : null);
				if (Object.op_Implicit((Object)(object)val))
				{
					((TMP_Text)val).text = "New loadout name...";
					((Graphic)val).color = new Color(0.5f, 0.5f, 0.5f, 0.5f);
				}
			}
			RefreshLoadoutList();
			if (Object.op_Implicit((Object)(object)_mainMenuPanel))
			{
				_mainMenuPanel.SetActive(false);
			}
			_loadoutsMenuPanel.SetActive(true);
			LoadoutPresets.Logger.LogDebug((object)"LoadoutsMenu: Menu opened successfully.");
		}

		public static void CloseMenu()
		{
			if (Object.op_Implicit((Object)(object)_loadoutsMenuPanel))
			{
				_loadoutsMenuPanel.SetActive(false);
				LoadoutPresets.Logger.LogDebug((object)"LoadoutsMenu: Menu closed.");
			}
			if (Object.op_Implicit((Object)(object)_mainMenuPanel))
			{
				_mainMenuPanel.SetActive(true);
			}
			Transform obj = _loadoutsMenuPanel.transform.parent.Find("Menu");
			if (obj != null)
			{
				((Component)obj).gameObject.SetActive(true);
			}
		}

		public static void OpenCharacterSelect(string loadoutName)
		{
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Expected O, but got Unknown
			if (!Object.op_Implicit((Object)(object)_characterSelect))
			{
				LoadoutPresets.Logger.LogError((object)"LoadoutsMenu: Cannot open character select - not initialized.");
				return;
			}
			_loadoutBeingEdited = loadoutName;
			if (_characterSelect.activeSelf)
			{
				LoadoutPresets.Logger.LogDebug((object)"LoadoutsMenu: Character select already open.");
				return;
			}
			ManualLogSource logger = LoadoutPresets.Logger;
			bool flag = default(bool);
			BepInExDebugLogInterpolatedStringHandler val = new BepInExDebugLogInterpolatedStringHandler(54, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("LoadoutsMenu: Opening character select for loadout '");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(loadoutName);
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("'.");
			}
			logger.LogDebug(val);
			if (!_loadoutsMenuPanel.activeSelf)
			{
				LoadoutPresets.Logger.LogDebug((object)"LoadoutsMenu: Loadouts menu not open. Opening menu first.");
				OpenMenu();
			}
			_characterSelect.SetActive(true);
		}

		public static void OnCharacterSelected(ECharacter selectedCharacter)
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Expected O, but got Unknown
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			if (string.IsNullOrEmpty(_loadoutBeingEdited))
			{
				LoadoutPresets.Logger.LogError((object)"LoadoutsMenu: No loadout is currently being edited.");
				return;
			}
			ManualLogSource logger = LoadoutPresets.Logger;
			bool flag = default(bool);
			BepInExDebugLogInterpolatedStringHandler val = new BepInExDebugLogInterpolatedStringHandler(51, 2, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("LoadoutsMenu: Character '");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<ECharacter>(selectedCharacter);
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("' selected for loadout '");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(_loadoutBeingEdited);
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("'.");
			}
			logger.LogDebug(val);
			LoadoutPresets.UpdateLoadoutCharacter(_loadoutBeingEdited, selectedCharacter);
			CloseCharacterSelect();
			_loadoutBeingEdited = null;
		}

		public static void CloseCharacterSelect()
		{
			if (Object.op_Implicit((Object)(object)_characterSelect) && _characterSelect.activeSelf)
			{
				_characterSelect.SetActive(false);
				LoadoutPresets.Logger.LogDebug((object)"LoadoutsMenu: Character select closed.");
			}
			_loadoutBeingEdited = null;
		}

		public static string GetCurrentEditingLoadout()
		{
			return _loadoutBeingEdited;
		}

		public static void RefreshLoadoutList()
		{
			if (!Object.op_Implicit((Object)(object)_loadoutListContainer))
			{
				LoadoutPresets.Logger.LogWarning((object)"LoadoutsMenu: Cannot refresh - container not found.");
				return;
			}
			Transform obj = _loadoutsMenuPanel.transform.Find("Header/Header/T_Title");
			TextMeshProUGUI titleTextReference = ((obj != null) ? ((Component)obj).GetComponent<TextMeshProUGUI>() : null);
			foreach (LoadoutData item in from x in LoadoutPresets.LoadoutDatasCache()
				orderby x.Name
				select x)
			{
				LoadoutListFactory.CreateLoadoutListItem(linkedCharacter: item.LinkedCharacter.GetEnumFromDisplayName(), loadoutName: item.Name, container: _loadoutListContainer, titleTextReference: titleTextReference);
			}
			LoadoutPresets.Logger.LogDebug((object)"LoadoutsMenu: Loadout list refreshed.");
		}

		public static void AddLoadoutListItem(string loadoutName)
		{
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Expected O, but got Unknown
			Transform loadoutListContainer = _loadoutListContainer;
			Transform obj = _loadoutsMenuPanel.transform.Find("Header/Header/T_Title");
			LoadoutListFactory.CreateLoadoutListItem(loadoutName, null, loadoutListContainer, (obj != null) ? ((Component)obj).GetComponent<TextMeshProUGUI>() : null);
			ManualLogSource logger = LoadoutPresets.Logger;
			bool flag = default(bool);
			BepInExDebugLogInterpolatedStringHandler val = new BepInExDebugLogInterpolatedStringHandler(45, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("LoadoutsMenu: Added loadout list item for '");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(loadoutName);
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("'.");
			}
			logger.LogDebug(val);
		}

		public static void UpdateLoadoutListItemCharacter(string loadoutName, ECharacter? linkedCharacter)
		{
			if (!LoadoutListFactory.TryUpdateLoadoutListItemCharacter(loadoutName, linkedCharacter))
			{
				RefreshLoadoutList();
			}
		}
	}
	internal static class LoadoutsMenuFactory
	{
		private static GameObject _buttonTemplate;

		public static GameObject CloneCreditsAsLoadoutsMenu(GameObject creditsTemplate, Transform newParent)
		{
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			LoadoutPresets.Logger.LogDebug((object)"MenuFactory: Starting Credits → Loadouts menu clone.");
			CacheButtonTemplate(creditsTemplate);
			GameObject obj = Object.Instantiate<GameObject>(creditsTemplate, newParent);
			((Object)obj).name = "W_LoadoutPresets";
			obj.SetActive(false);
			obj.GetComponent<RectTransf