Decompiled source of EasySettings v1.1.3

EasySettings.dll

Decompiled 2 weeks ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Nessie.ATLYSS.EasySettings.Extensions;
using Nessie.ATLYSS.EasySettings.UIElements;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("EasySettings")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.1.3.0")]
[assembly: AssemblyInformationalVersion("1.1.3+a9b24740d8cfb770c731c6ff5a76ba3fb64e0e4f")]
[assembly: AssemblyProduct("Easy Settings API")]
[assembly: AssemblyTitle("EasySettings")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.3.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 Nessie.ATLYSS.EasySettings
{
	public class ComponentReferences : MonoBehaviour
	{
		public List<Component> components = new List<Component>();
	}
	[BepInPlugin("EasySettings", "Easy Settings API", "1.1.3")]
	[BepInProcess("ATLYSS.exe")]
	public class EasySettingsPlugin : BaseUnityPlugin
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static UnityAction <>9__2_0;

			internal void <AddModTabButton>b__2_0()
			{
				SettingsManager._current.Set_SettingMenuSelectionIndex(Settings.ModTabIndex);
			}
		}

		internal static ManualLogSource Logger;

		private void Awake()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Expected O, but got Unknown
			Logger = ((BaseUnityPlugin)this).Logger;
			new Harmony("EasySettings").PatchAll();
			SettingsPatches.OnSettingsMenuInitialized.AddListener((UnityAction)delegate
			{
				AddModTabButton();
				AddModTabBottomSpace();
				Settings.OnInitialized.Invoke();
			});
		}

		private void AddModTabButton()
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Expected O, but got Unknown
			Settings.ModTabIndex = 4;
			AtlyssTabButton atlyssTabButton = Settings.AddTabButton("Mods");
			UnityEvent onClicked = atlyssTabButton.OnClicked;
			object obj = <>c.<>9__2_0;
			if (obj == null)
			{
				UnityAction val = delegate
				{
					SettingsManager._current.Set_SettingMenuSelectionIndex(Settings.ModTabIndex);
				};
				<>c.<>9__2_0 = val;
				obj = (object)val;
			}
			onClicked.AddListener((UnityAction)obj);
			Settings.ModTab.TabButton = atlyssTabButton;
		}

		private void AddModTabBottomSpace()
		{
			Settings.ModTab.BottomSpace = Settings.ModTab.AddSpace();
		}
	}
	public static class SettingsPatches
	{
		[HarmonyPatch(typeof(SettingsManager), "Start")]
		private static class MenuInitialization
		{
			[Serializable]
			[CompilerGenerated]
			private sealed class <>c
			{
				public static readonly <>c <>9 = new <>c();

				public static UnityAction <>9__0_0;

				internal void <InitializeModTab>b__0_0()
				{
					Settings.OnCancelSettings.Invoke();
				}
			}

			[HarmonyPostfix]
			private static void InitializeModTab(SettingsManager __instance)
			{
				//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
				//IL_00bd: Expected O, but got Unknown
				Transform val = Utility.FindTabsContainer(__instance);
				if (!Object.op_Implicit((Object)(object)val))
				{
					EasySettingsPlugin.Logger.LogError((object)"Unable to find settings tabs container GameObject. EasySettings won't be available.");
					return;
				}
				HorizontalLayoutGroup component = ((Component)val).GetComponent<HorizontalLayoutGroup>();
				if (!Object.op_Implicit((Object)(object)component))
				{
					EasySettingsPlugin.Logger.LogError((object)"Settings tabs container GameObject does not have a HorizontalLayoutGroup. EasySettings won't be available.");
					return;
				}
				((HorizontalOrVerticalLayoutGroup)component).spacing = 8f;
				((LayoutGroup)component).padding.right = ((LayoutGroup)component).padding.left;
				((HorizontalOrVerticalLayoutGroup)component).childControlWidth = true;
				Button val2 = Utility.FindCancelButton(__instance);
				if (Object.op_Implicit((Object)(object)val2))
				{
					ButtonClickedEvent onClick = val2.onClick;
					object obj = <>c.<>9__0_0;
					if (obj == null)
					{
						UnityAction val3 = delegate
						{
							Settings.OnCancelSettings.Invoke();
						};
						<>c.<>9__0_0 = val3;
						obj = (object)val3;
					}
					((UnityEvent)onClick).AddListener((UnityAction)obj);
				}
				Button val4 = Utility.FindApplyButton(__instance);
				if (!Object.op_Implicit((Object)(object)val4))
				{
					EasySettingsPlugin.Logger.LogWarning((object)"Unable to find Apply Button. Saving the settings will not be possible during this play session.");
				}
				TemplateManager.Initialize();
				OnSettingsMenuInitialized.Invoke();
			}
		}

		[HarmonyPatch(typeof(SettingsManager), "Close_SettingsMenu")]
		private static class MenuClose
		{
			[HarmonyPostfix]
			private static void CloseSettings()
			{
				Settings.OnCloseSettings.Invoke();
			}
		}

		[HarmonyPatch(typeof(SettingsManager), "Save_SettingsData")]
		private static class SaveSettings
		{
			[HarmonyPostfix]
			private static void ApplySettings()
			{
				Settings.OnApplySettings.Invoke();
			}
		}

		[HarmonyPatch(typeof(SettingsManager), "Set_SettingMenuSelectionIndex")]
		private static class MenuSelection
		{
			[HarmonyPostfix]
			private static void ApplySelection(SettingsManager __instance)
			{
				//IL_0020: Unknown result type (might be due to invalid IL or missing references)
				//IL_002a: Invalid comparison between Unknown and I4
				//IL_0050: Unknown result type (might be due to invalid IL or missing references)
				if (Object.op_Implicit((Object)(object)ModTab.Element))
				{
					ModTab.Element.isEnabled = (int)__instance._currentSettingsMenuSelection == Settings.ModTabIndex;
				}
				if (Object.op_Implicit((Object)(object)ModTab.Content))
				{
					ModTab.Content.anchoredPosition = Vector2.zero;
				}
			}
		}

		[HarmonyPatch(typeof(SettingsManager), "Handle_InputParameters")]
		private static class ListenForKeyChanges
		{
			[HarmonyPrefix]
			private static void RecordKeys(SettingsManager __instance, out string[] __state)
			{
				if (!__instance._waitingForKey)
				{
					__state = null;
					return;
				}
				KeyBindButton[] keyBindButtons = __instance.keyBindButtons;
				string[] array = new string[keyBindButtons.Length];
				for (int i = 0; i < keyBindButtons.Length; i++)
				{
					array[i] = keyBindButtons[i]?._keyBind;
				}
				__state = array;
			}

			[HarmonyPostfix]
			private static void CompareKeys(SettingsManager __instance, string[] __state)
			{
				//IL_005c: Unknown result type (might be due to invalid IL or missing references)
				if (__state == null)
				{
					return;
				}
				KeyBindButton[] keyBindButtons = __instance.keyBindButtons;
				for (int i = 0; i < keyBindButtons.Length; i++)
				{
					string text = __state[i];
					string keyBind = keyBindButtons[i]._keyBind;
					if (!(text == keyBind) && SettingsTab.KeyButtonIndexToKeyButton.ContainsKey(i))
					{
						SettingsTab.KeyButtonIndexToKeyButton[i].SetValue(Enum.Parse<KeyCode>(keyBind));
					}
				}
			}
		}

		[HarmonyPatch(typeof(SettingsManager), "OnGUI")]
		private static class ListenForKeyChanges2
		{
			[HarmonyPrefix]
			private static void RecordKeys(SettingsManager __instance, out string[] __state)
			{
				if (!__instance._waitingForKey)
				{
					__state = null;
					return;
				}
				KeyBindButton[] keyBindButtons = __instance.keyBindButtons;
				string[] array = new string[keyBindButtons.Length];
				for (int i = 0; i < keyBindButtons.Length; i++)
				{
					array[i] = keyBindButtons[i]?._keyBind;
				}
				__state = array;
			}

			[HarmonyPostfix]
			private static void CompareKeys(SettingsManager __instance, string[] __state)
			{
				//IL_0051: Unknown result type (might be due to invalid IL or missing references)
				if (__state == null)
				{
					return;
				}
				KeyBindButton[] keyBindButtons = __instance.keyBindButtons;
				for (int i = 0; i < keyBindButtons.Length; i++)
				{
					string text = __state[i];
					string keyBind = keyBindButtons[i]._keyBind;
					if (!(text == keyBind) && SettingsTab.KeyButtonIndexToKeyButton.TryGetValue(i, out var value))
					{
						value.SetValue(Enum.Parse<KeyCode>(keyBind));
					}
				}
			}
		}

		internal static UnityEvent OnSettingsMenuInitialized { get; } = new UnityEvent();


		private static SettingsTab ModTab => Settings.ModTab;
	}
	public static class Settings
	{
		private const string CREATE_TAB_NOTE = "Sorry, but this mod currently doesn't have any way to handle overflowing the tabs container, so the functions to create more tabs will have to be inaccessible for now.";

		public static SettingsTab ModTab { get; } = new SettingsTab();


		public static UnityEvent OnInitialized { get; } = new UnityEvent();


		public static UnityEvent OnCancelSettings { get; } = new UnityEvent();


		public static UnityEvent OnApplySettings { get; } = new UnityEvent();


		public static UnityEvent OnCloseSettings { get; } = new UnityEvent();


		internal static int ModTabIndex { get; set; }

		internal static SettingsTab AddTab(string label)
		{
			return new SettingsTab();
		}

		internal static AtlyssTabButton AddTabButton(string label)
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Expected O, but got Unknown
			SettingsManager current = SettingsManager._current;
			Transform val = Utility.FindTabsContainer(current);
			AtlyssTabButton atlyssTabButton = TemplateManager.CreateTabButton((RectTransform)val);
			atlyssTabButton.Label.text = label;
			((Component)atlyssTabButton.Root).gameObject.SetActive(true);
			return atlyssTabButton;
		}
	}
	public class SettingsTab
	{
		private const float DEFAULT_SLIDER_MIN = 0f;

		private const float DEFAULT_SLIDER_MAX = 1f;

		public AtlyssTabButton TabButton;

		public MenuElement Element;

		public RectTransform Content;

		public List<BaseAtlyssElement> ContentElements = new List<BaseAtlyssElement>();

		internal AtlyssSpace BottomSpace;

		internal static Dictionary<int, AtlyssKeyButton> KeyButtonIndexToKeyButton = new Dictionary<int, AtlyssKeyButton>();

		public AtlyssSpace AddSpace()
		{
			AtlyssSpace atlyssSpace = TemplateManager.CreateSpace(Content);
			((Component)atlyssSpace.Root).gameObject.SetActive(true);
			PushElement(atlyssSpace);
			return atlyssSpace;
		}

		public AtlyssHeader AddHeader(string label)
		{
			AtlyssHeader atlyssHeader = TemplateManager.CreateHeader(Content);
			atlyssHeader.Label.text = label;
			((Component)atlyssHeader.Root).gameObject.SetActive(true);
			PushElement(atlyssHeader);
			return atlyssHeader;
		}

		public AtlyssButton AddButton(string buttonLabel, UnityAction onClick)
		{
			AtlyssButton atlyssButton = AddButton(buttonLabel);
			((UnityEvent)atlyssButton.Button.onClick).AddListener(onClick);
			return atlyssButton;
		}

		public AtlyssButton AddButton(string buttonLabel)
		{
			AtlyssButton atlyssButton = TemplateManager.CreateButton(Content);
			atlyssButton.ButtonLabel.text = buttonLabel;
			((Component)atlyssButton.Root).gameObject.SetActive(true);
			PushElement(atlyssButton);
			return atlyssButton;
		}

		public AtlyssToggle AddToggle(ConfigEntry<bool> config)
		{
			return AddToggle(((ConfigEntryBase)config).Definition.Key, config);
		}

		public AtlyssToggle AddToggle(string label, ConfigEntry<bool> config)
		{
			AtlyssToggle atlyssToggle = AddToggle(label, config.Value);
			atlyssToggle.OnValueChanged.AddListener((UnityAction<bool>)delegate(bool newValue)
			{
				config.Value = newValue;
			});
			return atlyssToggle;
		}

		public AtlyssToggle AddToggle(string label, bool value = false)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Expected O, but got Unknown
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Expected O, but got Unknown
			AtlyssToggle element = TemplateManager.CreateToggle(Content);
			Settings.OnCloseSettings.AddListener((UnityAction)delegate
			{
				element.Revert();
			});
			Settings.OnApplySettings.AddListener((UnityAction)delegate
			{
				element.Apply();
			});
			element.Label.text = label;
			element.Toggle.SetIsOnWithoutNotify(value);
			element.Apply();
			((Component)element.Root).gameObject.SetActive(true);
			PushElement(element);
			return element;
		}

		public AtlyssSimpleSlider AddSlider(ConfigEntry<float> config, bool wholeNumbers = false)
		{
			return AddSlider(((ConfigEntryBase)config).Definition.Key, config, wholeNumbers);
		}

		public AtlyssSimpleSlider AddSlider(string label, ConfigEntry<float> config, bool wholeNumbers = false)
		{
			float min = 0f;
			float max = 1f;
			if (((ConfigEntryBase)config).Description.AcceptableValues is AcceptableValueRange<float> val)
			{
				min = val.MinValue;
				max = val.MaxValue;
			}
			AtlyssSimpleSlider atlyssSimpleSlider = AddSlider(label, config.Value, min, max, wholeNumbers);
			atlyssSimpleSlider?.OnValueChanged.AddListener((UnityAction<float>)delegate(float newValue)
			{
				config.Value = newValue;
			});
			return atlyssSimpleSlider;
		}

		public AtlyssSimpleSlider AddSlider(string label, float value = 0f, float min = 0f, float max = 1f, bool wholeNumbers = false)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Expected O, but got Unknown
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Expected O, but got Unknown
			AtlyssSimpleSlider element = TemplateManager.CreateSimpleSlider(Content);
			Settings.OnCloseSettings.AddListener((UnityAction)delegate
			{
				element.Revert();
			});
			Settings.OnApplySettings.AddListener((UnityAction)delegate
			{
				element.Apply();
			});
			element.Label.text = label;
			element.Slider.wholeNumbers = wholeNumbers;
			element.Slider.minValue = min;
			element.Slider.maxValue = max;
			element.Slider.SetValueWithoutNotify(value);
			element.Apply();
			((Component)element.Root).gameObject.SetActive(true);
			PushElement(element);
			return element;
		}

		public AtlyssAdvancedSlider AddAdvancedSlider(ConfigEntry<int> config)
		{
			return AddAdvancedSlider(((ConfigEntryBase)config).Definition.Key, config);
		}

		public AtlyssAdvancedSlider AddAdvancedSlider(string label, ConfigEntry<int> config)
		{
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Expected O, but got Unknown
			float min = 0f;
			float max = 1f;
			if (((ConfigEntryBase)config).Description.AcceptableValues is AcceptableValueRange<float> val)
			{
				min = val.MinValue;
				max = val.MaxValue;
			}
			AtlyssAdvancedSlider element = AddAdvancedSlider(label, config.Value, min, max, wholeNumbers: true);
			element?.OnValueChanged.AddListener((UnityAction<float>)delegate(float newValue)
			{
				config.Value = Mathf.RoundToInt(newValue);
			});
			AtlyssAdvancedSlider atlyssAdvancedSlider = element;
			if (atlyssAdvancedSlider != null)
			{
				atlyssAdvancedSlider.OnResetClicked.AddListener((UnityAction)delegate
				{
					element.SetValue((float)((ConfigEntryBase)config).DefaultValue);
				});
			}
			return element;
		}

		public AtlyssAdvancedSlider AddAdvancedSlider(ConfigEntry<float> config, bool wholeNumbers = false)
		{
			return AddAdvancedSlider(((ConfigEntryBase)config).Definition.Key, config, wholeNumbers);
		}

		public AtlyssAdvancedSlider AddAdvancedSlider(string label, ConfigEntry<float> config, bool wholeNumbers = false)
		{
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Expected O, but got Unknown
			float min = 0f;
			float max = 1f;
			if (((ConfigEntryBase)config).Description.AcceptableValues is AcceptableValueRange<float> val)
			{
				min = val.MinValue;
				max = val.MaxValue;
			}
			AtlyssAdvancedSlider element = AddAdvancedSlider(label, config.Value, min, max, wholeNumbers);
			element?.OnValueChanged.AddListener((UnityAction<float>)delegate(float newValue)
			{
				config.Value = newValue;
			});
			AtlyssAdvancedSlider atlyssAdvancedSlider = element;
			if (atlyssAdvancedSlider != null)
			{
				atlyssAdvancedSlider.OnResetClicked.AddListener((UnityAction)delegate
				{
					element.SetValue((float)((ConfigEntryBase)config).DefaultValue);
				});
			}
			return element;
		}

		public AtlyssAdvancedSlider AddAdvancedSlider(string label, float value = 0f, float min = 0f, float max = 1f, bool wholeNumbers = false)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Expected O, but got Unknown
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Expected O, but got Unknown
			AtlyssAdvancedSlider element = TemplateManager.CreateAdvancedSlider(Content);
			Settings.OnCloseSettings.AddListener((UnityAction)delegate
			{
				element.Revert();
			});
			Settings.OnApplySettings.AddListener((UnityAction)delegate
			{
				element.Apply();
			});
			element.Label.text = label;
			element.ValueText.text = value.ToString(CultureInfo.InvariantCulture);
			element.Slider.wholeNumbers = wholeNumbers;
			element.Slider.minValue = min;
			element.Slider.maxValue = max;
			element.Slider.SetValueWithoutNotify(value);
			element.Apply();
			((UnityEvent<float>)(object)element.Slider.onValueChanged).AddListener((UnityAction<float>)delegate(float newValue)
			{
				element.ValueText.text = newValue.ToString(CultureInfo.InvariantCulture);
			});
			((Component)element.Root).gameObject.SetActive(true);
			PushElement(element);
			return element;
		}

		public AtlyssDropdown AddDropdown<T>(ConfigEntry<T> config) where T : Enum
		{
			return AddDropdown<T>(((ConfigEntryBase)config).Definition.Key, config);
		}

		public AtlyssDropdown AddDropdown<T>(string label, ConfigEntry<T> config) where T : Enum
		{
			string[] names = Enum.GetNames(config.Value.GetType());
			AtlyssDropdown atlyssDropdown = AddDropdown(label, names, (int)(object)config.Value);
			atlyssDropdown.OnValueChanged.AddListener((UnityAction<int>)delegate(int newValue)
			{
				config.Value = (T)(object)newValue;
			});
			return atlyssDropdown;
		}

		public AtlyssDropdown AddDropdown(string label, string[] options, int value = 0)
		{
			return AddDropdown(label, options.ToList(), value);
		}

		public AtlyssDropdown AddDropdown(string label, List<string> options, int value = 0)
		{
			AtlyssDropdown atlyssDropdown = AddDropdown(label);
			atlyssDropdown.Dropdown.AddOptions(options);
			atlyssDropdown.Dropdown.SetValueWithoutNotify(value);
			atlyssDropdown.Apply();
			PushElement(atlyssDropdown);
			return atlyssDropdown;
		}

		public AtlyssDropdown AddDropdown(string label, List<Sprite> options, int value = 0)
		{
			AtlyssDropdown atlyssDropdown = AddDropdown(label);
			atlyssDropdown.Dropdown.AddOptions(options);
			atlyssDropdown.Dropdown.SetValueWithoutNotify(value);
			atlyssDropdown.Apply();
			PushElement(atlyssDropdown);
			return atlyssDropdown;
		}

		public AtlyssDropdown AddDropdown(string label)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Expected O, but got Unknown
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Expected O, but got Unknown
			AtlyssDropdown element = TemplateManager.CreateDropdown(Content);
			Settings.OnCloseSettings.AddListener((UnityAction)delegate
			{
				element.Revert();
			});
			Settings.OnApplySettings.AddListener((UnityAction)delegate
			{
				element.Apply();
			});
			element.Label.text = label;
			((Component)element.Root).gameObject.SetActive(true);
			PushElement(element);
			return element;
		}

		public AtlyssKeyButton AddKeyButton(ConfigEntry<KeyCode> config)
		{
			return AddKeyButton(((ConfigEntryBase)config).Definition.Key, config);
		}

		public AtlyssKeyButton AddKeyButton(string label, ConfigEntry<KeyCode> config)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			AtlyssKeyButton atlyssKeyButton = AddKeyButton(label, config.Value);
			atlyssKeyButton.OnValueChanged.AddListener((UnityAction<KeyCode>)delegate(KeyCode newValue)
			{
				//IL_0007: Unknown result type (might be due to invalid IL or missing references)
				config.Value = newValue;
			});
			return atlyssKeyButton;
		}

		public AtlyssKeyButton AddKeyButton(string label, KeyCode value = 0)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Expected O, but got Unknown
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Expected O, but got Unknown
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			AtlyssKeyButton element = TemplateManager.CreateKeyButton(Content);
			Settings.OnCloseSettings.AddListener((UnityAction)delegate
			{
				element.Revert();
			});
			Settings.OnApplySettings.AddListener((UnityAction)delegate
			{
				element.Apply();
			});
			element.Label.text = label;
			element.SetValue(value);
			element.Apply();
			((Component)element.Root).gameObject.SetActive(true);
			RegisterKeyButton(element);
			PushElement(element);
			return element;
		}

		private static void RegisterKeyButton(AtlyssKeyButton element)
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Expected O, but got Unknown
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Expected O, but got Unknown
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Expected O, but got Unknown
			SettingsManager manager = SettingsManager._current;
			KeyBindButton keyButton = new KeyBindButton
			{
				_inputReference = "",
				_keyBind = element.ButtonLabel.text,
				_button = element.Button,
				_buttonLabel = element.ButtonLabel
			};
			int newButtonIndex = manager.keyBindButtons.Length;
			((UnityEvent)keyButton._button.onClick).AddListener((UnityAction)delegate
			{
				manager.OnClick_KeybindButton(newButtonIndex);
			});
			KeyButtonIndexToKeyButton.Add(newButtonIndex, element);
			Settings.OnCloseSettings.AddListener((UnityAction)delegate
			{
				keyButton._keyBind = element.ButtonLabel.text;
			});
			manager.keyBindButtons = CollectionExtensions.AddToArray<KeyBindButton>(manager.keyBindButtons, keyButton);
		}

		private void PushElement(BaseAtlyssElement element)
		{
			ContentElements.Add(element);
			AtlyssSpace bottomSpace = BottomSpace;
			if (bottomSpace != null)
			{
				((Transform)bottomSpace.Root).SetSiblingIndex(((Transform)Content).childCount);
			}
		}
	}
	internal static class TemplateManager
	{
		internal static AtlyssTabButton TabTemplate;

		internal static AtlyssSpace SpaceTemplate;

		internal static AtlyssHeader HeaderTemplate;

		internal static AtlyssButton ButtonTemplate;

		internal static AtlyssToggle ToggleTemplate;

		internal static AtlyssSimpleSlider SimpleSliderTemplate;

		internal static AtlyssAdvancedSlider AdvancedSliderTemplate;

		internal static AtlyssDropdown DropdownTemplate;

		internal static AtlyssKeyButton KeyButtonTemplate;

		internal static void Initialize()
		{
			FindTemplateElements();
		}

		private static void FindTemplateElements()
		{
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Expected O, but got Unknown
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Expected O, but got Unknown
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Expected O, but got Unknown
			SettingsManager val = Object.FindObjectOfType<SettingsManager>(true);
			Transform val2 = Utility.FindTabsContainer(val);
			if (!Object.op_Implicit((Object)(object)val2))
			{
				EasySettingsPlugin.Logger.LogError((object)"Unable to find settings tabs container GameObject. EasySettings won't be available.");
				return;
			}
			RectTransform template = (RectTransform)val2.GetChild(0);
			TabTemplate = CreateTabButton((RectTransform)val2, template);
			((Component)TabTemplate.Root).gameObject.SetActive(false);
			SettingsTab modTab = Settings.ModTab;
			Transform val3 = Object.Instantiate<Transform>(((Component)val._videoTabElement).transform, ((Component)val._videoTabElement).transform.parent);
			modTab.Element = ((Component)val3).GetComponent<MenuElement>();
			modTab.Content = (RectTransform)((Component)((Component)val3).GetComponentInChildren<VerticalLayoutGroup>()).transform;
			InitializeTabContent(modTab.Content);
			RectTransform val4 = FindSpace(val);
			if (Object.op_Implicit((Object)(object)val4))
			{
				SpaceTemplate = CreateSpace(modTab.Content, val4);
				((Component)SpaceTemplate.Root).gameObject.SetActive(false);
			}
			RectTransform val5 = FindHeader(val);
			if (Object.op_Implicit((Object)(object)val5))
			{
				HeaderTemplate = CreateHeader(modTab.Content, val5);
				((Component)HeaderTemplate.Root).gameObject.SetActive(false);
			}
			RectTransform val6 = FindButton(val);
			if (Object.op_Implicit((Object)(object)val6))
			{
				ButtonTemplate = CreateButton(modTab.Content, val6);
				((Component)ButtonTemplate.Root).gameObject.SetActive(false);
			}
			RectTransform val7 = FindToggle(val);
			if (Object.op_Implicit((Object)(object)val7))
			{
				ToggleTemplate = CreateToggle(modTab.Content, val7);
				((Component)ToggleTemplate.Root).gameObject.SetActive(false);
			}
			RectTransform val8 = FindSimpleSlider(val);
			if (Object.op_Implicit((Object)(object)val8))
			{
				SimpleSliderTemplate = CreateSimpleSlider(modTab.Content, val8);
				((Component)SimpleSliderTemplate.Root).gameObject.SetActive(false);
			}
			RectTransform val9 = FindAdvancedSlider(val);
			if (Object.op_Implicit((Object)(object)val9))
			{
				AdvancedSliderTemplate = CreateAdvancedSlider(modTab.Content, val9);
				((Component)AdvancedSliderTemplate.Root).gameObject.SetActive(false);
			}
			RectTransform val10 = FindDropdown(val);
			if (Object.op_Implicit((Object)(object)val10))
			{
				DropdownTemplate = CreateDropdown(modTab.Content, val10);
				((Component)DropdownTemplate.Root).gameObject.SetActive(false);
			}
			RectTransform val11 = FindKeyButton(val);
			if (Object.op_Implicit((Object)(object)val11))
			{
				KeyButtonTemplate = CreateKeyButton(modTab.Content, val11);
				((Component)KeyButtonTemplate.Root).gameObject.SetActive(false);
			}
		}

		private static void InitializeTabContent(RectTransform tabContent)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			foreach (RectTransform item in (Transform)tabContent)
			{
				RectTransform val = item;
				Object.Destroy((Object)(object)((Component)val).gameObject);
			}
		}

		private static RectTransform FindSpace(SettingsManager manager)
		{
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Expected O, but got Unknown
			RectTransform[] array = (RectTransform[])(object)new RectTransform[4] { manager._videoTabContent, manager._audioTabContent, manager._inputTabContent, manager._networkTabContent };
			RectTransform[] array2 = array;
			foreach (RectTransform val in array2)
			{
				foreach (RectTransform item in (Transform)val)
				{
					RectTransform val2 = item;
					if (((Transform)val2).childCount == 0)
					{
						Component[] components = ((Component)val2).GetComponents<Component>();
						if (components.Length <= 1)
						{
							return val2;
						}
					}
				}
			}
			return null;
		}

		private static RectTransform FindHeader(SettingsManager manager)
		{
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Expected O, but got Unknown
			RectTransform[] array = (RectTransform[])(object)new RectTransform[4] { manager._videoTabContent, manager._audioTabContent, manager._inputTabContent, manager._networkTabContent };
			RectTransform[] array2 = array;
			foreach (RectTransform val in array2)
			{
				foreach (RectTransform item in (Transform)val)
				{
					RectTransform val2 = item;
					Selectable componentInChildren = ((Component)val2).GetComponentInChildren<Selectable>(true);
					if (!Object.op_Implicit((Object)(object)componentInChildren))
					{
						Text componentInChildren2 = ((Component)val2).GetComponentInChildren<Text>(true);
						if (Object.op_Implicit((Object)(object)componentInChildren2))
						{
							return val2;
						}
					}
				}
			}
			return null;
		}

		private static RectTransform FindButton(SettingsManager manager)
		{
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Expected O, but got Unknown
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Expected O, but got Unknown
			Transform[] array = (Transform[])(object)new Transform[4]
			{
				(Transform)manager._videoTabContent,
				(Transform)manager._audioTabContent,
				(Transform)manager._inputTabContent,
				(Transform)manager._networkTabContent
			};
			Transform[] array2 = array;
			for (int i = 0; i < array2.Length; i++)
			{
				RectTransform val = (RectTransform)array2[i];
				foreach (RectTransform item in (Transform)val)
				{
					RectTransform val2 = item;
					Button componentInChildren = ((Component)val2).GetComponentInChildren<Button>(true);
					if (!Object.op_Implicit((Object)(object)componentInChildren))
					{
						continue;
					}
					Text componentInChildren2 = ((Component)val2).GetComponentInChildren<Text>(true);
					if (Object.op_Implicit((Object)(object)componentInChildren2))
					{
						Selectable[] componentsInChildren = ((Component)val2).GetComponentsInChildren<Selectable>(true);
						if (componentsInChildren.Length <= 1)
						{
							return val2;
						}
					}
				}
			}
			return null;
		}

		private static RectTransform FindToggle(SettingsManager manager)
		{
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Expected O, but got Unknown
			Transform[] contents = (Transform[])(object)new Transform[4]
			{
				(Transform)manager._videoTabContent,
				(Transform)manager._audioTabContent,
				(Transform)manager._inputTabContent,
				(Transform)manager._networkTabContent
			};
			Toggle fullScreenToggle = manager._fullScreenToggle;
			if (!Utility.TryGetElementRoot(contents, ((Component)fullScreenToggle).transform, out var root))
			{
				return null;
			}
			List<Component> components = ((Component)root).gameObject.AddComponent<ComponentReferences>().components;
			components.Add((Component)(object)fullScreenToggle);
			return (RectTransform)root;
		}

		private static RectTransform FindSimpleSlider(SettingsManager manager)
		{
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Expected O, but got Unknown
			Transform[] contents = (Transform[])(object)new Transform[4]
			{
				(Transform)manager._videoTabContent,
				(Transform)manager._audioTabContent,
				(Transform)manager._inputTabContent,
				(Transform)manager._networkTabContent
			};
			Slider masterVolumeSlider = manager._masterVolumeSlider;
			if (!Utility.TryGetElementRoot(contents, ((Component)masterVolumeSlider).transform, out var root))
			{
				return null;
			}
			List<Component> components = ((Component)root).gameObject.AddComponent<ComponentReferences>().components;
			components.Add((Component)(object)masterVolumeSlider);
			return (RectTransform)root;
		}

		private static RectTransform FindAdvancedSlider(SettingsManager manager)
		{
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Expected O, but got Unknown
			Transform[] contents = (Transform[])(object)new Transform[4]
			{
				(Transform)manager._videoTabContent,
				(Transform)manager._audioTabContent,
				(Transform)manager._inputTabContent,
				(Transform)manager._networkTabContent
			};
			Slider cameraFieldOfViewSlider = manager._cameraFieldOfViewSlider;
			Text cameraFieldOfViewText = manager._cameraFieldOfViewText;
			if (!Utility.TryGetElementRoot(contents, ((Component)cameraFieldOfViewSlider).transform, out var root))
			{
				return null;
			}
			List<Component> components = ((Component)root).gameObject.AddComponent<ComponentReferences>().components;
			components.Add((Component)(object)cameraFieldOfViewSlider);
			components.Add((Component)(object)cameraFieldOfViewText);
			return (RectTransform)root;
		}

		private static RectTransform FindDropdown(SettingsManager manager)
		{
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Expected O, but got Unknown
			Transform[] contents = (Transform[])(object)new Transform[4]
			{
				(Transform)manager._videoTabContent,
				(Transform)manager._audioTabContent,
				(Transform)manager._inputTabContent,
				(Transform)manager._networkTabContent
			};
			Dropdown fullScreenResolutionDropdown = manager._fullScreenResolutionDropdown;
			if (!Utility.TryGetElementRoot(contents, ((Component)fullScreenResolutionDropdown).transform, out var root))
			{
				return null;
			}
			List<Component> components = ((Component)root).gameObject.AddComponent<ComponentReferences>().components;
			components.Add((Component)(object)fullScreenResolutionDropdown);
			return (RectTransform)root;
		}

		private static RectTransform FindKeyButton(SettingsManager manager)
		{
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Expected O, but got Unknown
			Transform[] contents = (Transform[])(object)new Transform[4]
			{
				(Transform)manager._videoTabContent,
				(Transform)manager._audioTabContent,
				(Transform)manager._inputTabContent,
				(Transform)manager._networkTabContent
			};
			KeyBindButton[] keyBindButtons = manager.keyBindButtons;
			if (keyBindButtons == null || keyBindButtons.Length <= 0)
			{
				return null;
			}
			KeyBindButton[] array = keyBindButtons;
			foreach (KeyBindButton val in array)
			{
				if (val != null)
				{
					Button button = val._button;
					Text buttonLabel = val._buttonLabel;
					if (Utility.TryGetElementRoot(contents, ((Component)button).transform, out var root))
					{
						List<Component> components = ((Component)root).gameObject.AddComponent<ComponentReferences>().components;
						components.Add((Component)(object)button);
						components.Add((Component)(object)buttonLabel);
						return (RectTransform)root;
					}
				}
			}
			return null;
		}

		internal static AtlyssTabButton CreateTabButton(RectTransform container)
		{
			return CreateTabButton(container, TabTemplate);
		}

		internal static AtlyssTabButton CreateTabButton(RectTransform container, AtlyssTabButton template)
		{
			return CreateTabButton(container, template.Root);
		}

		internal static AtlyssTabButton CreateTabButton(RectTransform container, RectTransform template)
		{
			RectTransform val = Object.Instantiate<RectTransform>(template, (Transform)(object)container);
			AtlyssTabButton atlyssTabButton = new AtlyssTabButton
			{
				Root = val,
				Label = ((Component)val).GetComponentInChildren<Text>(true),
				Button = ((Component)val).GetComponentInChildren<Button>(true)
			};
			atlyssTabButton.Initialize();
			return atlyssTabButton;
		}

		internal static AtlyssHeader CreateHeader(RectTransform container)
		{
			return CreateHeader(container, HeaderTemplate);
		}

		internal static AtlyssHeader CreateHeader(RectTransform container, AtlyssHeader template)
		{
			return CreateHeader(container, template.Root);
		}

		internal static AtlyssHeader CreateHeader(RectTransform container, RectTransform template)
		{
			RectTransform val = Object.Instantiate<RectTransform>(template, (Transform)(object)container);
			AtlyssHeader atlyssHeader = new AtlyssHeader
			{
				Root = val,
				Label = ((Component)val).GetComponentInChildren<Text>(true)
			};
			atlyssHeader.Initialize();
			return atlyssHeader;
		}

		internal static AtlyssButton CreateButton(RectTransform container)
		{
			return CreateButton(container, ButtonTemplate);
		}

		internal static AtlyssButton CreateButton(RectTransform container, AtlyssButton template)
		{
			return CreateButton(container, template.Root);
		}

		internal static AtlyssButton CreateButton(RectTransform container, RectTransform template)
		{
			RectTransform val = Object.Instantiate<RectTransform>(template, (Transform)(object)container);
			AtlyssButton atlyssButton = new AtlyssButton
			{
				Root = val,
				ButtonLabel = ((Component)val).GetComponentInChildren<Text>(true),
				Button = ((Component)val).GetComponentInChildren<Button>(true)
			};
			atlyssButton.Initialize();
			return atlyssButton;
		}

		internal static AtlyssToggle CreateToggle(RectTransform container)
		{
			return CreateToggle(container, ToggleTemplate);
		}

		internal static AtlyssToggle CreateToggle(RectTransform container, AtlyssToggle template)
		{
			return CreateToggle(container, template.Root);
		}

		internal static AtlyssToggle CreateToggle(RectTransform container, RectTransform template)
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Expected O, but got Unknown
			RectTransform val = Object.Instantiate<RectTransform>(template, (Transform)(object)container);
			AtlyssToggle atlyssToggle = new AtlyssToggle
			{
				Root = val,
				Label = ((Component)val).GetComponentInChildren<Text>(true),
				Toggle = (Toggle)((Component)val).GetComponentInChildren<ComponentReferences>(true).components[0]
			};
			atlyssToggle.Initialize();
			return atlyssToggle;
		}

		internal static AtlyssSimpleSlider CreateSimpleSlider(RectTransform container)
		{
			return CreateSimpleSlider(container, SimpleSliderTemplate);
		}

		internal static AtlyssSimpleSlider CreateSimpleSlider(RectTransform container, AtlyssSimpleSlider template)
		{
			return CreateSimpleSlider(container, template.Root);
		}

		internal static AtlyssSimpleSlider CreateSimpleSlider(RectTransform container, RectTransform template)
		{
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Expected O, but got Unknown
			RectTransform val = Object.Instantiate<RectTransform>(template, (Transform)(object)container);
			List<Component> components = ((Component)val).GetComponentInChildren<ComponentReferences>(true).components;
			AtlyssSimpleSlider atlyssSimpleSlider = new AtlyssSimpleSlider
			{
				Root = val,
				Label = ((Component)val).GetComponentInChildren<Text>(true),
				Slider = (Slider)components[0]
			};
			atlyssSimpleSlider.Initialize();
			return atlyssSimpleSlider;
		}

		internal static AtlyssAdvancedSlider CreateAdvancedSlider(RectTransform container)
		{
			return CreateAdvancedSlider(container, AdvancedSliderTemplate);
		}

		internal static AtlyssAdvancedSlider CreateAdvancedSlider(RectTransform container, AtlyssAdvancedSlider template)
		{
			return CreateAdvancedSlider(container, template.Root);
		}

		internal static AtlyssAdvancedSlider CreateAdvancedSlider(RectTransform container, RectTransform template)
		{
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Expected O, but got Unknown
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Expected O, but got Unknown
			RectTransform val = Object.Instantiate<RectTransform>(template, (Transform)(object)container);
			List<Component> components = ((Component)val).GetComponentInChildren<ComponentReferences>(true).components;
			AtlyssAdvancedSlider atlyssAdvancedSlider = new AtlyssAdvancedSlider
			{
				Root = val,
				Label = ((Component)val).GetComponentInChildren<Text>(true),
				ValueText = (Text)components[1],
				Slider = (Slider)components[0],
				ResetButton = ((Component)val).GetComponentInChildren<Button>(true)
			};
			atlyssAdvancedSlider.Initialize();
			return atlyssAdvancedSlider;
		}

		internal static AtlyssDropdown CreateDropdown(RectTransform container)
		{
			return CreateDropdown(container, DropdownTemplate);
		}

		internal static AtlyssDropdown CreateDropdown(RectTransform container, AtlyssDropdown template)
		{
			return CreateDropdown(container, template.Root);
		}

		internal static AtlyssDropdown CreateDropdown(RectTransform container, RectTransform template)
		{
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Expected O, but got Unknown
			RectTransform val = Object.Instantiate<RectTransform>(template, (Transform)(object)container);
			List<Component> components = ((Component)val).GetComponentInChildren<ComponentReferences>(true).components;
			AtlyssDropdown atlyssDropdown = new AtlyssDropdown
			{
				Root = val,
				Label = ((Component)val).GetComponentInChildren<Text>(true),
				Dropdown = (Dropdown)components[0]
			};
			atlyssDropdown.Initialize();
			return atlyssDropdown;
		}

		internal static AtlyssKeyButton CreateKeyButton(RectTransform container)
		{
			return CreateKeyButton(container, KeyButtonTemplate);
		}

		internal static AtlyssKeyButton CreateKeyButton(RectTransform container, AtlyssKeyButton template)
		{
			return CreateKeyButton(container, template.Root);
		}

		internal static AtlyssKeyButton CreateKeyButton(RectTransform container, RectTransform template)
		{
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Expected O, but got Unknown
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Expected O, but got Unknown
			RectTransform val = Object.Instantiate<RectTransform>(template, (Transform)(object)container);
			List<Component> components = ((Component)val).GetComponentInChildren<ComponentReferences>(true).components;
			AtlyssKeyButton atlyssKeyButton = new AtlyssKeyButton
			{
				Root = val,
				Label = ((Component)val).GetComponentInChildren<Text>(true),
				ButtonLabel = (Text)components[1],
				Button = (Button)components[0]
			};
			atlyssKeyButton.Initialize();
			return atlyssKeyButton;
		}

		internal static AtlyssSpace CreateSpace(RectTransform container)
		{
			return CreateSpace(container, SpaceTemplate);
		}

		internal static AtlyssSpace CreateSpace(RectTransform container, AtlyssSpace template)
		{
			return CreateSpace(container, template.Root);
		}

		internal static AtlyssSpace CreateSpace(RectTransform container, RectTransform template)
		{
			RectTransform root = Object.Instantiate<RectTransform>(template, (Transform)(object)container);
			return new AtlyssSpace
			{
				Root = root
			};
		}
	}
	public static class Utility
	{
		public static bool TryGetRelativeRoot(Transform relativeParent, Transform child, out Transform root)
		{
			root = child;
			while (Object.op_Implicit((Object)(object)root))
			{
				if ((Object)(object)root.parent == (Object)(object)relativeParent)
				{
					return true;
				}
				root = root.parent;
			}
			root = null;
			return false;
		}

		public static bool TryGetElementRoot(Transform[] contents, Transform elementChild, out Transform root)
		{
			foreach (Transform relativeParent in contents)
			{
				if (TryGetRelativeRoot(relativeParent, ((Component)elementChild).transform, out root))
				{
					return true;
				}
			}
			root = null;
			return false;
		}

		public static Transform FindTabsContainer(SettingsManager instance)
		{
			Button[] componentsInChildren = ((Component)instance).GetComponentsInChildren<Button>(true);
			foreach (Button val in componentsInChildren)
			{
				foreach (PersistentCall call in ((UnityEventBase)val.onClick).m_PersistentCalls.m_Calls)
				{
					if (call == null || call.target != (Object)(object)instance || call.methodName != "Set_SettingMenuSelectionIndex")
					{
						continue;
					}
					return ((Component)val).transform.parent;
				}
			}
			return null;
		}

		public static Button FindCancelButton(SettingsManager instance)
		{
			Button[] componentsInChildren = ((Component)instance).GetComponentsInChildren<Button>(true);
			foreach (Button val in componentsInChildren)
			{
				foreach (PersistentCall call in ((UnityEventBase)val.onClick).m_PersistentCalls.m_Calls)
				{
					if (call == null || call.target != (Object)(object)instance || call.methodName != "Close_SettingsMenu")
					{
						continue;
					}
					return val;
				}
			}
			return null;
		}

		public static Button FindApplyButton(SettingsManager instance)
		{
			Button[] componentsInChildren = ((Component)instance).GetComponentsInChildren<Button>(true);
			foreach (Button val in componentsInChildren)
			{
				foreach (PersistentCall call in ((UnityEventBase)val.onClick).m_PersistentCalls.m_Calls)
				{
					if (call == null || call.target != (Object)(object)instance || call.methodName != "Save_SettingsData")
					{
						continue;
					}
					return val;
				}
			}
			return null;
		}

		public static bool IsKeyBound(SettingsManager instance, KeyCode key)
		{
			return IsKeyBound(instance, ((object)(KeyCode)(ref key)).ToString());
		}

		public static bool IsKeyBound(SettingsManager instance, string key)
		{
			KeyBindButton[] keyBindButtons = instance.keyBindButtons;
			foreach (KeyBindButton val in keyBindButtons)
			{
				if (val._keyBind == key)
				{
					return true;
				}
			}
			return false;
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "EasySettings";

		public const string PLUGIN_NAME = "Easy Settings API";

		public const string PLUGIN_VERSION = "1.1.3";
	}
}
namespace Nessie.ATLYSS.EasySettings.Extensions
{
	public static class UnityEventExtensions
	{
		public static void SetAllPersistentListenerStates(this UnityEventBase unityEvent, UnityEventCallState state)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 0; i < unityEvent.GetPersistentEventCount(); i++)
			{
				unityEvent.SetPersistentListenerState(i, state);
			}
		}

		public static void DisablePersistentListeners(this UnityEventBase unityEvent)
		{
			unityEvent.SetAllPersistentListenerStates((UnityEventCallState)0);
		}

		public static void RemoveAndDisableAllListeners(this UnityEventBase unityEvent)
		{
			unityEvent.RemoveAllListeners();
			unityEvent.DisablePersistentListeners();
		}
	}
}
namespace Nessie.ATLYSS.EasySettings.UIElements
{
	public class AtlyssAdvancedSlider : BaseAtlyssLabelElement, IValueElement
	{
		public Text ValueText;

