Decompiled source of LethalCompany InputUtils v0.7.4

plugins/LethalCompanyInputUtils/LethalCompanyInputUtils.dll

Decompiled 2 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using LethalCompanyInputUtils.Api;
using LethalCompanyInputUtils.BindingPathEnums;
using LethalCompanyInputUtils.Components;
using LethalCompanyInputUtils.Components.Section;
using LethalCompanyInputUtils.Components.Switch;
using LethalCompanyInputUtils.Config;
using LethalCompanyInputUtils.Data;
using LethalCompanyInputUtils.Glyphs;
using LethalCompanyInputUtils.Localization;
using LethalCompanyInputUtils.Utils;
using LethalCompanyInputUtils.Utils.Anim;
using LethalCompanyInputUtils.Utils.Anim.TweenValues;
using LethalConfig;
using LethalConfig.ConfigItems;
using LethalConfig.ConfigItems.Options;
using LobbyCompatibility.Enums;
using LobbyCompatibility.Features;
using Microsoft.CodeAnalysis;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Layouts;
using UnityEngine.InputSystem.Utilities;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("LethalCompanyInputUtils")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+35425635346943c17ecc7a83c6b651ff27a4820f")]
[assembly: AssemblyProduct("LethalCompanyInputUtils")]
[assembly: AssemblyTitle("LethalCompanyInputUtils")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[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 LethalCompanyInputUtils
{
	public static class LcInputActionApi
	{
		private static readonly Dictionary<string, LcInputActions> InputActionsMap = new Dictionary<string, LcInputActions>();

		internal static bool PrefabLoaded;

		internal static RemapContainerController? ContainerInstance;

		internal static IReadOnlyCollection<LcInputActions> InputActions => InputActionsMap.Values;

		internal static void LoadIntoUI(KepRemapPanel panel)
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			AdjustSizeAndPos(panel);
			LayoutElement val = EnsureLayoutElement(panel);
			panel.LoadKeybindsUI();
			float horizontalOffset = panel.horizontalOffset;
			Rect rect = ((Component)((Transform)panel.keyRemapContainer).parent).GetComponent<RectTransform>().rect;
			float num = Mathf.Floor(((Rect)(ref rect)).width / horizontalOffset);
			int count = panel.keySlots.Count;
			int num2 = NumberOfActualKeys(panel.keySlots);
			int num3 = count - num2;
			panel.maxVertical = (float)num2 / num + (float)num3;
			if (ContainerInstance != null && ContainerInstance.legacyButton != null)
			{
				((TMP_Text)((Component)ContainerInstance.legacyButton).GetComponentInChildren<TextMeshProUGUI>()).SetText($"> Show Legacy Controls ({num2} present)", true);
			}
			if (count == 0)
			{
				return;
			}
			val.minHeight = (panel.maxVertical + 1f) * panel.verticalOffset;
			int num4 = 0;
			int num5 = 0;
			foreach (GameObject keySlot in panel.keySlots)
			{
				if ((float)num5 > num)
				{
					num4++;
					num5 = 0;
				}
				keySlot.GetComponent<RectTransform>().anchoredPosition = new Vector2((float)num5 * panel.horizontalOffset, (float)num4 * (0f - panel.verticalOffset));
				if (keySlot.GetComponentInChildren<SettingsOption>() == null)
				{
					num5 = 0;
					num4++;
				}
				else
				{
					num5++;
				}
			}
		}

		public static bool RemapContainerVisible()
		{
			if (ContainerInstance == null)
			{
				return false;
			}
			return ContainerInstance.LayerShown > 0;
		}

		private static int NumberOfActualKeys(List<GameObject> keySlots)
		{
			int num = 0;
			foreach (GameObject keySlot in keySlots)
			{
				if (keySlot.GetComponentInChildren<SettingsOption>() != null)
				{
					num++;
				}
			}
			return num;
		}

		internal static void CloseContainerLayer()
		{
			if (ContainerInstance != null)
			{
				ContainerInstance.HideHighestLayer();
			}
		}

		private static void AdjustSizeAndPos(KepRemapPanel panel)
		{
			GameObject gameObject = ((Component)((Transform)panel.keyRemapContainer).parent).gameObject;
			if (gameObject.GetComponent<ContentSizeFitter>() == null)
			{
				panel.keyRemapContainer.SetPivotY(1f);
				panel.keyRemapContainer.SetAnchorMinY(1f);
				panel.keyRemapContainer.SetAnchorMaxY(1f);
				panel.keyRemapContainer.SetAnchoredPosY(0f);
				panel.keyRemapContainer.SetLocalPosY(0f);
				ContentSizeFitter obj = gameObject.AddComponent<ContentSizeFitter>();
				obj.horizontalFit = (FitMode)0;
				obj.verticalFit = (FitMode)1;
			}
		}

		private static LayoutElement EnsureLayoutElement(KepRemapPanel panel)
		{
			GameObject gameObject = ((Component)((Transform)panel.keyRemapContainer).parent).gameObject;
			LayoutElement component = gameObject.GetComponent<LayoutElement>();
			if (component != null)
			{
				return component;
			}
			return gameObject.AddComponent<LayoutElement>();
		}

		internal static void CalculateVerticalMaxForGamepad(KepRemapPanel panel)
		{
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			int num = panel.remappableKeys.Count((RemappableKey key) => key.gamepadOnly);
			float horizontalOffset = panel.horizontalOffset;
			Rect rect = ((Component)((Transform)panel.keyRemapContainer).parent).GetComponent<RectTransform>().rect;
			float num2 = Mathf.Floor(((Rect)(ref rect)).width / horizontalOffset);
			panel.maxVertical = (float)num / num2;
			LayoutElement obj = EnsureLayoutElement(panel);
			obj.minHeight += (panel.maxVertical + 3f) * panel.verticalOffset;
		}

		internal static void ResetLoadedInputActions()
		{
			PrefabLoaded = false;
			foreach (LcInputActions inputAction in InputActions)
			{
				inputAction.Loaded = false;
			}
		}

		internal static void RegisterInputActions(LcInputActions lcInputActions, InputActionMapBuilder builder)
		{
			if (!InputActionsMap.TryAdd(lcInputActions.Id, lcInputActions))
			{
				Logging.Warn("The mod [" + lcInputActions.Plugin.GUID + "] instantiated an Actions class [" + lcInputActions.GetType().Name + "] more than once!\n\t These classes should be treated as singletons!, do not instantiate more than once!");
			}
			else
			{
				lcInputActions.CreateInputActions(in builder);
				InputActionSetupExtensions.AddActionMap(lcInputActions.GetAsset(), builder.Build());
				lcInputActions.GetAsset().Enable();
				lcInputActions.OnAssetLoaded();
				lcInputActions.Load();
				lcInputActions.BuildActionRefs();
			}
		}

		internal static void DisableForRebind()
		{
			foreach (LcInputActions inputAction in InputActions)
			{
				if (inputAction.Enabled)
				{
					inputAction.Disable();
				}
			}
		}

		internal static void ReEnableFromRebind()
		{
			foreach (LcInputActions inputAction in InputActions)
			{
				if (inputAction.WasEnabled)
				{
					inputAction.Enable();
				}
			}
		}

		internal static void SaveOverrides()
		{
			if (ContainerInstance != null)
			{
				ContainerInstance.SaveOverrides();
			}
		}

		internal static void DiscardOverrides()
		{
			if (ContainerInstance != null)
			{
				ContainerInstance.DiscardOverrides();
			}
		}
	}
	[BepInPlugin("com.rune580.LethalCompanyInputUtils", "Lethal Company Input Utils", "0.7.4")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class LethalCompanyInputUtilsPlugin : BaseUnityPlugin
	{
		public const string ModId = "com.rune580.LethalCompanyInputUtils";

		public const string ModName = "Lethal Company Input Utils";

		public const string ModVersion = "0.7.4";

		private Harmony? _harmony;

		private void Awake()
		{
			Logging.SetLogSource(((BaseUnityPlugin)this).Logger);
			_harmony = Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "com.rune580.LethalCompanyInputUtils");
			SceneManager.activeSceneChanged += OnSceneChanged;
			InputSystem.onDeviceChange += OnDeviceChanged;
			LoadAssetBundles();
			ControllerGlyph.LoadGlyphs();
			FsUtils.EnsureRequiredDirs();
			InputUtilsConfig.Init((BaseUnityPlugin)(object)this);
			LocaleManager.LoadLocaleData();
			RegisterExtendedMouseLayout();
			ModCompat.Init((BaseUnityPlugin)(object)this);
			Logging.Info("InputUtils 0.7.4 has finished loading!");
			LayoutExporter.TryExportLayouts();
		}

		private static void LoadAssetBundles()
		{
			Assets.AddBundle("ui-assets");
		}

		private static void OnSceneChanged(Scene current, Scene next)
		{
			LcInputActionApi.ResetLoadedInputActions();
			CameraUtils.ClearUiCameraReference();
			BindsListController.OffsetCompensation = ((((Scene)(ref next)).name != "MainMenu") ? 20 : 0);
		}

		private static void OnDeviceChanged(InputDevice device, InputDeviceChange state)
		{
			RebindButton.ReloadGlyphs();
		}

		private static void RegisterExtendedMouseLayout()
		{
			InputSystem.RegisterLayoutOverride("{\n   \"name\": \"InputUtilsExtendedMouse\",\n   \"extend\": \"Mouse\",\n   \"controls\": [\n       {\n           \"name\": \"scroll/up\",\n           \"layout\": \"Button\",\n           \"useStateFrom\": \"scroll/up\",\n           \"format\": \"BIT\",\n           \"synthetic\": true\n       },\n       {\n           \"name\": \"scroll/down\",\n           \"layout\": \"Button\",\n           \"useStateFrom\": \"scroll/down\",\n           \"format\": \"BIT\",\n           \"synthetic\": true\n       },\n       {\n           \"name\": \"scroll/left\",\n           \"layout\": \"Button\",\n           \"useStateFrom\": \"scroll/left\",\n           \"format\": \"BIT\",\n           \"synthetic\": true\n       },\n       {\n           \"name\": \"scroll/right\",\n           \"layout\": \"Button\",\n           \"useStateFrom\": \"scroll/right\",\n           \"format\": \"BIT\",\n           \"synthetic\": true\n       }\n   ]\n}", (string)null);
			Logging.Info("Registered InputUtilsExtendedMouse Layout Override!");
		}
	}
	internal static class ModCompat
	{
		public static void Init(BaseUnityPlugin plugin)
		{
			if (Chainloader.PluginInfos.ContainsKey("BMX.LobbyCompatibility"))
			{
				LoadLobbyCompatibilityCompat(plugin.Info.Metadata);
			}
		}

		private static void LoadLobbyCompatibilityCompat(BepInPlugin plugin)
		{
			PluginHelper.RegisterPlugin(plugin.GUID, plugin.Version, (CompatibilityLevel)0, (VersionStrictness)0);
		}
	}
}
namespace LethalCompanyInputUtils.BindingPathEnums
{
	public enum KeyboardControl
	{
		None = 0,
		Unbound = 0,
		AnyKey = 1,
		Escape = 2,
		Space = 3,
		Enter = 4,
		Tab = 5,
		Backquote = 6,
		Quote = 7,
		Semicolon = 8,
		Comma = 9,
		Period = 10,
		Slash = 11,
		Backslash = 12,
		LeftBracket = 13,
		RightBracket = 14,
		Minus = 15,
		Equals = 16,
		UpArrow = 17,
		DownArrow = 18,
		LeftArrow = 19,
		RightArrow = 20,
		A = 21,
		B = 22,
		C = 23,
		D = 24,
		E = 25,
		F = 26,
		G = 27,
		H = 28,
		I = 29,
		J = 30,
		K = 31,
		L = 32,
		M = 33,
		N = 34,
		O = 35,
		P = 36,
		Q = 37,
		R = 38,
		S = 39,
		T = 40,
		U = 41,
		V = 42,
		W = 43,
		X = 44,
		Y = 45,
		Z = 46,
		Num1 = 47,
		Num2 = 48,
		Num3 = 49,
		Num4 = 50,
		Num5 = 51,
		Num6 = 52,
		Num7 = 53,
		Num8 = 54,
		Num9 = 55,
		Num0 = 56,
		LeftShift = 57,
		RightShift = 58,
		Shift = 59,
		LeftAlt = 60,
		RightAlt = 61,
		Alt = 62,
		LeftCtrl = 63,
		RightCtrl = 64,
		Ctrl = 65,
		LeftMeta = 66,
		RightMeta = 67,
		ContextMenu = 68,
		Backspace = 69,
		PageDown = 70,
		PageUp = 71,
		Home = 72,
		End = 73,
		Insert = 74,
		Delete = 75,
		CapsLock = 76,
		NumLock = 77,
		PrintScreen = 78,
		ScrollLock = 79,
		Pause = 80,
		NumpadEnter = 81,
		NumpadDivide = 82,
		NumpadMultiply = 83,
		NumpadPlus = 84,
		NumpadMinus = 85,
		NumpadPeriod = 86,
		NumpadEquals = 87,
		Numpad1 = 88,
		Numpad2 = 89,
		Numpad3 = 90,
		Numpad4 = 91,
		Numpad5 = 92,
		Numpad6 = 93,
		Numpad7 = 94,
		Numpad8 = 95,
		Numpad9 = 96,
		Numpad0 = 97,
		F1 = 98,
		F2 = 99,
		F3 = 100,
		F4 = 101,
		F5 = 102,
		F6 = 103,
		F7 = 104,
		F8 = 105,
		F9 = 106,
		F10 = 107,
		F11 = 108,
		F12 = 109,
		OEM1 = 110,
		OEM2 = 111,
		OEM3 = 112,
		OEM4 = 113,
		OEM5 = 114,
		IMESelected = 115
	}
	public static class KeyboardControlExtensions
	{
		public static string ToPath(this KeyboardControl keyboardControl)
		{
			return keyboardControl switch
			{
				KeyboardControl.None => "", 
				KeyboardControl.AnyKey => "<Keyboard>/anyKey", 
				KeyboardControl.Escape => "<Keyboard>/escape", 
				KeyboardControl.Space => "<Keyboard>/space", 
				KeyboardControl.Enter => "<Keyboard>/enter", 
				KeyboardControl.Tab => "<Keyboard>/tab", 
				KeyboardControl.Backquote => "<Keyboard>/backquote", 
				KeyboardControl.Quote => "<Keyboard>/quote", 
				KeyboardControl.Semicolon => "<Keyboard>/semicolon", 
				KeyboardControl.Comma => "<Keyboard>/comma", 
				KeyboardControl.Period => "<Keyboard>/period", 
				KeyboardControl.Slash => "<Keyboard>/slash", 
				KeyboardControl.Backslash => "<Keyboard>/backslash", 
				KeyboardControl.LeftBracket => "<Keyboard>/leftBracket", 
				KeyboardControl.RightBracket => "<Keyboard>/rightBracket", 
				KeyboardControl.Minus => "<Keyboard>/minus", 
				KeyboardControl.Equals => "<Keyboard>/equals", 
				KeyboardControl.UpArrow => "<Keyboard>/upArrow", 
				KeyboardControl.DownArrow => "<Keyboard>/downArrow", 
				KeyboardControl.LeftArrow => "<Keyboard>/leftArrow", 
				KeyboardControl.RightArrow => "<Keyboard>/rightArrow", 
				KeyboardControl.A => "<Keyboard>/a", 
				KeyboardControl.B => "<Keyboard>/b", 
				KeyboardControl.C => "<Keyboard>/c", 
				KeyboardControl.D => "<Keyboard>/d", 
				KeyboardControl.E => "<Keyboard>/e", 
				KeyboardControl.F => "<Keyboard>/f", 
				KeyboardControl.G => "<Keyboard>/g", 
				KeyboardControl.H => "<Keyboard>/h", 
				KeyboardControl.I => "<Keyboard>/i", 
				KeyboardControl.J => "<Keyboard>/j", 
				KeyboardControl.K => "<Keyboard>/k", 
				KeyboardControl.L => "<Keyboard>/l", 
				KeyboardControl.M => "<Keyboard>/m", 
				KeyboardControl.N => "<Keyboard>/n", 
				KeyboardControl.O => "<Keyboard>/o", 
				KeyboardControl.P => "<Keyboard>/p", 
				KeyboardControl.Q => "<Keyboard>/q", 
				KeyboardControl.R => "<Keyboard>/r", 
				KeyboardControl.S => "<Keyboard>/s", 
				KeyboardControl.T => "<Keyboard>/t", 
				KeyboardControl.U => "<Keyboard>/u", 
				KeyboardControl.V => "<Keyboard>/v", 
				KeyboardControl.W => "<Keyboard>/w", 
				KeyboardControl.X => "<Keyboard>/x", 
				KeyboardControl.Y => "<Keyboard>/y", 
				KeyboardControl.Z => "<Keyboard>/z", 
				KeyboardControl.Num1 => "<Keyboard>/1", 
				KeyboardControl.Num2 => "<Keyboard>/2", 
				KeyboardControl.Num3 => "<Keyboard>/3", 
				KeyboardControl.Num4 => "<Keyboard>/4", 
				KeyboardControl.Num5 => "<Keyboard>/5", 
				KeyboardControl.Num6 => "<Keyboard>/6", 
				KeyboardControl.Num7 => "<Keyboard>/7", 
				KeyboardControl.Num8 => "<Keyboard>/8", 
				KeyboardControl.Num9 => "<Keyboard>/9", 
				KeyboardControl.Num0 => "<Keyboard>/0", 
				KeyboardControl.LeftShift => "<Keyboard>/leftShift", 
				KeyboardControl.RightShift => "<Keyboard>/rightShift", 
				KeyboardControl.Shift => "<Keyboard>/shift", 
				KeyboardControl.LeftAlt => "<Keyboard>/leftAlt", 
				KeyboardControl.RightAlt => "<Keyboard>/rightAlt", 
				KeyboardControl.Alt => "<Keyboard>/alt", 
				KeyboardControl.LeftCtrl => "<Keyboard>/leftCtrl", 
				KeyboardControl.RightCtrl => "<Keyboard>/rightCtrl", 
				KeyboardControl.Ctrl => "<Keyboard>/ctrl", 
				KeyboardControl.LeftMeta => "<Keyboard>/leftMeta", 
				KeyboardControl.RightMeta => "<Keyboard>/rightMeta", 
				KeyboardControl.ContextMenu => "<Keyboard>/contextMenu", 
				KeyboardControl.Backspace => "<Keyboard>/backspace", 
				KeyboardControl.PageDown => "<Keyboard>/pageDown", 
				KeyboardControl.PageUp => "<Keyboard>/pageUp", 
				KeyboardControl.Home => "<Keyboard>/home", 
				KeyboardControl.End => "<Keyboard>/end", 
				KeyboardControl.Insert => "<Keyboard>/insert", 
				KeyboardControl.Delete => "<Keyboard>/delete", 
				KeyboardControl.CapsLock => "<Keyboard>/capsLock", 
				KeyboardControl.NumLock => "<Keyboard>/numLock", 
				KeyboardControl.PrintScreen => "<Keyboard>/printScreen", 
				KeyboardControl.ScrollLock => "<Keyboard>/scrollLock", 
				KeyboardControl.Pause => "<Keyboard>/pause", 
				KeyboardControl.NumpadEnter => "<Keyboard>/numpadEnter", 
				KeyboardControl.NumpadDivide => "<Keyboard>/numpadDivide", 
				KeyboardControl.NumpadMultiply => "<Keyboard>/numpadMultiply", 
				KeyboardControl.NumpadPlus => "<Keyboard>/numpadPlus", 
				KeyboardControl.NumpadMinus => "<Keyboard>/numpadMinus", 
				KeyboardControl.NumpadPeriod => "<Keyboard>/numpadPeriod", 
				KeyboardControl.NumpadEquals => "<Keyboard>/numpadEquals", 
				KeyboardControl.Numpad1 => "<Keyboard>/numpad1", 
				KeyboardControl.Numpad2 => "<Keyboard>/numpad2", 
				KeyboardControl.Numpad3 => "<Keyboard>/numpad3", 
				KeyboardControl.Numpad4 => "<Keyboard>/numpad4", 
				KeyboardControl.Numpad5 => "<Keyboard>/numpad5", 
				KeyboardControl.Numpad6 => "<Keyboard>/numpad6", 
				KeyboardControl.Numpad7 => "<Keyboard>/numpad7", 
				KeyboardControl.Numpad8 => "<Keyboard>/numpad8", 
				KeyboardControl.Numpad9 => "<Keyboard>/numpad9", 
				KeyboardControl.Numpad0 => "<Keyboard>/numpad0", 
				KeyboardControl.F1 => "<Keyboard>/f1", 
				KeyboardControl.F2 => "<Keyboard>/f2", 
				KeyboardControl.F3 => "<Keyboard>/f3", 
				KeyboardControl.F4 => "<Keyboard>/f4", 
				KeyboardControl.F5 => "<Keyboard>/f5", 
				KeyboardControl.F6 => "<Keyboard>/f6", 
				KeyboardControl.F7 => "<Keyboard>/f7", 
				KeyboardControl.F8 => "<Keyboard>/f8", 
				KeyboardControl.F9 => "<Keyboard>/f9", 
				KeyboardControl.F10 => "<Keyboard>/f10", 
				KeyboardControl.F11 => "<Keyboard>/f11", 
				KeyboardControl.F12 => "<Keyboard>/f12", 
				KeyboardControl.OEM1 => "<Keyboard>/OEM1", 
				KeyboardControl.OEM2 => "<Keyboard>/OEM2", 
				KeyboardControl.OEM3 => "<Keyboard>/OEM3", 
				KeyboardControl.OEM4 => "<Keyboard>/OEM4", 
				KeyboardControl.OEM5 => "<Keyboard>/OEM5", 
				KeyboardControl.IMESelected => "<Keyboard>/IMESelected", 
				_ => throw new ArgumentOutOfRangeException("keyboardControl", keyboardControl, null), 
			};
		}
	}
	public enum MouseControl
	{
		None = 0,
		Unbound = 0,
		ScrollUp = 1,
		ScrollDown = 2,
		ScrollLeft = 3,
		ScrollRight = 4,
		Position = 5,
		Delta = 6,
		Scroll = 7,
		ScrollX = 8,
		ScrollY = 9,
		Press = 10,
		LeftButton = 11,
		RightButton = 12,
		MiddleButton = 13,
		ForwardButton = 14,
		BackButton = 15,
		Pressure = 16,
		Radius = 17,
		PointerId = 18,
		DisplayIndex = 19,
		ClickCount = 20
	}
	public static class MouseControlExtensions
	{
		public static string ToPath(this MouseControl mouseControl)
		{
			return mouseControl switch
			{
				MouseControl.None => "", 
				MouseControl.ScrollUp => "<Mouse>/scroll/up", 
				MouseControl.ScrollDown => "<Mouse>/scroll/down", 
				MouseControl.ScrollLeft => "<Mouse>/scroll/left", 
				MouseControl.ScrollRight => "<Mouse>/scroll/right", 
				MouseControl.Position => "<Mouse>/position", 
				MouseControl.Delta => "<Mouse>/delta", 
				MouseControl.Scroll => "<Mouse>/scroll", 
				MouseControl.ScrollX => "<Mouse>/scroll/x", 
				MouseControl.ScrollY => "<Mouse>/scroll/y", 
				MouseControl.Press => "<Mouse>/press", 
				MouseControl.LeftButton => "<Mouse>/leftButton", 
				MouseControl.RightButton => "<Mouse>/rightButton", 
				MouseControl.MiddleButton => "<Mouse>/middleButton", 
				MouseControl.ForwardButton => "<Mouse>/forwardButton", 
				MouseControl.BackButton => "<Mouse>/backButton", 
				MouseControl.Pressure => "<Mouse>/pressure", 
				MouseControl.Radius => "<Mouse>/radius", 
				MouseControl.PointerId => "<Mouse>/pointerId", 
				MouseControl.DisplayIndex => "<Mouse>/displayIndex", 
				MouseControl.ClickCount => "<Mouse>/clickCount", 
				_ => throw new ArgumentOutOfRangeException("mouseControl", mouseControl, null), 
			};
		}
	}
	public enum GamepadControl
	{
		None = 0,
		Unbound = 0,
		Dpad = 1,
		ButtonSouth = 2,
		ButtonWest = 3,
		ButtonNorth = 4,
		ButtonEast = 5,
		LeftStickPress = 6,
		RightStickPress = 7,
		LeftShoulder = 8,
		RightShoulder = 9,
		Start = 10,
		Select = 11,
		LeftStick = 12,
		RightStick = 13,
		LeftTrigger = 14,
		RightTrigger = 15
	}
	public static class GamepadControlExtensions
	{
		public static string ToPath(this GamepadControl gamepadControl)
		{
			return gamepadControl switch
			{
				GamepadControl.None => "", 
				GamepadControl.Dpad => "<Gamepad>/dpad", 
				GamepadControl.ButtonSouth => "<Gamepad>/buttonSouth", 
				GamepadControl.ButtonWest => "<Gamepad>/buttonWest", 
				GamepadControl.ButtonNorth => "<Gamepad>/buttonNorth", 
				GamepadControl.ButtonEast => "<Gamepad>/buttonEast", 
				GamepadControl.LeftStickPress => "<Gamepad>/leftStickPress", 
				GamepadControl.RightStickPress => "<Gamepad>/rightStickPress", 
				GamepadControl.LeftShoulder => "<Gamepad>/leftShoulder", 
				GamepadControl.RightShoulder => "<Gamepad>/rightShoulder", 
				GamepadControl.Start => "<Gamepad>/start", 
				GamepadControl.Select => "<Gamepad>/select", 
				GamepadControl.LeftStick => "<Gamepad>/leftStick", 
				GamepadControl.RightStick => "<Gamepad>/rightStick", 
				GamepadControl.LeftTrigger => "<Gamepad>/leftTrigger", 
				GamepadControl.RightTrigger => "<Gamepad>/rightTrigger", 
				_ => throw new ArgumentOutOfRangeException("gamepadControl", gamepadControl, null), 
			};
		}
	}
}
namespace LethalCompanyInputUtils.Utils
{
	internal static class AssemblyUtils
	{
		public static BepInPlugin? GetBepInPlugin(this Assembly assembly)
		{
			foreach (Type validType in assembly.GetValidTypes())
			{
				BepInPlugin customAttribute = ((MemberInfo)validType).GetCustomAttribute<BepInPlugin>();
				if (customAttribute != null)
				{
					return customAttribute;
				}
			}
			return null;
		}

		public static IEnumerable<Type> GetValidTypes(this Assembly assembly)
		{
			try
			{
				return assembly.GetTypes();
			}
			catch (ReflectionTypeLoadException ex)
			{
				return ex.Types.Where((Type type) => (object)type != null);
			}
		}
	}
	internal static class Assets
	{
		private static readonly List<AssetBundle> AssetBundles = new List<AssetBundle>();

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

		public static void AddBundle(string bundleName)
		{
			AssetBundle val = AssetBundle.LoadFromFile(Path.Combine(FsUtils.AssetBundlesDir, bundleName));
			int count = AssetBundles.Count;
			AssetBundles.Add(val);
			string[] allAssetNames = val.GetAllAssetNames();
			for (int i = 0; i < allAssetNames.Length; i++)
			{
				string text = allAssetNames[i].ToLowerInvariant();
				if (text.StartsWith("assets/"))
				{
					string text2 = text;
					int length = "assets/".Length;
					text = text2.Substring(length, text2.Length - length);
				}
				AssetIndices[text] = count;
			}
		}

		public static T? Load<T>(string assetName) where T : Object
		{
			try
			{
				assetName = assetName.ToLowerInvariant();
				if (assetName.StartsWith("assets/"))
				{
					string text = assetName;
					int length = "assets/".Length;
					assetName = text.Substring(length, text.Length - length);
				}
				int index = AssetIndices[assetName];
				return AssetBundles[index].LoadAsset<T>("assets/" + assetName);
			}
			catch (Exception arg)
			{
				Logging.Error($"Couldn't load asset [{assetName}] exception: {arg}");
				return default(T);
			}
		}
	}
	internal static class CameraUtils
	{
		private static Camera? _uiCamera;

		public static Camera GetBestUiCamera()
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			if (_uiCamera != null && Object.op_Implicit((Object)(object)_uiCamera))
			{
				return _uiCamera;
			}
			_uiCamera = null;
			Scene activeScene = SceneManager.GetActiveScene();
			if (((Scene)(ref activeScene)).name == "MainMenu")
			{
				GameObject val = ((IEnumerable<GameObject>)((Scene)(ref activeScene)).GetRootGameObjects()).FirstOrDefault((Func<GameObject, bool>)((GameObject go) => ((Object)go).name == "UICamera"));
				if (val == null)
				{
					Logging.Warn("Failed to find UICamera at MainMenu, falling back to Camera.current!");
					return Camera.current;
				}
				Camera component = val.GetComponent<Camera>();
				if (component == null)
				{
					Logging.Warn("Failed to find Camera component on UICamera, falling back to Camera.current!");
					return Camera.current;
				}
				_uiCamera = component;
			}
			else
			{
				GameObject val2 = ((IEnumerable<GameObject>)((Scene)(ref activeScene)).GetRootGameObjects()).FirstOrDefault((Func<GameObject, bool>)((GameObject go) => ((Object)go).name == "Systems"));
				if (val2 == null)
				{
					Logging.Warn("Failed to find UICamera in active scene, falling back to Camera.current!");
					return Camera.current;
				}
				Transform val3 = val2.transform.Find("UI/UICamera");
				if (val3 == null)
				{
					Logging.Warn("Failed to find UICamera at MainMenu, falling back to Camera.current!");
					return Camera.current;
				}
				Camera component2 = ((Component)val3).GetComponent<Camera>();
				if (component2 == null)
				{
					Logging.Warn("Failed to find Camera component on UICamera, falling back to Camera.current!");
					return Camera.current;
				}
				_uiCamera = component2;
			}
			return _uiCamera;
		}

		public static void ClearUiCameraReference()
		{
			_uiCamera = null;
		}
	}
	internal static class DebugUtils
	{
		public static string ToPrettyString<TKey, TValue>(this IDictionary<TKey, TValue> dictionary)
		{
			StringBuilder stringBuilder = new StringBuilder();
			stringBuilder.AppendLine("{");
			using (IEnumerator<KeyValuePair<TKey, TValue>> enumerator = dictionary.GetEnumerator())
			{
				string[] obj;
				object obj3;
				for (; enumerator.MoveNext(); obj[3] = (string)obj3, obj[4] = "\",", stringBuilder.AppendLine(string.Concat(obj)))
				{
					enumerator.Current.Deconstruct(out var key, out var value);
					TKey val = key;
					TValue val2 = value;
					obj = new string[5] { "\t\"", null, null, null, null };
					ref TKey reference = ref val;
					key = default(TKey);
					object obj2;
					if (key == null)
					{
						key = reference;
						reference = ref key;
						if (key == null)
						{
							obj2 = null;
							goto IL_007c;
						}
					}
					obj2 = reference.ToString();
					goto IL_007c;
					IL_007c:
					obj[1] = (string)obj2;
					obj[2] = "\": \"";
					ref TValue reference2 = ref val2;
					value = default(TValue);
					if (value == null)
					{
						value = reference2;
						reference2 = ref value;
						if (value == null)
						{
							obj3 = null;
							continue;
						}
					}
					obj3 = reference2.ToString();
				}
			}
			stringBuilder.Remove(stringBuilder.Length - 1, 1);
			stringBuilder.AppendLine("}");
			return stringBuilder.ToString();
		}

		public static void DrawGizmoUiRectWorld(this RectTransform rectTransform)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			float z = ((Transform)rectTransform).position.z;
			Rect val = rectTransform.UiBoundsWorld();
			Vector3 val2 = default(Vector3);
			((Vector3)(ref val2))..ctor(((Rect)(ref val)).min.x, ((Rect)(ref val)).min.y, z);
			Vector3 val3 = default(Vector3);
			((Vector3)(ref val3))..ctor(((Rect)(ref val)).min.x, ((Rect)(ref val)).max.y, z);
			Vector3 val4 = default(Vector3);
			((Vector3)(ref val4))..ctor(((Rect)(ref val)).max.x, ((Rect)(ref val)).max.y, z);
			Vector3 val5 = default(Vector3);
			((Vector3)(ref val5))..ctor(((Rect)(ref val)).max.x, ((Rect)(ref val)).min.y, z);
			Gizmos.DrawLine(val2, val3);
			Gizmos.DrawLine(val3, val4);
			Gizmos.DrawLine(val4, val5);
			Gizmos.DrawLine(val5, val2);
		}

		public static void DrawGizmoUiRect(this RectTransform rectTransform, Vector3 position)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: 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_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: 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)
			float z = position.z;
			Rect val = rectTransform.UiBounds(position);
			Vector3 val2 = default(Vector3);
			((Vector3)(ref val2))..ctor(((Rect)(ref val)).min.x, ((Rect)(ref val)).min.y, z);
			Vector3 val3 = default(Vector3);
			((Vector3)(ref val3))..ctor(((Rect)(ref val)).min.x, ((Rect)(ref val)).max.y, z);
			Vector3 val4 = default(Vector3);
			((Vector3)(ref val4))..ctor(((Rect)(ref val)).max.x, ((Rect)(ref val)).max.y, z);
			Vector3 val5 = default(Vector3);
			((Vector3)(ref val5))..ctor(((Rect)(ref val)).max.x, ((Rect)(ref val)).min.y, z);
			Gizmos.DrawLine(val2, val3);
			Gizmos.DrawLine(val3, val4);
			Gizmos.DrawLine(val4, val5);
			Gizmos.DrawLine(val5, val2);
		}

		public static void DrawGizmoRect(this Rect rect, Vector3 position)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: 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_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			float z = position.z;
			Vector3 val = default(Vector3);
			((Vector3)(ref val))..ctor(((Rect)(ref rect)).min.x + position.x, ((Rect)(ref rect)).min.y + position.y, z);
			Vector3 val2 = default(Vector3);
			((Vector3)(ref val2))..ctor(((Rect)(ref rect)).min.x + position.x, ((Rect)(ref rect)).max.y + position.y, z);
			Vector3 val3 = default(Vector3);
			((Vector3)(ref val3))..ctor(((Rect)(ref rect)).max.x + position.x, ((Rect)(ref rect)).max.y + position.y, z);
			Vector3 val4 = default(Vector3);
			((Vector3)(ref val4))..ctor(((Rect)(ref rect)).max.x + position.x, ((Rect)(ref rect)).min.y + position.y, z);
			Gizmos.DrawLine(val, val2);
			Gizmos.DrawLine(val2, val3);
			Gizmos.DrawLine(val3, val4);
			Gizmos.DrawLine(val4, val);
		}
	}
	internal static class DeconstructUtils
	{
		public static void Deconstruct(this Rect rect, out Vector2 min, out Vector2 max)
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			min = new Vector2(((Rect)(ref rect)).xMin, ((Rect)(ref rect)).yMin);
			max = new Vector2(((Rect)(ref rect)).xMax, ((Rect)(ref rect)).yMax);
		}

		public static void Deconstruct(this Vector3 vector, out float x, out float y, out float z)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			x = vector.x;
			y = vector.y;
			z = vector.z;
		}
	}
	public static class DeviceGroups
	{
		public const string KeyboardAndMouse = "KeyboardAndMouse";

		public const string Gamepad = "Gamepad";
	}
	internal static class FsUtils
	{
		private static string? _assetBundlesDir;

		private static string? _localeDir;

		public static string SaveDir { get; } = GetSaveDir();


		public static string PersistentDir { get; } = Path.Combine(SaveDir, "InputUtils");


		public static string PersistentConfigPath { get; } = Path.Combine(PersistentDir, "Settings.cfg");


		public static string Pre041ControlsDir { get; } = Path.Combine(Paths.BepInExRootPath, "controls");


		public static string ControlsDir { get; } = Path.Combine(Paths.ConfigPath, "controls");


		public static string PersistentControlsDir { get; } = Path.Combine(PersistentDir, "controls");


		public static string AssetBundlesDir
		{
			get
			{
				if (_assetBundlesDir == null)
				{
					_assetBundlesDir = GetAssetBundlesDir();
				}
				if (string.IsNullOrEmpty(_assetBundlesDir))
				{
					string text = Chainloader.PluginInfos.ToPrettyString();
					Logging.Warn("InputUtils is loading in an invalid state!\n\tOne of the following mods may be the culprit:\n" + text);
					return "";
				}
				return _assetBundlesDir;
			}
		}

		public static string LocaleDir
		{
			get
			{
				if (_localeDir == null)
				{
					_localeDir = GetLocaleDir();
				}
				if (string.IsNullOrEmpty(_localeDir))
				{
					string text = Chainloader.PluginInfos.ToPrettyString();
					Logging.Warn("InputUtils is loading in an invalid state!\n\tOne of the following mods may be the culprit:\n" + text);
					return "";
				}
				return _localeDir;
			}
		}

		private static string GetSaveDir()
		{
			string folderPath = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
			return Path.Combine(folderPath, "AppData", "LocalLow", "ZeekerssRBLX", "Lethal Company");
		}

		private static string? GetAssetBundlesDir()
		{
			if (!Chainloader.PluginInfos.TryGetValue("com.rune580.LethalCompanyInputUtils", out var value))
			{
				return null;
			}
			string text = Path.Combine((Directory.GetParent(value.Location) ?? throw new NotSupportedException(BadInstallError())).FullName, "AssetBundles");
			if (!Directory.Exists(text))
			{
				throw new NotSupportedException(BadInstallError());
			}
			return text;
			static string BadInstallError()
			{
				Logging.Error("InputUtils can't find it's required AssetBundles! This will cause many issues!\nThis either means your mod manager incorrectly installed InputUtilsor if you've manually installed InputUtils, you've done so incorrectly. If you manually installed don't bother reporting the issue, I only provide support to people who use mod managers.");
				return "InputUtils can't find it's required AssetBundles! This will cause many issues!\nThis either means your mod manager incorrectly installed InputUtilsor if you've manually installed InputUtils, you've done so incorrectly. If you manually installed don't bother reporting the issue, I only provide support to people who use mod managers.";
			}
		}

		private static string? GetLocaleDir()
		{
			if (!Chainloader.PluginInfos.TryGetValue("com.rune580.LethalCompanyInputUtils", out var value))
			{
				return null;
			}
			string text = Path.Combine((Directory.GetParent(value.Location) ?? throw new NotSupportedException(BadInstallError())).FullName, "Locale");
			if (!Directory.Exists(text))
			{
				throw new NotSupportedException(BadInstallError());
			}
			return text;
			static string BadInstallError()
			{
				Logging.Error("InputUtils can't find it's required AssetBundles! This will cause many issues!\nThis either means your mod manager incorrectly installed InputUtilsor if you've manually installed InputUtils, you've done so incorrectly. If you manually installed don't bother reporting the issue, I only provide support to people who use mod managers.");
				return "InputUtils can't find it's required AssetBundles! This will cause many issues!\nThis either means your mod manager incorrectly installed InputUtilsor if you've manually installed InputUtils, you've done so incorrectly. If you manually installed don't bother reporting the issue, I only provide support to people who use mod managers.";
			}
		}

		public static void EnsureRequiredDirs()
		{
			if (!Directory.Exists(ControlsDir))
			{
				Directory.CreateDirectory(ControlsDir);
			}
			if (!Directory.Exists(SaveDir))
			{
				Logging.Warn("LethalCompany save directory doesn't exist!\n Persistent settings will fail!");
			}
			else if (!Directory.Exists(PersistentControlsDir))
			{
				Directory.CreateDirectory(PersistentControlsDir);
			}
		}
	}
	internal static class InputSystemUtils
	{
		public static bool IsGamepadOnly(this InputAction action)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			return ((IEnumerable<InputBinding>)(object)action.bindings).All((InputBinding binding) => !binding.IsKbmBind());
		}

		public static bool IsKbmBind(this InputBinding binding)
		{
			return string.Equals(((InputBinding)(ref binding)).groups, "KeyboardAndMouse");
		}

		public static bool IsGamepadBind(this InputBinding binding)
		{
			return string.Equals(((InputBinding)(ref binding)).groups, "Gamepad");
		}

		public static RemappableKey? GetKbmKey(this InputActionReference actionRef)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Expected O, but got Unknown
			ReadOnlyArray<InputBinding> bindings = actionRef.action.bindings;
			for (int i = 0; i < bindings.Count; i++)
			{
				InputBinding binding = bindings[i];
				if (binding.IsKbmBind())
				{
					return new RemappableKey
					{
						ControlName = ((InputBinding)(ref binding)).name,
						currentInput = actionRef,
						rebindingIndex = i,
						gamepadOnly = false
					};
				}
			}
			return null;
		}

		public static RemappableKey? GetGamepadKey(this InputActionReference actionRef)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Expected O, but got Unknown
			ReadOnlyArray<InputBinding> bindings = actionRef.action.bindings;
			for (int i = 0; i < bindings.Count; i++)
			{
				InputBinding binding = bindings[i];
				if (binding.IsGamepadBind())
				{
					return new RemappableKey
					{
						ControlName = ((InputBinding)(ref binding)).name,
						currentInput = actionRef,
						rebindingIndex = i,
						gamepadOnly = true
					};
				}
			}
			return null;
		}
	}
	internal static class LayoutExporter
	{
		private static readonly InputControlLayout[] Layouts = (InputControlLayout[])(object)new InputControlLayout[3]
		{
			InputSystem.LoadLayout<Keyboard>(),
			InputSystem.LoadLayout<Mouse>(),
			InputSystem.LoadLayout<Gamepad>()
		};

		public static void TryExportLayouts()
		{
			string[] commandLineArgs = Environment.GetCommandLineArgs();
			string text = null;
			string[] array = commandLineArgs;
			foreach (string text2 in array)
			{
				if (text2.StartsWith("--inputUtilsExportLayoutsToDir="))
				{
					string[] array2 = text2.Split('=');
					if (array2.Length == 2)
					{
						text = array2[1];
					}
				}
			}
			if (text == null)
			{
				return;
			}
			try
			{
				ExportLayouts(Layouts, Path.Combine(text, "device_layouts.json"));
				Application.Quit();
			}
			catch (Exception data)
			{
				Logging.Error(data);
			}
		}

		public static void ExportLayouts(InputControlLayout[] layouts, string filePath)
		{
			StringBuilder stringBuilder = new StringBuilder();
			stringBuilder.AppendLine("{");
			stringBuilder.AppendLine("\t\"layouts\": [");
			for (int i = 0; i < layouts.Length; i++)
			{
				string[] array = layouts[i].ToJson().Split("\n");
				foreach (string text in array)
				{
					stringBuilder.AppendLine("\t\t" + text);
				}
				stringBuilder.Remove(stringBuilder.Length - 2, 2);
				stringBuilder.AppendLine(",");
			}
			stringBuilder.Remove(stringBuilder.Length - 3, 1);
			stringBuilder.AppendLine("\t]");
			stringBuilder.AppendLine("}");
			File.WriteAllText(filePath, stringBuilder.ToString());
		}
	}
	internal static class Logging
	{
		private static ManualLogSource? _logSource;

		internal static void SetLogSource(ManualLogSource logSource)
		{
			_logSource = logSource;
		}

		public static void Error(object data)
		{
			Error(data.ToString());
		}

		public static void Warn(object data)
		{
			Warn(data.ToString());
		}

		public static void Info(object data)
		{
			Info(data.ToString());
		}

		public static void Error(string msg)
		{
			if (_logSource == null)
			{
				Debug.LogError((object)("[Lethal Company Input Utils] [Error] " + msg));
			}
			else
			{
				_logSource.LogError((object)msg);
			}
		}

		public static void Warn(string msg)
		{
			if (_logSource == null)
			{
				Debug.LogWarning((object)("[Lethal Company Input Utils] [Warning] " + msg));
			}
			else
			{
				_logSource.LogWarning((object)msg);
			}
		}

		public static void Info(string msg)
		{
			if (_logSource == null)
			{
				Debug.Log((object)("[Lethal Company Input Utils] [Info] " + msg));
			}
			else
			{
				_logSource.LogInfo((object)msg);
			}
		}
	}
	internal static class RectTransformExtensions
	{
		public static void SetLocalPosX(this RectTransform rectTransform, float x)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			Vector3 localPosition = ((Transform)rectTransform).localPosition;
			((Transform)rectTransform).localPosition = new Vector3(x, localPosition.y, localPosition.z);
		}

		public static void SetLocalPosY(this RectTransform rectTransform, float y)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			Vector3 localPosition = ((Transform)rectTransform).localPosition;
			((Transform)rectTransform).localPosition = new Vector3(localPosition.x, y, localPosition.z);
		}

		public static void SetPivotY(this RectTransform rectTransform, float y)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			rectTransform.pivot = new Vector2(rectTransform.pivot.x, y);
		}

		public static void SetAnchorMinY(this RectTransform rectTransform, float y)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			rectTransform.anchorMin = new Vector2(rectTransform.anchorMin.x, y);
		}

		public static void SetAnchorMaxY(this RectTransform rectTransform, float y)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			rectTransform.anchorMax = new Vector2(rectTransform.anchorMax.x, y);
		}

		public static void SetAnchoredPosX(this RectTransform rectTransform, float x)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			rectTransform.anchoredPosition = new Vector2(x, rectTransform.anchoredPosition.y);
		}

		public static void SetAnchoredPosY(this RectTransform rectTransform, float y)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			rectTransform.anchoredPosition = new Vector2(rectTransform.anchoredPosition.x, y);
		}

		public static void SetSizeDeltaX(this RectTransform rectTransform, float x)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			rectTransform.sizeDelta = new Vector2(x, rectTransform.sizeDelta.y);
		}

		public static Rect UiBoundsWorld(this RectTransform rectTransform)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			Vector3 position = ((Transform)rectTransform).position;
			Rect rect = rectTransform.rect;
			Vector3 lossyScale = ((Transform)rectTransform).lossyScale;
			return new Rect(((Rect)(ref rect)).x * lossyScale.x + position.x, ((Rect)(ref rect)).y * lossyScale.y + position.y, ((Rect)(ref rect)).width * lossyScale.x, ((Rect)(ref rect)).height * lossyScale.y);
		}

		[Obsolete("Use GetRelativeRect")]
		public static Rect UiBounds(this RectTransform rectTransform, Vector3 position)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			Rect rect = rectTransform.rect;
			Vector3 lossyScale = ((Transform)rectTransform).lossyScale;
			return new Rect(((Rect)(ref rect)).x * lossyScale.x + position.x, ((Rect)(ref rect)).y * lossyScale.y + position.y, ((Rect)(ref rect)).width * lossyScale.x, ((Rect)(ref rect)).height * lossyScale.y);
		}

		public static Rect GetRelativeRect(this RectTransform rectTransform, RectTransform worldRectTransform)
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			Camera bestUiCamera = CameraUtils.GetBestUiCamera();
			Vector3[] array = (Vector3[])(object)new Vector3[4];
			worldRectTransform.GetWorldCorners(array);
			Vector2[] array2 = (Vector2[])(object)new Vector2[4];
			for (int i = 0; i < array.Length; i++)
			{
				array2[i] = RectTransformUtility.WorldToScreenPoint(bestUiCamera, array[i]);
			}
			Vector2[] array3 = (Vector2[])(object)new Vector2[4];
			for (int j = 0; j < array2.Length; j++)
			{
				RectTransformUtility.ScreenPointToLocalPointInRectangle(rectTransform, array2[j], bestUiCamera, ref array3[j]);
			}
			Vector2 val = array3[0];
			Vector2 val2 = array3[0];
			Vector2[] array4 = array3;
			foreach (Vector2 val3 in array4)
			{
				val = Vector2.Min(val, val3);
				val2 = Vector2.Max(val2, val3);
			}
			Vector2 val4 = val2 - val;
			return new Rect(val.x, val.y, val4.x, val4.y);
		}

		public static Vector2 WorldToLocalPoint(this RectTransform rectTransform, Vector3 worldPoint)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: 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)
			Camera bestUiCamera = CameraUtils.GetBestUiCamera();
			Vector2 val = RectTransformUtility.WorldToScreenPoint(bestUiCamera, worldPoint);
			Vector2 result = default(Vector2);
			RectTransformUtility.ScreenPointToLocalPointInRectangle(rectTransform, val, bestUiCamera, ref result);
			return result;
		}

		public static Vector2 WorldToLocalPoint(this RectTransform rectTransform, RectTransform other)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			return rectTransform.WorldToLocalPoint(((Transform)other).position);
		}

		public static float WorldMaxY(this RectTransform rectTransform)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			Rect val = rectTransform.UiBoundsWorld();
			return ((Rect)(ref val)).max.y;
		}

		public static float WorldMinY(this RectTransform rectTransform)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			Rect val = rectTransform.UiBoundsWorld();
			return ((Rect)(ref val)).min.y;
		}
	}
	internal static class RectUtils
	{
		public static Vector2 CenteredPos(this Rect rect)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			return ((Rect)(ref rect)).min + ((Rect)(ref rect)).size / 2f;
		}
	}
	internal static class RuntimeHelper
	{
		public static Vector3 LocalPositionRelativeTo(this Transform transform, Transform parent)
		{
			//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_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = Vector3.zero;
			Transform val2 = transform;
			do
			{
				val += transform.localPosition;
				val2 = val2.parent;
			}
			while ((Object)(object)val2 != (Object)(object)parent);
			return val;
		}

		public static void DisableKeys(this IEnumerable<RemappableKey> keys)
		{
			foreach (RemappableKey key in keys)
			{
				key.currentInput.action.Disable();
			}
		}

		public static void EnableKeys(this IEnumerable<RemappableKey> keys)
		{
			foreach (RemappableKey key in keys)
			{
				key.currentInput.action.Enable();
			}
		}
	}
	internal static class VectorUtils
	{
		public static Vector3 Mul(this Vector3 left, Vector3 right)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			return new Vector3(left.x * right.x, left.y * right.y, left.z * right.z);
		}
	}
}
namespace LethalCompanyInputUtils.Utils.Anim
{
	public interface ITweenValue
	{
		bool IgnoreTimeScale { get; }

