Decompiled source of Rebindables v1.0.4

Rebindables.dll

Decompiled a day ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using Microsoft.CodeAnalysis;
using MonoMod.RuntimeDetour;
using On.RoR2;
using On.RoR2.UI;
using Rewired;
using Rewired.Data;
using Rewired.Data.Mapping;
using RoR2;
using RoR2.UI;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Rebindables")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+92a073609133a40c801e07c71061ab4ac98901f0")]
[assembly: AssemblyProduct("Rebindables")]
[assembly: AssemblyTitle("Rebindables")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: UnverifiableCode]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace Rebindables
{
	public static class InputBankExtensions
	{
		public static ButtonState GetButtonState(this InputBankTest bank, ModKeybind bind)
		{
			//IL_0003: 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_000b: Unknown result type (might be due to invalid IL or missing references)
			return bind.GetButtonState(bank);
		}
	}
	public class RebindAPI
	{
		internal delegate void orig_RewiredMoment(UserData self);

		[CompilerGenerated]
		private static class <>O
		{
			public static hook_LoadUserProfiles <0>__LoadProfiles;

			public static hook_Start <1>__SPCStart;

			public static hook_Start <2>__IBTStart;

			public static hook_LoadDefaultProfile <3>__LoadDefault;

			public static hook_FillDefaultJoystickMaps <4>__FillJoystickMaps;
		}

		private static int lastClaimedID = 940;

		public static List<ModKeybind> Keybinds = new List<ModKeybind>();

		public static Dictionary<ModKeybind, InputAction> KeybindActions = new Dictionary<ModKeybind, InputAction>();

		internal static void ApplyHooks()
		{
			//IL_0011: 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_001c: Expected O, but got Unknown
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Expected O, but got Unknown
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Expected O, but got Unknown
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Expected O, but got Unknown
			//IL_00d0: 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_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Expected O, but got Unknown
			object obj = <>O.<0>__LoadProfiles;
			if (obj == null)
			{
				hook_LoadUserProfiles val = LoadProfiles;
				<>O.<0>__LoadProfiles = val;
				obj = (object)val;
			}
			SaveSystem.LoadUserProfiles += (hook_LoadUserProfiles)obj;
			object obj2 = <>O.<1>__SPCStart;
			if (obj2 == null)
			{
				hook_Start val2 = SPCStart;
				<>O.<1>__SPCStart = val2;
				obj2 = (object)val2;
			}
			SettingsPanelController.Start += (hook_Start)obj2;
			object obj3 = <>O.<2>__IBTStart;
			if (obj3 == null)
			{
				hook_Start val3 = IBTStart;
				<>O.<2>__IBTStart = val3;
				obj3 = (object)val3;
			}
			InputBankTest.Start += (hook_Start)obj3;
			object obj4 = <>O.<3>__LoadDefault;
			if (obj4 == null)
			{
				hook_LoadDefaultProfile val4 = LoadDefault;
				<>O.<3>__LoadDefault = val4;
				obj4 = (object)val4;
			}
			UserProfile.LoadDefaultProfile += (hook_LoadDefaultProfile)obj4;
			object obj5 = <>O.<4>__FillJoystickMaps;
			if (obj5 == null)
			{
				hook_FillDefaultJoystickMaps val5 = FillJoystickMaps;
				<>O.<4>__FillJoystickMaps = val5;
				obj5 = (object)val5;
			}
			UserProfile.FillDefaultJoystickMaps += (hook_FillDefaultJoystickMaps)obj5;
			new Hook((MethodBase)typeof(UserData).GetMethod("gLOOAxUFAvrvUufkVjaYyZoeLbLE", (BindingFlags)(-1)), typeof(RebindAPI).GetMethod("RewiredMoment", (BindingFlags)(-1)));
		}

		private static void FillJoystickMaps(orig_FillDefaultJoystickMaps orig, UserProfile self)
		{
			orig.Invoke(self);
			AddMaps(self);
			self.RequestEventualSave();
		}

		private static void LoadDefault(orig_LoadDefaultProfile orig)
		{
			orig.Invoke();
			AddMaps(UserProfile.defaultProfile);
			UserProfile.defaultProfile.RequestEventualSave();
		}

		private static void IBTStart(orig_Start orig, InputBankTest self)
		{
			orig.Invoke(self);
			((Component)self).gameObject.AddComponent<ModdedInputBank>();
		}

		private static void RewiredMoment(orig_RewiredMoment orig, UserData self)
		{
			foreach (ModKeybind keybind in Keybinds)
			{
				self.actions?.Add(KeybindActions[keybind]);
				FillAction(keybind, self.keyboardMaps, self.joystickMaps, self.mouseMaps);
			}
			orig(self);
		}

		private static void SPCStart(orig_Start orig, SettingsPanelController self)
		{
			orig.Invoke(self);
			if (!(((Object)self).name == "SettingsSubPanel, Controls (M&KB)") && !(((Object)self).name == "SettingsSubPanel, Controls (Gamepad)"))
			{
				return;
			}
			GameObject gameObject = ((Component)((Component)self).transform.Find("Scroll View").Find("Viewport").Find("VerticalLayout")
				.Find("SettingsEntryButton, Binding (Jump)")).gameObject;
			Transform val = ((Component)self).transform.Find("Scroll View").Find("Viewport").Find("VerticalLayout");
			foreach (ModKeybind keybind in Keybinds)
			{
				GameObject val2 = Object.Instantiate<GameObject>(gameObject, val);
				InputBindingControl component = val2.GetComponent<InputBindingControl>();
				component.actionName = keybind.InternalName;
				component.Awake();
				if (keybind.Position != null)
				{
					int num = FindSiblingIndex(keybind.Position, val);
					if (num != -1)
					{
						val2.transform.SetSiblingIndex(num + 1);
					}
				}
			}
		}

		private static int FindSiblingIndex(string input, Transform target)
		{
			Transform val = target.Find("SettingsEntryButton, Binding (" + input + ")");
			Transform val2 = target.Find("SettingsEntryButton, Bool (" + input + ")");
			Transform val3 = target.Find("SettingsEntryButton, Slider (" + input + ")");
			return ((Object)(object)val != (Object)null) ? val.GetSiblingIndex() : (((Object)(object)val2 != (Object)null) ? val2.GetSiblingIndex() : (((Object)(object)val3 != (Object)null) ? val3.GetSiblingIndex() : (-1)));
		}

		private static void LoadProfiles(orig_LoadUserProfiles orig, SaveSystem self)
		{
			orig.Invoke(self);
			foreach (KeyValuePair<string, UserProfile> loadedUserProfile in self.loadedUserProfiles)
			{
				UserProfile value = loadedUserProfile.Value;
				AddMaps(value);
				value.RequestEventualSave();
			}
		}

		private static void AddMaps(UserProfile prof)
		{
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_019c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0295: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c5: Unknown result type (might be due to invalid IL or missing references)
			ActionElementMap val = default(ActionElementMap);
			ActionElementMap val2 = default(ActionElementMap);
			foreach (ModKeybind bind in Keybinds)
			{
				if (((ControllerMap)prof.keyboardMap).AllMaps.All((ActionElementMap x) => x.actionId != bind.Id) && ((ControllerMap)prof.mouseMap).AllMaps.All((ActionElementMap x) => x.actionId != bind.Id) && !bind.IsMouse())
				{
					((ControllerMap)prof.keyboardMap).CreateElementMap(bind.kbMap.actionId, bind.kbMap.axisContribution, bind.kbMap.elementIdentifierId, bind.kbMap.elementType, bind.kbMap.axisRange, bind.kbMap.invert, ref val);
					val._keyboardKeyCode = (KeyboardKeyCode)bind.DefaultKeyboardInput;
					val.keyCode = bind.DefaultKeyboardInput;
					bind.kbMap.cVYzDXVDMNXvRMrklCVdVyeXGAlK((ControllerMap)(object)prof.keyboardMap);
				}
				if (((ControllerMap)prof.keyboardMap).AllMaps.All((ActionElementMap x) => x.actionId != bind.Id) && ((ControllerMap)prof.mouseMap).AllMaps.All((ActionElementMap x) => x.actionId != bind.Id) && !bind.IsMouse())
				{
					((ControllerMap)prof.mouseMap).CreateElementMap(bind.mMap.actionId, bind.mMap.axisContribution, bind.mMap.elementIdentifierId, bind.mMap.elementType, bind.mMap.axisRange, bind.mMap.invert, ref val2);
					val2.keyCode = bind.DefaultKeyboardInput;
					bind.mMap.cVYzDXVDMNXvRMrklCVdVyeXGAlK((ControllerMap)(object)prof.mouseMap);
				}
				foreach (var (_, val4) in prof.HardwareJoystickMaps2)
				{
					if (((ControllerMap)val4).AllMaps.All((ActionElementMap x) => x.actionId != bind.Id))
					{
						((ControllerMap)val4).CreateElementMap(bind.jsMap.actionId, bind.jsMap.axisContribution, bind.jsMap.elementIdentifierId, bind.jsMap.elementType, bind.jsMap.axisRange, bind.jsMap.invert);
						bind.jsMap.cVYzDXVDMNXvRMrklCVdVyeXGAlK((ControllerMap)(object)prof.joystickMap);
					}
				}
			}
		}

		private static void FillAction(ModKeybind bind, List<ControllerMap_Editor> kb, List<ControllerMap_Editor> ctrl, List<ControllerMap_Editor> m)
		{
			foreach (ControllerMap_Editor item in kb)
			{
				if (item.categoryId == 0 && item.actionElementMaps.All((ActionElementMap x) => x.actionId != bind.Id))
				{
					item.actionElementMaps.Add(bind.kbMap);
				}
			}
			foreach (ControllerMap_Editor item2 in ctrl)
			{
				if (item2.categoryId == 0 && item2.actionElementMaps.All((ActionElementMap x) => x.actionId != bind.Id))
				{
					item2.actionElementMaps.Add(bind.jsMap);
				}
			}
			foreach (ControllerMap_Editor item3 in m)
			{
				if (item3.categoryId == 0 && item3.actionElementMaps.All((ActionElementMap x) => x.actionId != bind.Id))
				{
					item3.actionElementMaps.Add(bind.kbMap);
				}
			}
		}

		public static ModKeybind RegisterModKeybind(ModKeybind keybind)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			InputAction val = new InputAction();
			int num = Rebindables.ReadID(keybind.InternalName);
			while (num == -1)
			{
				int num2 = lastClaimedID++;
				if (!Rebindables.CheckIDExists(num2))
				{
					num = num2;
					break;
				}
			}
			val.QurFqcdYtHIEpCpYBddZfQQtnImHA(num);
			Rebindables.WriteID(keybind.InternalName, num);
			val.MFwTFVDRoziRWNJMARlSUXIebtLw(0);
			val.nfWwbfSEwQCdVSicPaIBIPkMqJfu(keybind.InternalName);
			val.LEWtVuPGPZtPpCUSAMYCEbPqyAuf(keybind.InternalName);
			val.REsRGcKFtjbUwlqUSreCTUubayPb(0);
			val.BSFQAxJApIZsVFnOmINQEGShHPvFb(true);
			val.nLGCfekdjaMIxCLlcjdYgcEjEDxz(keybind.InputType);
			keybind.Id = val.id;
			keybind.action = val;
			ActionAxisPair key = default(ActionAxisPair);
			((ActionAxisPair)(ref key))..ctor(val.name, keybind.AxisRange);
			InputCatalog.actionToToken[key] = keybind.DisplayToken;
			Keybinds.Add(keybind);
			KeybindActions.Add(keybind, val);
			return keybind;
		}
	}
	public class ModKeybind
	{
		internal string InternalName;

		public string DisplayToken;

		public KeyCode DefaultKeyboardInput;

		public int DefaultJoystickInput;

		public InputActionType InputType;

		public AxisRange AxisRange;

		private ActionElementMap _kbMap;

		private ActionElementMap _jsMap;

		private ActionElementMap _mMap;

		public string Position;

		internal int Id;

		internal InputAction action;

		internal ActionElementMap kbMap
		{
			get
			{
				//IL_0018: Unknown result type (might be due to invalid IL or missing references)
				//IL_0022: Unknown result type (might be due to invalid IL or missing references)
				//IL_0027: Unknown result type (might be due to invalid IL or missing references)
				//IL_0029: Expected O, but got Unknown
				//IL_002e: Expected O, but got Unknown
				ActionElementMap obj = _kbMap;
				if (obj == null)
				{
					ActionElementMap val = new ActionElementMap(action.id, (ControllerElementType)1, ToElementId(DefaultKeyboardInput));
					ActionElementMap val2 = val;
					_kbMap = val;
					obj = val2;
				}
				return obj;
			}
		}

		internal ActionElementMap jsMap
		{
			get
			{
				//IL_0017: Unknown result type (might be due to invalid IL or missing references)
				//IL_001d: Invalid comparison between Unknown and I4
				//IL_002a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0030: Invalid comparison between Unknown and I4
				//IL_0037: Unknown result type (might be due to invalid IL or missing references)
				//IL_003c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0041: Unknown result type (might be due to invalid IL or missing references)
				//IL_0043: Expected O, but got Unknown
				//IL_0048: Expected O, but got Unknown
				ActionElementMap obj = _jsMap;
				if (obj == null)
				{
					ActionElementMap val = new ActionElementMap(action.id, (ControllerElementType)((int)InputType == 1), DefaultJoystickInput, (Pole)((int)AxisRange == 2), AxisRange);
					ActionElementMap val2 = val;
					_jsMap = val;
					obj = val2;
				}
				return obj;
			}
		}

		internal ActionElementMap mMap
		{
			get
			{
				//IL_0018: Unknown result type (might be due to invalid IL or missing references)
				//IL_0022: Unknown result type (might be due to invalid IL or missing references)
				//IL_0027: Unknown result type (might be due to invalid IL or missing references)
				//IL_0029: Expected O, but got Unknown
				//IL_002e: Expected O, but got Unknown
				ActionElementMap obj = _mMap;
				if (obj == null)
				{
					ActionElementMap val = new ActionElementMap(action.id, (ControllerElementType)1, ToElementId(DefaultKeyboardInput));
					ActionElementMap val2 = val;
					_mMap = val;
					obj = val2;
				}
				return obj;
			}
		}

		public ModKeybind(string displayToken, KeyCode defaultKeyboardInput, int defaultJoystickInput, string position = null, InputActionType type = 1, AxisRange range = 0)
		{
			//IL_0026: 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)
			InternalName = displayToken.Replace("_", "");
			DisplayToken = displayToken;
			DefaultKeyboardInput = defaultKeyboardInput;
			DefaultJoystickInput = defaultJoystickInput;
			Position = position;
		}

		public ButtonState GetButtonState(InputBankTest inputBank)
		{
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: 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_0062: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)inputBank != (Object)null && ModdedInputBank.BankMap.ContainsKey(inputBank))
			{
				return ModdedInputBank.BankMap[inputBank].ButtonStates[this];
			}
			Rebindables.ModLogger.LogError((object)("Attempted to get state for " + InternalName + " on a InputBankTest that does not exist!"));
			return default(ButtonState);
		}

		public bool IsMouse()
		{
			//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)
			//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_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_0012: Invalid comparison between Unknown and I4
			//IL_0016: 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_001e: Invalid comparison between Unknown and I4
			KeyCode defaultKeyboardInput = DefaultKeyboardInput;
			KeyCode val = defaultKeyboardInput;
			if (val - 323 <= 1 || val - 326 <= 2)
			{
				return true;
			}
			return false;
		}

		public static int ToElementId(KeyCode key)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0004: 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_020b: Expected I4, but got Unknown
			//IL_020d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0213: Unknown result type (might be due to invalid IL or missing references)
			//IL_033d: Expected I4, but got Unknown
			switch ((int)key)
			{
			default:
				switch (key - 256)
				{
				case 0:
					return 37;
				case 1:
					return 38;
				case 2:
					return 39;
				case 3:
					return 40;
				case 4:
					return 41;
				case 5:
					return 42;
				case 6:
					return 43;
				case 7:
					return 44;
				case 8:
					return 45;
				case 9:
					return 46;
				case 10:
					return 47;
				case 11:
					return 48;
				case 12:
					return 49;
				case 13:
					return 50;
				case 14:
					return 51;
				case 15:
					return 52;
				case 16:
					return 53;
				case 17:
					return 89;
				case 18:
					return 90;
				case 19:
					return 91;
				case 20:
					return 92;
				case 21:
					return 93;
				case 22:
					return 94;
				case 23:
					return 95;
				case 24:
					return 96;
				case 25:
					return 97;
				case 26:
					return 98;
				case 27:
					return 99;
				case 28:
					return 100;
				case 29:
					return 101;
				case 30:
					return 102;
				case 31:
					return 103;
				case 32:
					return 104;
				case 33:
					return 105;
				case 34:
					return 106;
				case 35:
					return 107;
				case 36:
					return 108;
				case 37:
					return 109;
				case 38:
					return 110;
				case 39:
					return 111;
				case 40:
					return 112;
				case 44:
					return 113;
				case 45:
					return 114;
				case 46:
					return 115;
				case 47:
					return 116;
				case 48:
					return 117;
				case 49:
					return 118;
				case 50:
					return 119;
				case 51:
					return 120;
				case 52:
					return 121;
				case 53:
					return 122;
				case 54:
					return 123;
				case 55:
					return 124;
				case 56:
					return 125;
				case 57:
					return 126;
				case 59:
					return 127;
				case 60:
					return 128;
				case 61:
					return 129;
				case 62:
					return 130;
				case 63:
					return 131;
				case 67:
					return 3;
				case 68:
					return 4;
				case 70:
					return 5;
				case 71:
					return 6;
				case 72:
					return 7;
				}
				break;
			case 0:
				return 0;
			case 97:
				return 1;
			case 98:
				return 2;
			case 99:
				return 3;
			case 100:
				return 4;
			case 101:
				return 5;
			case 102:
				return 6;
			case 103:
				return 7;
			case 104:
				return 8;
			case 105:
				return 9;
			case 106:
				return 10;
			case 107:
				return 11;
			case 108:
				return 12;
			case 109:
				return 13;
			case 110:
				return 14;
			case 111:
				return 15;
			case 112:
				return 16;
			case 113:
				return 17;
			case 114:
				return 18;
			case 115:
				return 19;
			case 116:
				return 20;
			case 117:
				return 21;
			case 118:
				return 22;
			case 119:
				return 23;
			case 120:
				return 24;
			case 121:
				return 25;
			case 122:
				return 26;
			case 48:
				return 27;
			case 49:
				return 28;
			case 50:
				return 29;
			case 51:
				return 30;
			case 52:
				return 31;
			case 53:
				return 32;
			case 54:
				return 33;
			case 55:
				return 34;
			case 56:
				return 35;
			case 57:
				return 36;
			case 32:
				return 54;
			case 8:
				return 55;
			case 9:
				return 56;
			case 12:
				return 57;
			case 13:
				return 58;
			case 19:
				return 59;
			case 27:
				return 60;
			case 33:
				return 61;
			case 34:
				return 62;
			case 35:
				return 63;
			case 36:
				return 64;
			case 38:
				return 65;
			case 39:
				return 66;
			case 40:
				return 67;
			case 41:
				return 68;
			case 42:
				return 69;
			case 43:
				return 70;
			case 44:
				return 71;
			case 45:
				return 72;
			case 46:
				return 73;
			case 47:
				return 74;
			case 58:
				return 75;
			case 59:
				return 76;
			case 60:
				return 77;
			case 61:
				return 78;
			case 62:
				return 79;
			case 63:
				return 80;
			case 64:
				return 81;
			case 91:
				return 82;
			case 92:
				return 83;
			case 93:
				return 84;
			case 94:
				return 85;
			case 95:
				return 86;
			case 96:
				return 87;
			case 127:
				return 88;
			case 1:
			case 2:
			case 3:
			case 4:
			case 5:
			case 6:
			case 7:
			case 10:
			case 11:
			case 14:
			case 15:
			case 16:
			case 17:
			case 18:
			case 20:
			case 21:
			case 22:
			case 23:
			case 24:
			case 25:
			case 26:
			case 28:
			case 29:
			case 30:
			case 31:
			case 37:
			case 65:
			case 66:
			case 67:
			case 68:
			case 69:
			case 70:
			case 71:
			case 72:
			case 73:
			case 74:
			case 75:
			case 76:
			case 77:
			case 78:
			case 79:
			case 80:
			case 81:
			case 82:
			case 83:
			case 84:
			case 85:
			case 86:
			case 87:
			case 88:
			case 89:
			case 90:
			case 123:
			case 124:
			case 125:
			case 126:
				break;
			}
			return -1;
		}
	}
	internal class ModdedInputBank : MonoBehaviour
	{
		public PlayerCharacterMasterController pcmc;

		public Dictionary<ModKeybind, ButtonState> ButtonStates = new Dictionary<ModKeybind, ButtonState>();

		public static Dictionary<InputBankTest, ModdedInputBank> BankMap = new Dictionary<InputBankTest, ModdedInputBank>();

		public void Start()
		{
			//IL_0021: 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)
			foreach (ModKeybind keybind in RebindAPI.Keybinds)
			{
				ButtonStates.Add(keybind, default(ButtonState));
			}
			BankMap.Add(((Component)this).GetComponent<InputBankTest>(), this);
		}

		public void OnDestroy()
		{
			BankMap.Remove(((Component)this).GetComponent<InputBankTest>());
		}

		public void FixedUpdate()
		{
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			LocalUser val = default(LocalUser);
			Player val2 = default(Player);
			CameraRigController val3 = default(CameraRigController);
			bool flag = default(bool);
			if (!Object.op_Implicit((Object)(object)pcmc))
			{
				CharacterBody component = ((Component)this).GetComponent<CharacterBody>();
				if (Object.op_Implicit((Object)(object)component))
				{
					pcmc = (Object.op_Implicit((Object)(object)component.master) ? component.master.playerCharacterMasterController : null);
				}
			}
			else if (PlayerCharacterMasterController.CanSendBodyInput(pcmc.networkUser, ref val, ref val2, ref val3, ref flag))
			{
				for (int i = 0; i < RebindAPI.Keybinds.Count; i++)
				{
					ModKeybind modKeybind = RebindAPI.Keybinds[i];
					ButtonState value = ButtonStates[modKeybind];
					((ButtonState)(ref value)).PushState(val2.GetButton(modKeybind.Id));
					ButtonStates[modKeybind] = value;
				}
			}
		}
	}
	[BepInPlugin("pseudopulse.Rebindables", "Rebindables", "1.0.4")]
	public class Rebindables : BaseUnityPlugin
	{
		public const string PluginGUID = "pseudopulse.Rebindables";

		public const string PluginAuthor = "pseudopulse";

		public const string PluginName = "Rebindables";

		public const string PluginVersion = "1.0.4";

		public static ManualLogSource ModLogger;

		public static string RebindablesSaveInfoPath;

		public void Awake()
		{
			ModLogger = ((BaseUnityPlugin)this).Logger;
			RebindAPI.ApplyHooks();
			VerifyFile();
		}

		public static void VerifyFile()
		{
			RebindablesSaveInfoPath = Path.Combine(Application.persistentDataPath, "RebindablesInfo");
			try
			{
				if (!File.Exists(RebindablesSaveInfoPath))
				{
					File.CreateText(RebindablesSaveInfoPath).Close();
				}
			}
			catch
			{
				RebindablesSaveInfoPath = Assembly.GetExecutingAssembly().Location.Replace("Rebindables.dll", "RebindablesInfo");
				if (!File.Exists(RebindablesSaveInfoPath))
				{
					File.CreateText(RebindablesSaveInfoPath).Close();
				}
			}
		}

		public static int ReadID(string internalName)
		{
			string text = File.ReadAllText(RebindablesSaveInfoPath);
			List<string> list = text.Split("|").ToList();
			int num = list.IndexOf(internalName);
			if (num == -1)
			{
				return -1;
			}
			if (num > list.Count || num + 1 > list.Count)
			{
				return -1;
			}
			return int.Parse(list[num + 1]);
		}

		public static bool CheckIDExists(int id)
		{
			string text = File.ReadAllText(RebindablesSaveInfoPath);
			List<string> list = text.Split("|").ToList();
			for (int i = 0; i < list.Count; i++)
			{
				if (i % 2 != 0 && int.TryParse(list[i], out var result) && result == id)
				{
					return true;
				}
			}
			return false;
		}

		public static void WriteID(string internalName, int id)
		{
			string text = File.ReadAllText(RebindablesSaveInfoPath);
			int num = ReadID(internalName);
			if (num != -1)
			{
				text = text.Replace($"{internalName}|{num}|", "");
			}
			text += $"{internalName}|{id}|";
			File.WriteAllText(RebindablesSaveInfoPath, text);
		}
	}
}