		private Slider _slider;

		private Button _resetButton;

		public Slider Slider
		{
			get
			{
				return _slider;
			}
			set
			{
				if (Object.op_Implicit((Object)(object)_slider))
				{
					((UnityEvent<float>)(object)_slider.onValueChanged).RemoveListener((UnityAction<float>)ValueChanged);
				}
				_slider = value;
				if (Object.op_Implicit((Object)(object)_slider))
				{
					((UnityEvent<float>)(object)_slider.onValueChanged).AddListener((UnityAction<float>)ValueChanged);
				}
			}
		}

		public Button ResetButton
		{
			get
			{
				return _resetButton;
			}
			set
			{
				//IL_0022: Unknown result type (might be due to invalid IL or missing references)
				//IL_002c: Expected O, but got Unknown
				//IL_0055: Unknown result type (might be due to invalid IL or missing references)
				//IL_005f: Expected O, but got Unknown
				if (Object.op_Implicit((Object)(object)_resetButton))
				{
					((UnityEvent)_resetButton.onClick).RemoveListener(new UnityAction(ResetClicked));
				}
				_resetButton = value;
				if (Object.op_Implicit((Object)(object)_resetButton))
				{
					((UnityEvent)_resetButton.onClick).AddListener(new UnityAction(ResetClicked));
				}
			}
		}