		float Duration { get; }

		void TweenValue(float percentage);

		bool ValidTarget();
	}
	public class TweenRunner<T> where T : struct, ITweenValue
	{
		protected MonoBehaviour? CoroutineContainer;

		protected IEnumerator? Tween;

		private static IEnumerator Start(T tweenValue)
		{
			if (tweenValue.ValidTarget())
			{
				float elapsedTime = 0f;
				while (elapsedTime < tweenValue.Duration)
				{
					elapsedTime += (tweenValue.IgnoreTimeScale ? Time.unscaledDeltaTime : Time.deltaTime);
					float percentage = Mathf.Clamp01(elapsedTime / tweenValue.Duration);
					tweenValue.TweenValue(percentage);
					yield return null;
				}
				tweenValue.TweenValue(1f);
			}
		}

		public void Init(MonoBehaviour coroutineContainer)
		{
			CoroutineContainer = coroutineContainer;
		}

		public void StartTween(T tweenValue)
		{
			if (CoroutineContainer != null)
			{
				if (Tween != null)
				{
					CoroutineContainer.StopCoroutine(Tween);
					Tween = null;
				}
				if (!((Component)CoroutineContainer).gameObject.activeInHierarchy)
				{
					tweenValue.TweenValue(1f);
					return;
				}
				Tween = Start(tweenValue);
				CoroutineContainer.StartCoroutine(Tween);
			}
		}