		public UnityEvent<float> OnValueChanged { get; } = new UnityEvent<float>();


		public UnityEvent OnResetClicked { get; } = new UnityEvent();


		public float AppliedValue { get; private set; }

		public void Initialize()
		{
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Expected O, but got Unknown
			base.Label.text = "Advanced Slider";
			ValueText.text = $"{AppliedValue}";
			((UnityEventBase)(object)Slider.onValueChanged).RemoveAndDisableAllListeners();
			((UnityEvent<float>)(object)Slider.onValueChanged).AddListener((UnityAction<float>)ValueChanged);
			Slider.wholeNumbers = false;
			Slider.minValue = 0f;
			Slider.maxValue = 1f;
			Slider.SetValueWithoutNotify(AppliedValue);
			((UnityEventBase)(object)ResetButton.onClick).RemoveAndDisableAllListeners();
			((UnityEvent)ResetButton.onClick).AddListener(new UnityAction(ResetClicked));
		}

		public void SetValue(float value)
		{
			_slider.value = value;
		}

		public void Apply()
		{
			AppliedValue = _slider.value;
		}

		public void Revert()
		{
			_slider.value = AppliedValue;
		}

		private void ValueChanged(float newValue)
		{
			OnValueChanged.Invoke(newValue);
		}

		private void ResetClicked()
		{
			OnResetClicked.Invoke();
		}
	}
	public abstract class BaseAtlyssElement
	{
		public RectTransform Root;
	}
	public abstract class BaseAtlyssLabelElement : BaseAtlyssElement
	{
		public Text Label { get; set; }