		public void StopTween()
		{
			if (Tween != null && CoroutineContainer != null)
			{
				CoroutineContainer.StopCoroutine(Tween);
				Tween = null;
			}
		}
	}
}
namespace LethalCompanyInputUtils.Utils.Anim.TweenValues
{
	public struct Vector2Tween : ITweenValue
	{
		private class Vector2TweenCallback : UnityEvent<Vector2>
		{
		}

		private Vector2TweenCallback? _target;

		public float Duration { get; set; }

		public Vector2 StartValue { get; set; }

		public Vector2 TargetValue { get; set; }

		public bool IgnoreTimeScale { get; set; }

		public void TweenValue(float percentage)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: 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)
			if (ValidTarget())
			{
				Vector2 val = Vector2.Lerp(StartValue, TargetValue, percentage);
				((UnityEvent<Vector2>)_target).Invoke(val);
			}
		}

		public void AddOnChangedCallback(UnityAction<Vector2> callback)
		{
			if (_target == null)
			{
				_target = new Vector2TweenCallback();
			}
			((UnityEvent<Vector2>)_target).AddListener(callback);
		}

		public bool ValidTarget()
		{
			return _target != null;
		}
	}
	public struct Vector3Tween : ITweenValue
	{
		private class Vector3TweenCallback : UnityEvent<Vector3>
		{
		}

		private Vector3TweenCallback? _target;

		public float Duration { get; set; }

		public Vector3 StartValue { get; set; }

		public Vector3 TargetValue { get; set; }

		public bool IgnoreTimeScale { get; set; }

		public void TweenValue(float percentage)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: 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)
			if (ValidTarget())
			{
				Vector3 val = Vector3.Lerp(StartValue, TargetValue, percentage);
				((UnityEvent<Vector3>)_target).Invoke(val);
			}
		}

		public void AddOnChangedCallback(UnityAction<Vector3> callback)
		{
			if (_target == null)
			{
				_target = new Vector3TweenCallback();
			}
			((UnityEvent<Vector3>)_target).AddListener(callback);
		}

		public bool ValidTarget()
		{
			return _target != null;
		}
	}
	public struct Vector4Tween : ITweenValue
	{
		private class Vector4TweenCallback : UnityEvent<Vector4>
		{
		}

		private Vector4TweenCallback? _target;

		public float Duration { get; set; }

		public Vector4 StartValue { get; set; }

		public Vector4 TargetValue { get; set; }

		public bool IgnoreTimeScale { get; set; }

		public void TweenValue(float percentage)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: 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)
			if (ValidTarget())
			{
				Vector4 val = Vector4.Lerp(StartValue, TargetValue, percentage);
				((UnityEvent<Vector4>)_target).Invoke(val);
			}
		}

		public void AddOnChangedCallback(UnityAction<Vector4> callback)
		{
			if (_target == null)
			{
				_target = new Vector4TweenCallback();
			}
			((UnityEvent<Vector4>)_target).AddListener(callback);
		}

		public bool ValidTarget()
		{
			return _target != null;
		}
	}
}
namespace LethalCompanyInputUtils.Patches
{
	public static class InGamePlayerSettingsPatches
	{
		[HarmonyPatch(typeof(IngamePlayerSettings), "SaveChangedSettings")]
		public static class SaveChangedSettingsPatch
		{
			public static void Prefix()
			{
				LcInputActionApi.SaveOverrides();
			}
		}

		[HarmonyPatch(typeof(IngamePlayerSettings), "DiscardChangedSettings")]
		public static class DiscardChangedSettingsPatch
		{
			public static void Prefix()
			{
				LcInputActionApi.DiscardOverrides();
			}
		}
	}
	public static class InputControlPathPatches
	{
		[HarmonyPatch]
		public static class ToHumanReadableStringPatch
		{
			public static IEnumerable<MethodBase> TargetMethods()
			{
				return from method in AccessTools.GetDeclaredMethods(typeof(InputControlPath))
					where method.Name == "ToHumanReadableString" && method.ReturnType == typeof(string)
					select method;
			}

			public static void Postfix(ref string __result)
			{
				string text = __result;
				if ((text == "<InputUtils-Gamepad-Not-Bound>" || text == "<InputUtils-Kbm-Not-Bound>") ? true : false)
				{
					__result = "";
				}
			}
		}
	}
	public static class KeyRemapPanelPatches
	{
		[HarmonyPatch(typeof(KepRemapPanel), "OnEnable")]
		public static class LoadKeybindsUIPatch
		{
			[CompilerGenerated]
			private static class <>O
			{
				public static UnityAction <0>__CloseContainerLayer;
			}

			public static void Prefix(KepRemapPanel __instance)
			{
				//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d5: Expected O, but got Unknown
				//IL_011f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0129: Expected O, but got Unknown
				//IL_0130: Unknown result type (might be due to invalid IL or missing references)
				//IL_0147: Unknown result type (might be due to invalid IL or missing references)
				//IL_0182: Unknown result type (might be due to invalid IL or missing references)
				//IL_018c: Unknown result type (might be due to invalid IL or missing references)
				//IL_019f: Unknown result type (might be due to invalid IL or missing references)
				//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
				//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
				//IL_0202: Expected O, but got Unknown
				//IL_023b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0245: Expected O, but got Unknown
				//IL_00ea: 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_00f5: Expected O, but got Unknown
				LcInputActionApi.DisableForRebind();
				if (LcInputActionApi.PrefabLoaded && LcInputActionApi.ContainerInstance != null)
				{
					LcInputActionApi.ContainerInstance.baseGameKeys.DisableKeys();
					return;
				}
				GameObject val = Object.Instantiate<GameObject>(Assets.Load<GameObject>("Prefabs/InputUtilsRemapContainer.prefab"), ((Component)__instance).transform);
				GameObject val2 = Object.Instantiate<GameObject>(Assets.Load<GameObject>("Prefabs/Legacy Holder.prefab"), ((Component)__instance).transform);
				if (val == null || val2 == null)
				{
					return;
				}
				Transform val3 = ((Component)__instance).transform.Find("Scroll View");
				if (val3 != null)
				{
					val3.SetParent(val2.transform);
					List<RemappableKey> remappableKeys = __instance.remappableKeys;
					__instance.remappableKeys = new List<RemappableKey>();
					val2.SetActive(false);
					GameObject gameObject = ((Component)((Component)__instance).transform.Find("Back")).gameObject;
					Button component = gameObject.GetComponent<Button>();
					GameObject obj = Object.Instantiate<GameObject>(gameObject, val2.transform, true);
					Object.DestroyImmediate((Object)(object)obj.GetComponentInChildren<SettingsOption>());
					Button component2 = obj.GetComponent<Button>();
					component2.onClick = new ButtonClickedEvent();
					ButtonClickedEvent onClick = component2.onClick;
					object obj2 = <>O.<0>__CloseContainerLayer;
					if (obj2 == null)
					{
						UnityAction val4 = LcInputActionApi.CloseContainerLayer;
						<>O.<0>__CloseContainerLayer = val4;
						obj2 = (object)val4;
					}
					((UnityEvent)onClick).AddListener((UnityAction)obj2);
					GameObject obj3 = Object.Instantiate<GameObject>(gameObject, gameObject.transform.parent);
					Object.DestroyImmediate((Object)(object)obj3.GetComponentInChildren<SettingsOption>());
					Button component3 = obj3.GetComponent<Button>();
					component3.onClick = new ButtonClickedEvent();
					RectTransform component4 = obj3.GetComponent<RectTransform>();
					component4.SetAnchoredPosY(component4.anchoredPosition.y + 25f);
					component4.SetSizeDeltaX(component4.sizeDelta.x + 180f);
					RectTransform component5 = ((Component)((Transform)component4).Find("SelectionHighlight")).GetComponent<RectTransform>();
					component5.SetSizeDeltaX(410f);
					component5.offsetMax = new Vector2(410f, component5.offsetMax.y);
					component5.offsetMin = new Vector2(0f, component5.offsetMin.y);
					RemapContainerController component6 = val.GetComponent<RemapContainerController>();
					component6.baseGameKeys = remappableKeys;
					component6.backButton = component;
					component6.legacyButton = component3;
					component6.legacyHolder = val2;
					component6.baseGameKeys.DisableKeys();
					((UnityEvent)component3.onClick).AddListener(new UnityAction(component6.ShowLegacyUi));
					component6.LoadUi();
					Button component7 = ((Component)((Component)__instance).transform.Find("SetDefault")).gameObject.GetComponent<Button>();
					((UnityEventBase)component7.onClick).RemoveAllListeners();
					((UnityEvent)component7.onClick).AddListener(new UnityAction(component6.OnSetToDefault));
					val2.transform.SetAsLastSibling();
					LcInputActionApi.PrefabLoaded = true;
				}
			}