		public string LabelText
		{
			get
			{
				return Label.text;
			}
			set
			{
				Label.text = value;
			}
		}
	}
	public interface IValueElement
	{
		private void Apply()
		{
		}

		void Revert()
		{
		}
	}
	public class AtlyssButton : BaseAtlyssElement
	{
		public Text ButtonLabel;

		private Button _button;

		public Button Button
		{
			get
			{
				return _button;
			}
			set
			{
				//IL_0022: Unknown result type (might be due to invalid IL or missing references)
				//IL_002c: Expected O, but got Unknown
				//IL_0055: Unknown result type (might be due to invalid IL or missing references)
				//IL_005f: Expected O, but got Unknown
				if (Object.op_Implicit((Object)(object)_button))
				{
					((UnityEvent)_button.onClick).RemoveListener(new UnityAction(Clicked));
				}
				_button = value;
				if (Object.op_Implicit((Object)(object)_button))
				{
					((UnityEvent)_button.onClick).RemoveListener(new UnityAction(Clicked));
				}
			}
		}

		public UnityEvent OnClicked { get; } = new UnityEvent();


		public void Initialize()
		{
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Expected O, but got Unknown
			ButtonLabel.text = "Button";
			((UnityEventBase)(object)Button.onClick).RemoveAndDisableAllListeners();
			((UnityEvent)Button.onClick).AddListener(new UnityAction(Clicked));
		}

		private void Clicked()
		{
			OnClicked.Invoke();
		}
	}
	public class AtlyssDropdown : BaseAtlyssLabelElement, IValueElement
	{
		private Dropdown _dropdown;

		public Dropdown Dropdown
		{
			get
			{
				return _dropdown;
			}
			set
			{
				if (Object.op_Implicit((Object)(object)_dropdown))
				{
					((UnityEvent<int>)(object)_dropdown.onValueChanged).RemoveListener((UnityAction<int>)ValueChanged);
				}
				_dropdown = value;
				if (Object.op_Implicit((Object)(object)_dropdown))
				{
					((UnityEvent<int>)(object)_dropdown.onValueChanged).AddListener((UnityAction<int>)ValueChanged);
				}
			}
		}

		public UnityEvent<int> OnValueChanged { get; } = new UnityEvent<int>();


		public int AppliedValue { get; private set; }

		public void Initialize()
		{
			base.Label.text = "Dropdown";
			((UnityEventBase)(object)Dropdown.onValueChanged).RemoveAndDisableAllListeners();
			((UnityEvent<int>)(object)Dropdown.onValueChanged).AddListener((UnityAction<int>)ValueChanged);
			Dropdown.options.Clear();
			Dropdown.SetValueWithoutNotify(AppliedValue);
		}