			public static void Postfix(KepRemapPanel __instance)
			{
				LcInputActionApi.LoadIntoUI(__instance);
			}
		}

		[HarmonyPatch(typeof(KepRemapPanel), "OnDisable")]
		public static class UnloadKeybindsUIPatch
		{
			public static void Prefix()
			{
				if (LcInputActionApi.ContainerInstance != null)
				{
					LcInputActionApi.ContainerInstance.baseGameKeys.EnableKeys();
				}
			}
		}
	}
	public static class MenuManagerPatches
	{
		[HarmonyPatch(typeof(MenuManager), "Awake")]
		public static class AwakePatch
		{
			public static void Prefix(MenuManager __instance)
			{
				if (__instance.menuAnimator != null)
				{
					Transform transform = ((Component)__instance.menuAnimator).gameObject.transform;
					Object.Instantiate<GameObject>(Assets.Load<GameObject>("Prefabs/PopOver Layer.prefab"), transform);
				}
			}
		}
	}
	public static class QuickMenuManagerPatches
	{
		[HarmonyPatch(typeof(QuickMenuManager), "Start")]
		public static class StartPatch
		{
			public static void Prefix(QuickMenuManager __instance)
			{
				Object.Instantiate<GameObject>(Assets.Load<GameObject>("Prefabs/PopOver Layer.prefab"), __instance.menuContainer.transform);
			}
		}

		[HarmonyPatch(typeof(QuickMenuManager), "CloseQuickMenu")]
		public static class CloseQuickMenuPatch
		{
			public static bool Prefix(QuickMenuManager __instance)
			{
				if (LcInputActionApi.RemapContainerVisible() && __instance.isMenuOpen)
				{
					LcInputActionApi.CloseContainerLayer();
					return false;
				}
				return true;
			}
		}
	}
	public static class SettingsOptionPatches
	{
		[HarmonyPatch(typeof(SettingsOption), "SetBindingToCurrentSetting")]
		public static class SetBindingToCurrentSettingPatch
		{
			public static bool Prefix(SettingsOption __instance)
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_0007: Invalid comparison between Unknown and I4
				//IL_0016: Unknown result type (might be due to invalid IL or missing references)
				//IL_001b: Unknown result type (might be due to invalid IL or missing references)
				//IL_001e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0023: Unknown result type (might be due to invalid IL or missing references)
				//IL_0028: Unknown result type (might be due to invalid IL or missing references)
				//IL_002d: Unknown result type (might be due to invalid IL or missing references)
				if ((int)__instance.optionType != 6)
				{
					return true;
				}
				Enumerator<InputBinding> enumerator = __instance.rebindableAction.action.bindings.GetEnumerator();
				try
				{
					while (enumerator.MoveNext())
					{
						InputBinding current = enumerator.Current;
						if (__instance.gamepadOnlyRebinding)
						{
							if (!string.Equals(((InputBinding)(ref current)).effectivePath, "<InputUtils-Gamepad-Not-Bound>"))
							{
								continue;
							}
						}
						else if (!string.Equals(((InputBinding)(ref current)).effectivePath, "<InputUtils-Kbm-Not-Bound>"))
						{
							continue;
						}
						((TMP_Text)__instance.currentlyUsedKeyText).SetText("", true);
						return false;
					}
				}
				finally
				{
					((IDisposable)enumerator).Dispose();
				}
				return true;
			}
		}
	}
}
namespace LethalCompanyInputUtils.Localization
{
	public static class LangTokens
	{
		public const string ResetToDefaultPopOver = "RebindButton.ResetToDefault.PopOver";

		public const string RemoveBindPopOver = "RebindButton.RemoveBind.PopOver";

		public const string UnsupportedDeviceBindPopOver = "RebindButton.NotSupportedDeviceBind.PopOver";

		public const string BindingOverrideContextSwitchInfoPopOver = "BindingOverrideContextSwitch.Info.PopOver";

		public const string BindingOverridePriorityDropdownInfoPopOver = "BindingOverridePriorityDropdown.Info.PopOver";
	}
	[Serializable]
	internal class Locale
	{
		public string? fallback;