		public void Apply()
		{
			AppliedValue = Dropdown.value;
		}

		public void Revert()
		{
			Dropdown.value = AppliedValue;
		}

		private void ValueChanged(int newValue)
		{
			OnValueChanged.Invoke(newValue);
		}
	}
	public class AtlyssHeader : BaseAtlyssLabelElement
	{
		public void Initialize()
		{
			base.LabelText = "Header";
		}
	}
	public class AtlyssKeyButton : BaseAtlyssLabelElement, IValueElement
	{
		public Text ButtonLabel;

		private Button _button;

		private KeyCode _value;

		public Button Button
		{
			get
			{
				return _button;
			}
			set
			{
				//IL_0022: Unknown result type (might be due to invalid IL or missing references)
				//IL_002c: Expected O, but got Unknown
				//IL_0055: Unknown result type (might be due to invalid IL or missing references)
				//IL_005f: Expected O, but got Unknown
				if (Object.op_Implicit((Object)(object)_button))
				{
					((UnityEvent)_button.onClick).RemoveListener(new UnityAction(Clicked));
				}
				_button = value;
				if (Object.op_Implicit((Object)(object)_button))
				{
					((UnityEvent)_button.onClick).RemoveListener(new UnityAction(Clicked));
				}
			}
		}

		public UnityEvent<KeyCode> OnValueChanged { get; } = new UnityEvent<KeyCode>();