		public Dictionary<string, string> entries = new Dictionary<string, string>();

		public static Locale LoadFrom(string jsonPath)
		{
			return JsonConvert.DeserializeObject<Locale>(File.ReadAllText(jsonPath)) ?? throw new NullReferenceException();
		}
	}
	internal static class LocaleManager
	{
		private static readonly Dictionary<string, string> LocaleEntries = new Dictionary<string, string>();

		internal static void LoadLocaleData()
		{
			Stack<Locale> stack = new Stack<Locale>();
			string text = InputUtilsConfig.localeKey.Value;
			string text2 = Path.Combine(FsUtils.LocaleDir, text + ".json");
			if (!File.Exists(text2))
			{
				Logging.Warn("Could not find Locale " + text + " at `" + text2 + "`!\nFalling back to `en_US`");
				text = "en_US";
				text2 = Path.Combine(FsUtils.LocaleDir, text + ".json");
			}
			while (File.Exists(text2))
			{
				Locale locale = Locale.LoadFrom(text2);
				stack.Push(locale);
				text = ((!(text != "en_US") || locale.fallback != null) ? locale.fallback : "en_US");
				text2 = Path.Combine(FsUtils.LocaleDir, text + ".json");
				if (text == null)
				{
					break;
				}
			}
			Locale result;
			while (stack.TryPop(out result))
			{
				foreach (var (key, value) in result.entries)
				{
					LocaleEntries[key] = value;
				}
			}
		}

		internal static string[] GetAllLocales()
		{
			return Directory.GetFiles(FsUtils.LocaleDir, "*.json").Select(Path.GetFileNameWithoutExtension).ToArray();
		}

		public static string GetString(string token)
		{
			return LocaleEntries[token];
		}
	}
}
namespace LethalCompanyInputUtils.Glyphs
{
	[CreateAssetMenu]
	public class ControllerGlyph : ScriptableObject
	{
		public List<string> validGamepadTypes = new List<string>();

		public List<GlyphDef> glyphSet = new List<GlyphDef>();

		private readonly Dictionary<string, Sprite?> _glyphLut = new Dictionary<string, Sprite>();

		private static readonly List<ControllerGlyph> Instances = new List<ControllerGlyph>();

		private static bool _loaded;

		public static ControllerGlyph? MouseGlyphs { get; private set; }

		public bool IsCurrent
		{
			get
			{
				Gamepad current = Gamepad.current;
				if (current == null)
				{
					return false;
				}
				return validGamepadTypes.Any((string gamepadTypeName) => string.Equals(gamepadTypeName, ((object)current).GetType().Name));
			}
		}

		public Sprite this[string controlPath]
		{
			get
			{
				if (_glyphLut.Count == 0)
				{
					UpdateLut();
				}
				return _glyphLut.GetValueOrDefault(controlPath, null);
			}
		}

		public static ControllerGlyph? GetBestMatching()
		{
			if (Instances.Count == 0)
			{
				return null;
			}
			foreach (ControllerGlyph instance in Instances)
			{
				if (instance.IsCurrent)
				{
					return instance;
				}
			}
			return Instances[0];
		}

		internal static void LoadGlyphs()
		{
			if (!_loaded)
			{
				Assets.Load<ControllerGlyph>("controller glyphs/xbox series x glyphs.asset");
				Assets.Load<ControllerGlyph>("controller glyphs/dualsense glyphs.asset");
				MouseGlyphs = Assets.Load<ControllerGlyph>("controller glyphs/mouse glyphs.asset");
				_loaded = true;
			}
		}

		private void Awake()
		{
			if (!Instances.Contains(this))
			{
				Instances.Add(this);
			}
		}

		private void UpdateLut()
		{
			foreach (GlyphDef item in glyphSet)
			{
				_glyphLut[item.controlPath] = item.glyphSprite;
			}
		}

		private void OnDestroy()
		{
			if (Instances.Contains(this))
			{
				Instances.Remove(this);
			}
		}
	}
	[CreateAssetMenu]
	public class GlyphDef : ScriptableObject
	{
		public string controlPath = "";

		public Sprite? glyphSprite;
	}
}
namespace LethalCompanyInputUtils.Data
{
	[Serializable]
	public struct BindingOverride
	{
		public string? action;

		public string? origPath;

		public string? path;

		public string? groups;
	}
	[Serializable]
	public class BindingOverrides
	{
		public List<BindingOverride> overrides;

		public BindingOverrides()
		{
			overrides = new List<BindingOverride>();
		}

		public BindingOverrides(IEnumerable<InputBinding> bindings)
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			overrides = new List<BindingOverride>();
			foreach (InputBinding binding in bindings)
			{
				InputBinding current = binding;
				if (((InputBinding)(ref current)).hasOverrides)
				{
					BindingOverride item = new BindingOverride
					{
						action = ((InputBinding)(ref current)).action,
						origPath = ((InputBinding)(ref current)).path,
						path = ((InputBinding)(ref current)).overridePath,
						groups = ((InputBinding)(ref current)).groups
					};
					overrides.Add(item);
				}
			}
		}

		public void LoadInto(InputActionAsset asset)
		{
			foreach (BindingOverride @override in overrides)
			{
				InputAction obj = asset.FindAction(@override.action, false);
				if (obj != null)
				{
					InputActionRebindingExtensions.ApplyBindingOverride(obj, @override.path, @override.groups, (string)null);
				}
			}
		}

		public void LoadInto(IReadOnlyCollection<InputActionReference> actionRefs)
		{
			foreach (BindingOverride @override in overrides)
			{
				foreach (InputActionReference actionRef in actionRefs)
				{
					if (!(actionRef.action.name != @override.action))
					{
						InputActionRebindingExtensions.ApplyBindingOverride(actionRef.action, @override.path, @override.groups, (string)null);
						break;
					}
				}
			}
		}

		public string AsJson()
		{
			return JsonConvert.SerializeObject((object)this);
		}

		public static BindingOverrides FromJson(string json)
		{
			BindingOverrides bindingOverrides = new BindingOverrides();
			JToken value = JsonConvert.DeserializeObject<JObject>(json).GetValue("overrides");
			bindingOverrides.overrides = value.ToObject<List<BindingOverride>>();
			return bindingOverrides;
		}
	}
}
namespace LethalCompanyInputUtils.Config
{
	public enum BindingOverridePriority
	{
		GlobalThenLocal,
		LocalThenGlobal,
		GlobalOnly,
		LocalOnly
	}
	public enum BindingOverrideType
	{
		Global,
		Local
	}
	public static class BindingOverrideTypeExtensions
	{
		public static string GetJsonPath(this BindingOverrideType overrideType, string name)
		{
			return Path.Combine(overrideType switch
			{
				BindingOverrideType.Global => FsUtils.PersistentControlsDir, 
				BindingOverrideType.Local => FsUtils.ControlsDir, 
				_ => throw new ArgumentOutOfRangeException("overrideType", overrideType, null), 
			}, name + ".json");
		}
	}
	public static class InputUtilsConfig
	{
		public static ConfigEntry<BindingOverridePriority> bindingOverridePriority;

		public static ConfigEntry<string> localeKey;

		internal static void Init(BaseUnityPlugin plugin)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			bindingOverridePriority = new ConfigFile(FsUtils.PersistentConfigPath, true, plugin.Info.Metadata).Bind<BindingOverridePriority>("General", "Binding Overrides Priority", BindingOverridePriority.GlobalThenLocal, "Determines the priority when loading controls.\n\n\tGlobalThenLocal: Global defined controls take priority over Local/Profile/ModPack defined controls\n\tLocalThenGlobal: Local/Profile/ModPack defined controls take priority over Global defined controls\n\tGlobalOnly: Only loads Global defined controls\n\tLocalOnly: Only loads Local/Profile/ModPack defined controls\n");
			localeKey = plugin.Config.Bind<string>("General", "Locale", "en_US", "Valid Locales can be found in the 'Locale' folder where InputUtils is installed at.\nCan reload live in-game when using LethalConfig.");
			localeKey.SettingChanged += delegate
			{
				LocaleManager.LoadLocaleData();
			};
			if (Chainloader.PluginInfos.ContainsKey("ainavt.lc.lethalconfig"))
			{
				LethalConfigSetup();
			}
		}

		private static void LethalConfigSetup()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but got Unknown
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected O, but got Unknown
			TextDropDownOptions val = new TextDropDownOptions(LocaleManager.GetAllLocales())
			{
				RequiresRestart = false
			};
			LethalConfigManager.AddConfigItem((BaseConfigItem)new TextDropDownConfigItem(localeKey, val));
		}
	}
}
namespace LethalCompanyInputUtils.Components
{
	[RequireComponent(typeof(RectTransform))]
	public class BindsListController : MonoBehaviour
	{
		public GameObject? sectionHeaderPrefab;

		public GameObject? sectionAnchorPrefab;

		public GameObject? rebindItemPrefab;

		public GameObject? spacerPrefab;

		public ScrollRect? scrollRect;

		public RectTransform? headerContainer;

		public UnityEvent<int> OnSectionChanged = new UnityEvent<int>();

		public static float OffsetCompensation;

		private RectTransform? _rectTransform;

		private RectTransform? _scrollRectTransform;

		private RectTransform? _content;

		private VerticalLayoutGroup? _verticalLayoutGroup;

		private int _currentSection;

		private float _sectionHeight;

		private float _spacing;

		private readonly List<SectionHeaderAnchor> _anchors = new List<SectionHeaderAnchor>();

		private void Awake()
		{
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			if (_rectTransform == null)
			{
				_rectTransform = ((Component)this).GetComponent<RectTransform>();
			}
			if (scrollRect == null)
			{
				scrollRect = ((Component)this).GetComponentInChildren<ScrollRect>();
			}
			if (_verticalLayoutGroup == null)
			{
				_verticalLayoutGroup = ((Component)scrollRect.content).GetComponent<VerticalLayoutGroup>();
			}
			_spacing = ((HorizontalOrVerticalLayoutGroup)_verticalLayoutGroup).spacing;
			if (sectionAnchorPrefab != null && rebindItemPrefab != null && spacerPrefab != null)
			{
				_sectionHeight = sectionAnchorPrefab.GetComponent<RectTransform>().sizeDelta.y;
				_scrollRectTransform = ((Component)scrollRect).GetComponent<RectTransform>();
				_content = scrollRect.content;
				if (headerContainer != null)
				{
					headerContainer.drivenByObject = (Object)(object)this;
					headerContainer.drivenProperties = (DrivenTransformProperties)3840;
					headerContainer.anchorMin = new Vector2(0f, 1f);
					headerContainer.anchorMax = Vector2.one;
					((UnityEvent<Vector2>)(object)scrollRect.onValueChanged).AddListener((UnityAction<Vector2>)OnScroll);
					OnScroll(Vector2.zero);
				}
			}
		}