		public UnityEvent OnClicked { get; } = new UnityEvent();


		public KeyCode AppliedValue { get; private set; }

		public void Initialize()
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Expected O, but got Unknown
			base.Label.text = "Key Button";
			_value = AppliedValue;
			Text buttonLabel = ButtonLabel;
			KeyCode appliedValue = AppliedValue;
			buttonLabel.text = ((object)(KeyCode)(ref appliedValue)).ToString();
			((UnityEventBase)(object)Button.onClick).RemoveAndDisableAllListeners();
			((UnityEvent)Button.onClick).AddListener(new UnityAction(Clicked));
		}

		public void SetValue(KeyCode key)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			_value = key;
			ButtonLabel.text = ((object)(KeyCode)(ref key)).ToString();
			ValueChanged(key);
		}

		public void Apply()
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			AppliedValue = _value;
		}

		public void Revert()
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			SetValue(AppliedValue);
		}

		private void ValueChanged(KeyCode newValue)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			OnValueChanged.Invoke(newValue);
		}

		private void Clicked()
		{
			OnClicked.Invoke();
		}
	}
	public class AtlyssSimpleSlider : BaseAtlyssLabelElement, IValueElement
	{
		private Slider _slider;

		public Slider Slider
		{
			get
			{
				return _slider;
			}
			set
			{
				if (Object.op_Implicit((Object)(object)_slider))
				{
					((UnityEvent<float>)(object)_slider.onValueChanged).RemoveListener((UnityAction<float>)ValueChanged);
				}
				_slider = value;
				if (Object.op_Implicit((Object)(object)_slider))
				{
					((UnityEvent<float>)(object)_slider.onValueChanged).AddListener((UnityAction<float>)ValueChanged);
				}
			}
		}

		public UnityEvent<float> OnValueChanged { get; } = new UnityEvent<float>();


		public float AppliedValue { get; private set; }

		public void Initialize()
		{
			base.LabelText = "Slider";
			((UnityEventBase)(object)Slider.onValueChanged).RemoveAndDisableAllListeners();
			((UnityEvent<float>)(object)Slider.onValueChanged).AddListener((UnityAction<float>)ValueChanged);
			Slider.wholeNumbers = false;
			Slider.minValue = 0f;
			Slider.maxValue = 1f;
			Slider.SetValueWithoutNotify(AppliedValue);
		}

		public void Apply()
		{
			AppliedValue = _slider.value;
		}

		public void Revert()
		{
			_slider.value = AppliedValue;
		}

		private void ValueChanged(float newValue)
		{
			OnValueChanged.Invoke(newValue);
		}
	}
	public class AtlyssSpace : BaseAtlyssElement
	{
	}
	public class AtlyssTabButton : BaseAtlyssElement
	{
		public Text Label;

		private Button _resetButton;

		public Button Button
		{
			get
			{
				return _resetButton;
			}
			set
			{
				//IL_0022: Unknown result type (might be due to invalid IL or missing references)
				//IL_002c: Expected O, but got Unknown
				//IL_0055: Unknown result type (might be due to invalid IL or missing references)
				//IL_005f: Expected O, but got Unknown
				if (Object.op_Implicit((Object)(object)_resetButton))
				{
					((UnityEvent)_resetButton.onClick).RemoveListener(new UnityAction(Clicked));
				}
				_resetButton = value;
				if (Object.op_Implicit((Object)(object)_resetButton))
				{
					((UnityEvent)_resetButton.onClick).AddListener(new UnityAction(Clicked));
				}
			}
		}

		public UnityEvent OnClicked { get; } = new UnityEvent();


		public void Initialize()
		{
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Expected O, but got Unknown
			Label.text = "Tab";
			((UnityEventBase)Button.onClick).RemoveAllListeners();
			((UnityEvent)Button.onClick).AddListener(new UnityAction(Clicked));
		}

		private void Clicked()
		{
			OnClicked.Invoke();
		}
	}
	public class AtlyssToggle : BaseAtlyssLabelElement, IValueElement
	{
		private Toggle _toggle;

		public Toggle Toggle
		{
			get
			{
				return _toggle;
			}
			set
			{
				if (Object.op_Implicit((Object)(object)_toggle))
				{
					((UnityEvent<bool>)(object)_toggle.onValueChanged).RemoveListener((UnityAction<bool>)ValueChanged);
				}
				_toggle = value;
				if (Object.op_Implicit((Object)(object)_toggle))
				{
					((UnityEvent<bool>)(object)_toggle.onValueChanged).AddListener((UnityAction<bool>)ValueChanged);
				}
			}
		}

		public UnityEvent<bool> OnValueChanged { get; } = new UnityEvent<bool>();


		public bool AppliedValue { get; private set; }

		public void Initialize()
		{
			base.LabelText = "Toggle";
			((UnityEventBase)(object)Toggle.onValueChanged).RemoveAndDisableAllListeners();
			((UnityEvent<bool>)(object)Toggle.onValueChanged).AddListener((UnityAction<bool>)ValueChanged);
			Toggle.SetIsOnWithoutNotify(AppliedValue);
		}

		public void Apply()
		{
			AppliedValue = _toggle.isOn;
		}

		public void Revert()
		{
			_toggle.isOn = AppliedValue;
		}

		private void ValueChanged(bool newValue)
		{
			OnValueChanged.Invoke(newValue);
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}