		private void Start()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			OnScroll(Vector2.zero);
		}

		private void OnEnable()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			OnScroll(Vector2.zero);
		}

		public void JumpTo(int sectionIndex)
		{
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			if (_content == null || scrollRect == null || _scrollRectTransform == null)
			{
				return;
			}
			int count = _anchors.Count;
			if (sectionIndex < count && sectionIndex >= 0)
			{
				Canvas.ForceUpdateCanvases();
				scrollRect.StopMovement();
				if (sectionIndex == 0)
				{
					scrollRect.verticalNormalizedPosition = 1f;
				}
				else
				{
					SectionHeaderAnchor sectionHeaderAnchor = _anchors[sectionIndex];
					float y = Vector2.op_Implicit(((Transform)_scrollRectTransform).InverseTransformPoint(((Transform)_content).position) - ((Transform)_scrollRectTransform).InverseTransformPoint(((Transform)sectionHeaderAnchor.RectTransform).position)).y + _sectionHeight / 2f - _spacing;
					_content.SetAnchoredPosY(y);
				}
				if (_currentSection != sectionIndex)
				{
					OnSectionChanged.Invoke(sectionIndex);
				}
				_currentSection = sectionIndex;
			}
		}

		public void AddSection(string sectionName)
		{
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: 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_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			if (((Behaviour)this).isActiveAndEnabled && sectionHeaderPrefab != null && sectionAnchorPrefab != null && scrollRect != null)
			{
				SectionHeaderAnchor component = Object.Instantiate<GameObject>(sectionAnchorPrefab, (Transform)(object)_content).GetComponent<SectionHeaderAnchor>();
				SectionHeader component2 = Object.Instantiate<GameObject>(sectionHeaderPrefab, (Transform)(object)headerContainer).GetComponent<SectionHeader>();
				RectTransform rectTransform = component2.RectTransform;
				rectTransform.drivenByObject = (Object)(object)this;
				rectTransform.drivenProperties = (DrivenTransformProperties)1286;
				rectTransform.anchorMin = new Vector2(0f, rectTransform.anchorMin.y);
				rectTransform.anchorMax = new Vector2(1f, rectTransform.anchorMax.y);
				component2.anchor = component;
				component.sectionHeader = component2;
				component2.SetText(sectionName);
				OnScroll(Vector2.zero);
				if (_anchors.Count == 0)
				{
					component.RectTransform.sizeDelta = default(Vector2);
				}
				_currentSection = _anchors.Count;
				_anchors.Add(component);
			}
		}

		public void AddBinds(RemappableKey? kbmKey, RemappableKey? gamepadKey, bool isBaseGame = false, string controlName = "")
		{
			if (((Behaviour)this).isActiveAndEnabled && rebindItemPrefab != null && scrollRect != null)
			{
				if (kbmKey != null && string.IsNullOrEmpty(controlName))
				{
					controlName = kbmKey.ControlName;
				}
				else if (gamepadKey != null && string.IsNullOrEmpty(controlName))
				{
					controlName = gamepadKey.ControlName;
				}
				Object.Instantiate<GameObject>(rebindItemPrefab, (Transform)(object)_content).GetComponent<RebindItem>().SetBind(controlName, kbmKey, gamepadKey, isBaseGame);
			}
		}

		public void AddFooter()
		{
			if (((Behaviour)this).isActiveAndEnabled && spacerPrefab != null)
			{
				Object.Instantiate<GameObject>(spacerPrefab, (Transform)(object)_content);
			}
		}

		private void OnScroll(Vector2 delta)
		{
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			if (_scrollRectTransform == null || headerContainer == null || _rectTransform == null)
			{
				return;
			}
			float maxY = GetMaxY(headerContainer);
			int num = -1;
			for (int i = 0; i < _anchors.Count; i++)
			{
				SectionHeaderAnchor sectionHeaderAnchor = _anchors[i];
				SectionHeader sectionHeader = sectionHeaderAnchor.sectionHeader;
				if (i == 0)
				{
					sectionHeader.RectTransform.SetLocalPosY(maxY - (_sectionHeight / 2f - _spacing));
					num = i;
					continue;
				}
				SectionHeader sectionHeader2 = _anchors[i - 1].sectionHeader;
				float num2 = CalculateHeaderRawYPos(sectionHeaderAnchor);
				sectionHeader.RectTransform.SetLocalPosY(num2);
				float num3 = GetMaxY(sectionHeader.RectTransform) + ((Transform)sectionHeader.RectTransform).localPosition.y;
				float num4 = GetMinY(sectionHeader2.RectTransform) + ((Transform)sectionHeader2.RectTransform).localPosition.y;
				if (num3 + _sectionHeight / 2f + _spacing >= num4)
				{
					sectionHeader2.RectTransform.SetLocalPosY(num2 + _sectionHeight);
				}
				if (num3 + _spacing / 2f >= maxY - _sectionHeight / 2f)
				{
					num = i;
					sectionHeader.RectTransform.SetLocalPosY(maxY - (_sectionHeight / 2f - _spacing));
				}
			}
			if (_currentSection != num)
			{
				OnSectionChanged.Invoke(num);
			}
			_currentSection = num;
		}

		private float CalculateHeaderRawYPos(SectionHeaderAnchor anchor)
		{
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			if (_content == null || headerContainer == null || _scrollRectTransform == null)
			{
				return 0f;
			}
			float num = GetMaxY(headerContainer) - GetMaxY(_scrollRectTransform);
			num += _sectionHeight / 2f;
			num -= OffsetCompensation;
			return ((Transform)anchor.RectTransform).localPosition.y - (num + 50f) + ((Transform)_content).localPosition.y;
		}

		private void OnDrawGizmos()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			if (_rectTransform != null && headerContainer != null)
			{
				Color color = Gizmos.color;
				_rectTransform.DrawGizmoUiRectWorld();
				Gizmos.color = color;
			}
		}

		private float GetMaxY(RectTransform element)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: 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)
			if (_rectTransform == null)
			{
				_rectTransform = ((Component)this).GetComponent<RectTransform>();
			}
			Rect val = element.UiBounds(Vector3.zero);
			return ((Rect)(ref val)).max.y;
		}

		private float GetMinY(RectTransform element)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: 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)
			if (_rectTransform == null)
			{
				_rectTransform = ((Component)this).GetComponent<RectTransform>();
			}
			Rect val = element.UiBounds(Vector3.zero);
			return ((Rect)(ref val)).min.y;
		}
	}
	public class RebindButton : MonoBehaviour
	{
		public Selectable? button;

		public TextMeshProUGUI? bindLabel;

		public Image? glyphLabel;

		public Image? notSupportedImage;

		public RebindIndicator? rebindIndicator;

		public Button? resetButton;

		public Button? removeButton;

		public float timeout = 5f;

		private RemappableKey? _key;

		private bool _isBaseGame;

		private RebindingOperation? _rebindingOperation;

		private bool _rebinding;

		private float _timeoutTimer;

		private static MethodInfo? _setChangesNotAppliedMethodInfo;

		private static readonly List<RebindButton> Instances = new List<RebindButton>();

		public void SetKey(RemappableKey? key, bool isBaseGame)
		{
			_key = key;
			_isBaseGame = isBaseGame;
			UpdateState();
		}

		public void UpdateState()
		{
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			if (bindLabel == null || glyphLabel == null || button == null || notSupportedImage == null || resetButton == null || removeButton == null)
			{
				return;
			}
			if (_key == null)
			{
				SetAsUnsupported();
				return;
			}
			int rebindingIndex = GetRebindingIndex();
			InputAction action = _key.currentInput.action;
			if (rebindingIndex >= action.bindings.Count)
			{
				SetAsUnsupported();
				return;
			}
			GameObject gameObject = ((Component)resetButton).gameObject;
			InputBinding val = action.bindings[rebindingIndex];
			gameObject.SetActive(((InputBinding)(ref val)).hasOverrides);
			val = action.bindings[rebindingIndex];
			string effectivePath = ((InputBinding)(ref val)).effectivePath;
			string bindPath = InputControlPath.ToHumanReadableString(effectivePath, (HumanReadableStringOptions)2, (InputControl)null);
			if (_key.gamepadOnly)
			{
				((TMP_Text)bindLabel).SetText("", true);
				if (effectivePath == "<InputUtils-Gamepad-Not-Bound>")
				{
					((Component)removeButton).gameObject.SetActive(false);
					((Behaviour)glyphLabel).enabled = false;
					return;
				}
				((Component)removeButton).gameObject.SetActive(true);
				ControllerGlyph bestMatching = ControllerGlyph.GetBestMatching();
				if (bestMatching == null)
				{
					((TMP_Text)bindLabel).SetText(effectivePath, true);
					((Behaviour)glyphLabel).enabled = false;
					return;
				}
				Sprite val2 = bestMatching[effectivePath];
				if (val2 == null)
				{
					((TMP_Text)bindLabel).SetText(effectivePath, true);
					((Behaviour)glyphLabel).enabled = false;
				}
				else
				{
					glyphLabel.sprite = val2;
					((Behaviour)glyphLabel).enabled = true;
				}
			}
			else
			{
				((Component)removeButton).gameObject.SetActive(!string.Equals(effectivePath, "<InputUtils-Kbm-Not-Bound>"));
				HandleKbmGlyphOrLabel(effectivePath, bindPath);
			}
		}

		private void HandleKbmGlyphOrLabel(string effectivePath, string bindPath)
		{
			if (bindLabel == null || glyphLabel == null)
			{
				return;
			}
			if (ControllerGlyph.MouseGlyphs != null)
			{
				Sprite val = ControllerGlyph.MouseGlyphs[effectivePath];
				if (val != null)
				{
					((TMP_Text)bindLabel).SetText("", true);
					glyphLabel.sprite = val;
					((Behaviour)glyphLabel).enabled = true;
					return;
				}
			}
			((Behaviour)glyphLabel).enabled = false;
			((TMP_Text)bindLabel).SetText(bindPath, true);
		}

		private void SetAsUnsupported()
		{
			if (button != null && bindLabel != null && glyphLabel != null && notSupportedImage != null && resetButton != null && removeButton != null)
			{
				button.interactable = false;
				button.targetGraphic.raycastTarget = false;
				((Behaviour)button.targetGraphic).enabled = false;
				((TMP_Text)bindLabel).SetText("", true);
				((Behaviour)glyphLabel).enabled = false;
				((Component)notSupportedImage).gameObject.SetActive(true);
				((Component)resetButton).gameObject.SetActive(false);
				((Component)removeButton).gameObject.SetActive(false);
			}
		}

		private int GetRebindingIndex()
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: 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_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			if (_key == null)
			{
				return -1;
			}
			InputAction action = _key.currentInput.action;
			if (action.controls.Count == 0)
			{
				if (action.bindings.Count == 0)
				{
					return -1;
				}
				if (_key.gamepadOnly && action.bindings.Count > 1)