Decompiled source of HZ FixedKeybinds v1.0.0

HZ_FixedKeybinds.dll

Decompiled 14 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using TMPro;
using UnityEngine;

[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("HZ_FixedKeybinds")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("HZ_FixedKeybinds")]
[assembly: AssemblyTitle("HZ_FixedKeybinds")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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 ExtendedKeybinds
{
	internal sealed class ConfigurationManagerAttributes
	{
		public Action<ConfigEntryBase> CustomDrawer;

		public int? Order;
	}
	[HarmonyPatch(typeof(HotkeyBar), "UpdateIcons")]
	internal class HotkeyBarLabelPatch
	{
		private static readonly FieldRef<HotkeyBar, IList> ElementsField = AccessTools.FieldRefAccess<HotkeyBar, IList>("m_elements");

		[HarmonyPostfix]
		private static void Postfix(HotkeyBar __instance)
		{
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Expected O, but got Unknown
			if (ZInput.IsGamepadActive() || !ModConfig.IsInitialized)
			{
				return;
			}
			IList list = ElementsField.Invoke(__instance);
			if (list == null)
			{
				return;
			}
			for (int i = 0; i < list.Count && i < 8; i++)
			{
				object obj = list[i];
				if (obj == null)
				{
					continue;
				}
				GameObject val = (GameObject)AccessTools.Field(obj.GetType(), "m_go").GetValue(obj);
				if ((Object)(object)val == (Object)null)
				{
					continue;
				}
				Transform val2 = val.transform.Find("binding");
				if (!((Object)(object)val2 == (Object)null))
				{
					TMP_Text component = ((Component)val2).GetComponent<TMP_Text>();
					if (!((Object)(object)component == (Object)null))
					{
						string shortcutDisplayName = ModConfig.GetShortcutDisplayName($"Hotbar{i + 1}", richText: true);
						component.text = shortcutDisplayName;
					}
				}
			}
		}
	}
	[HarmonyPatch(typeof(InventoryGrid), "UpdateGui")]
	internal class InventoryGridLabelPatch
	{
		private static readonly FieldRef<InventoryGrid, IList> ElementsField = AccessTools.FieldRefAccess<InventoryGrid, IList>("m_elements");

		[HarmonyPostfix]
		private static void Postfix(InventoryGrid __instance, Player player, ItemData dragItem)
		{
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Expected O, but got Unknown
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)player == (Object)null || !ModConfig.IsInitialized)
			{
				return;
			}
			IList list = ElementsField.Invoke(__instance);
			if (list == null)
			{
				return;
			}
			foreach (object item in list)
			{
				Type type = item.GetType();
				Vector2i val = (Vector2i)AccessTools.Field(type, "m_pos").GetValue(item);
				if (val.y != 0 || val.x < 0 || val.x >= 8)
				{
					continue;
				}
				GameObject val2 = (GameObject)AccessTools.Field(type, "m_go").GetValue(item);
				if ((Object)(object)val2 == (Object)null)
				{
					continue;
				}
				Transform val3 = val2.transform.Find("binding");
				if (!((Object)(object)val3 == (Object)null))
				{
					TMP_Text component = ((Component)val3).GetComponent<TMP_Text>();
					if (!((Object)(object)component == (Object)null))
					{
						string internalName = $"Hotbar{val.x + 1}";
						component.text = ModConfig.GetShortcutDisplayName(internalName, richText: true);
					}
				}
			}
		}
	}
	internal static class KeyCodePathMap
	{
		private static readonly Dictionary<KeyCode, string> Map = new Dictionary<KeyCode, string>
		{
			{
				(KeyCode)48,
				"<Keyboard>/0"
			},
			{
				(KeyCode)49,
				"<Keyboard>/1"
			},
			{
				(KeyCode)50,
				"<Keyboard>/2"
			},
			{
				(KeyCode)51,
				"<Keyboard>/3"
			},
			{
				(KeyCode)52,
				"<Keyboard>/4"
			},
			{
				(KeyCode)53,
				"<Keyboard>/5"
			},
			{
				(KeyCode)54,
				"<Keyboard>/6"
			},
			{
				(KeyCode)55,
				"<Keyboard>/7"
			},
			{
				(KeyCode)56,
				"<Keyboard>/8"
			},
			{
				(KeyCode)57,
				"<Keyboard>/9"
			},
			{
				(KeyCode)97,
				"<Keyboard>/a"
			},
			{
				(KeyCode)98,
				"<Keyboard>/b"
			},
			{
				(KeyCode)99,
				"<Keyboard>/c"
			},
			{
				(KeyCode)100,
				"<Keyboard>/d"
			},
			{
				(KeyCode)101,
				"<Keyboard>/e"
			},
			{
				(KeyCode)102,
				"<Keyboard>/f"
			},
			{
				(KeyCode)103,
				"<Keyboard>/g"
			},
			{
				(KeyCode)104,
				"<Keyboard>/h"
			},
			{
				(KeyCode)105,
				"<Keyboard>/i"
			},
			{
				(KeyCode)106,
				"<Keyboard>/j"
			},
			{
				(KeyCode)107,
				"<Keyboard>/k"
			},
			{
				(KeyCode)108,
				"<Keyboard>/l"
			},
			{
				(KeyCode)109,
				"<Keyboard>/m"
			},
			{
				(KeyCode)110,
				"<Keyboard>/n"
			},
			{
				(KeyCode)111,
				"<Keyboard>/o"
			},
			{
				(KeyCode)112,
				"<Keyboard>/p"
			},
			{
				(KeyCode)113,
				"<Keyboard>/q"
			},
			{
				(KeyCode)114,
				"<Keyboard>/r"
			},
			{
				(KeyCode)115,
				"<Keyboard>/s"
			},
			{
				(KeyCode)116,
				"<Keyboard>/t"
			},
			{
				(KeyCode)117,
				"<Keyboard>/u"
			},
			{
				(KeyCode)118,
				"<Keyboard>/v"
			},
			{
				(KeyCode)119,
				"<Keyboard>/w"
			},
			{
				(KeyCode)120,
				"<Keyboard>/x"
			},
			{
				(KeyCode)121,
				"<Keyboard>/y"
			},
			{
				(KeyCode)122,
				"<Keyboard>/z"
			},
			{
				(KeyCode)282,
				"<Keyboard>/f1"
			},
			{
				(KeyCode)283,
				"<Keyboard>/f2"
			},
			{
				(KeyCode)284,
				"<Keyboard>/f3"
			},
			{
				(KeyCode)285,
				"<Keyboard>/f4"
			},
			{
				(KeyCode)286,
				"<Keyboard>/f5"
			},
			{
				(KeyCode)287,
				"<Keyboard>/f6"
			},
			{
				(KeyCode)288,
				"<Keyboard>/f7"
			},
			{
				(KeyCode)289,
				"<Keyboard>/f8"
			},
			{
				(KeyCode)290,
				"<Keyboard>/f9"
			},
			{
				(KeyCode)291,
				"<Keyboard>/f10"
			},
			{
				(KeyCode)292,
				"<Keyboard>/f11"
			},
			{
				(KeyCode)293,
				"<Keyboard>/f12"
			},
			{
				(KeyCode)32,
				"<Keyboard>/space"
			},
			{
				(KeyCode)9,
				"<Keyboard>/tab"
			},
			{
				(KeyCode)301,
				"<Keyboard>/capsLock"
			},
			{
				(KeyCode)8,
				"<Keyboard>/backspace"
			},
			{
				(KeyCode)13,
				"<Keyboard>/enter"
			},
			{
				(KeyCode)27,
				"<Keyboard>/escape"
			},
			{
				(KeyCode)304,
				"<Keyboard>/leftShift"
			},
			{
				(KeyCode)303,
				"<Keyboard>/rightShift"
			},
			{
				(KeyCode)306,
				"<Keyboard>/leftCtrl"
			},
			{
				(KeyCode)305,
				"<Keyboard>/rightCtrl"
			},
			{
				(KeyCode)308,
				"<Keyboard>/leftAlt"
			},
			{
				(KeyCode)307,
				"<Keyboard>/rightAlt"
			},
			{
				(KeyCode)273,
				"<Keyboard>/upArrow"
			},
			{
				(KeyCode)274,
				"<Keyboard>/downArrow"
			},
			{
				(KeyCode)276,
				"<Keyboard>/leftArrow"
			},
			{
				(KeyCode)275,
				"<Keyboard>/rightArrow"
			},
			{
				(KeyCode)277,
				"<Keyboard>/insert"
			},
			{
				(KeyCode)127,
				"<Keyboard>/delete"
			},
			{
				(KeyCode)278,
				"<Keyboard>/home"
			},
			{
				(KeyCode)279,
				"<Keyboard>/end"
			},
			{
				(KeyCode)280,
				"<Keyboard>/pageUp"
			},
			{
				(KeyCode)281,
				"<Keyboard>/pageDown"
			},
			{
				(KeyCode)61,
				"<Keyboard>/equals"
			},
			{
				(KeyCode)45,
				"<Keyboard>/minus"
			},
			{
				(KeyCode)96,
				"<Keyboard>/backquote"
			},
			{
				(KeyCode)91,
				"<Keyboard>/leftBracket"
			},
			{
				(KeyCode)93,
				"<Keyboard>/rightBracket"
			},
			{
				(KeyCode)59,
				"<Keyboard>/semicolon"
			},
			{
				(KeyCode)39,
				"<Keyboard>/quote"
			},
			{
				(KeyCode)44,
				"<Keyboard>/comma"
			},
			{
				(KeyCode)46,
				"<Keyboard>/period"
			},
			{
				(KeyCode)47,
				"<Keyboard>/slash"
			},
			{
				(KeyCode)92,
				"<Keyboard>/backslash"
			},
			{
				(KeyCode)256,
				"<Keyboard>/numpad0"
			},
			{
				(KeyCode)257,
				"<Keyboard>/numpad1"
			},
			{
				(KeyCode)258,
				"<Keyboard>/numpad2"
			},
			{
				(KeyCode)259,
				"<Keyboard>/numpad3"
			},
			{
				(KeyCode)260,
				"<Keyboard>/numpad4"
			},
			{
				(KeyCode)261,
				"<Keyboard>/numpad5"
			},
			{
				(KeyCode)262,
				"<Keyboard>/numpad6"
			},
			{
				(KeyCode)263,
				"<Keyboard>/numpad7"
			},
			{
				(KeyCode)264,
				"<Keyboard>/numpad8"
			},
			{
				(KeyCode)265,
				"<Keyboard>/numpad9"
			},
			{
				(KeyCode)266,
				"<Keyboard>/numpadPeriod"
			},
			{
				(KeyCode)267,
				"<Keyboard>/numpadDivide"
			},
			{
				(KeyCode)268,
				"<Keyboard>/numpadMultiply"
			},
			{
				(KeyCode)269,
				"<Keyboard>/numpadMinus"
			},
			{
				(KeyCode)270,
				"<Keyboard>/numpadPlus"
			},
			{
				(KeyCode)271,
				"<Keyboard>/numpadEnter"
			},
			{
				(KeyCode)323,
				"<Mouse>/leftButton"
			},
			{
				(KeyCode)324,
				"<Mouse>/rightButton"
			},
			{
				(KeyCode)325,
				"<Mouse>/middleButton"
			},
			{
				(KeyCode)326,
				"<Mouse>/button3"
			},
			{
				(KeyCode)327,
				"<Mouse>/button4"
			},
			{
				(KeyCode)328,
				"<Mouse>/button5"
			},
			{
				(KeyCode)329,
				"<Mouse>/button6"
			}
		};

		public static string ToPath(KeyCode key)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			if (Map.TryGetValue(key, out var value))
			{
				return value;
			}
			return null;
		}
	}
	[HarmonyPatch(typeof(FejdStartup), "OnWorldStart")]
	internal class WorldLoadKeybindPatch
	{
		[HarmonyPostfix]
		private static void Postfix()
		{
			if (ZInput.instance != null && ModConfig.IsInitialized)
			{
				Plugin.Log.LogInfo((object)"Forçando re-aplicação de keybinds ao carregar mundo...");
				ModConfig.ApplyAllToZInput(ZInput.instance);
			}
		}
	}
	internal static class ModConfig
	{
		private readonly struct ActionDefault
		{
			public readonly string DisplayName;

			public readonly string InternalName;

			public readonly KeyCode DefaultKey;

			public ActionDefault(string displayName, string internalName, KeyCode defaultKey)
			{
				//IL_000f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0010: Unknown result type (might be due to invalid IL or missing references)
				DisplayName = displayName;
				InternalName = internalName;
				DefaultKey = defaultKey;
			}
		}

		internal enum ConfigAction
		{
			None,
			RestoreDefaults
		}

		private const string ShortcutsSection = "Shortcuts";

		private const string GeneralSection = "General";

		public const int HotbarSlotCount = 8;

		private static ActionDefault[] Actions = new ActionDefault[36]
		{
			new ActionDefault("Forward", "Forward", (KeyCode)119),
			new ActionDefault("Left", "Left", (KeyCode)97),
			new ActionDefault("Backward", "Backward", (KeyCode)115),
			new ActionDefault("Right", "Right", (KeyCode)100),
			new ActionDefault("Attack", "Attack", (KeyCode)323),
			new ActionDefault("Secondary Attack", "SecondaryAttack", (KeyCode)325),
			new ActionDefault("Block", "Block", (KeyCode)324),
			new ActionDefault("Use", "Use", (KeyCode)101),
			new ActionDefault("Hide/Show Weapons", "Hide", (KeyCode)114),
			new ActionDefault("Jump", "Jump", (KeyCode)32),
			new ActionDefault("Crouch", "Crouch", (KeyCode)306),
			new ActionDefault("Run", "Run", (KeyCode)304),
			new ActionDefault("Toggle Walk", "ToggleWalk", (KeyCode)99),
			new ActionDefault("Auto-Run", "AutoRun", (KeyCode)113),
			new ActionDefault("Sit", "Sit", (KeyCode)120),
			new ActionDefault("Forsaken Power", "GP", (KeyCode)102),
			new ActionDefault("Alt Position", "AltPlace", (KeyCode)304),
			new ActionDefault("Inventory", "Inventory", (KeyCode)9),
			new ActionDefault("Map", "Map", (KeyCode)109),
			new ActionDefault("MapZoomOut", "MapZoomOut", (KeyCode)44),
			new ActionDefault("MapZoomIn", "MapZoomIn", (KeyCode)46),
			new ActionDefault("Page Left", "TabLeft", (KeyCode)113),
			new ActionDefault("Page Right", "TabRight", (KeyCode)101),
			new ActionDefault("Build Menu", "BuildMenu", (KeyCode)324),
			new ActionDefault("Remove", "Remove", (KeyCode)325),
			new ActionDefault("Auto Pickup", "AutoPickup", (KeyCode)118),
			new ActionDefault("Console", "Console", (KeyCode)286),
			new ActionDefault("Open Emote", "OpenEmote", (KeyCode)116),
			new ActionDefault("Hotbar1", "Hotbar1", (KeyCode)49),
			new ActionDefault("Hotbar2", "Hotbar2", (KeyCode)50),
			new ActionDefault("Hotbar3", "Hotbar3", (KeyCode)51),
			new ActionDefault("Hotbar4", "Hotbar4", (KeyCode)52),
			new ActionDefault("Hotbar5", "Hotbar5", (KeyCode)53),
			new ActionDefault("Hotbar6", "Hotbar6", (KeyCode)54),
			new ActionDefault("Hotbar7", "Hotbar7", (KeyCode)55),
			new ActionDefault("Hotbar8", "Hotbar8", (KeyCode)56)
		};

		private static Dictionary<string, ConfigEntry<KeyboardShortcut>> _entries;

		private static Dictionary<string, KeyboardShortcut> _previousValues;

		private static bool _isApplyingConflict;

		public static ConfigEntry<bool> CanRepeatShortcut { get; private set; }

		public static bool IsInitialized => _entries != null;

		public static ConfigEntry<bool> ResetToDefaults { get; private set; }

		public static ConfigEntry<ConfigAction> Action { get; private set; }

		public static void Init(ConfigFile config)
		{
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Expected O, but got Unknown
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			CanRepeatShortcut = config.Bind<bool>("General", "Repeat Shortcut:", false, "");
			ConfigurationManagerAttributes configurationManagerAttributes = new ConfigurationManagerAttributes
			{
				CustomDrawer = DrawResetButton,
				Order = -100
			};
			ResetToDefaults = config.Bind<bool>("General", "Restore Defaults:", false, new ConfigDescription("", (AcceptableValueBase)null, new object[1] { configurationManagerAttributes }));
			_entries = new Dictionary<string, ConfigEntry<KeyboardShortcut>>(Actions.Length);
			_previousValues = new Dictionary<string, KeyboardShortcut>(Actions.Length);
			ActionDefault[] actions = Actions;
			for (int i = 0; i < actions.Length; i++)
			{
				ActionDefault actionDefault = actions[i];
				ConfigEntry<KeyboardShortcut> val = config.Bind<KeyboardShortcut>("Shortcuts", actionDefault.DisplayName, new KeyboardShortcut(actionDefault.DefaultKey, Array.Empty<KeyCode>()), (ConfigDescription)null);
				_entries[actionDefault.InternalName] = val;
				_previousValues[actionDefault.InternalName] = val.Value;
			}
			foreach (string item in _entries.Keys.ToList())
			{
				string capturedName = item;
				_entries[capturedName].SettingChanged += delegate
				{
					OnShortcutChanged(capturedName);
				};
			}
		}

		private static void DrawResetButton(ConfigEntryBase entry)
		{
			if (GUILayout.Button("Restore Defaults", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }))
			{
				DoResetToDefaults();
			}
		}

		private static void OnShortcutChanged(string changedName)
		{
			//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_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: 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_00d8: Unknown result type (might be due to invalid IL or missing references)
			if (!_entries.TryGetValue(changedName, out var value))
			{
				return;
			}
			KeyboardShortcut value2 = value.Value;
			_previousValues[changedName] = value2;
			if (!CanRepeatShortcut.Value && (int)((KeyboardShortcut)(ref value2)).MainKey != 0 && !_isApplyingConflict)
			{
				foreach (string item in _entries.Keys.ToList())
				{
					if (item == changedName)
					{
						continue;
					}
					ConfigEntry<KeyboardShortcut> val = _entries[item];
					if (ShortcutsEqual(val.Value, value2))
					{
						Plugin.Log.LogInfo((object)("Conflito de atalho: \"" + item + "\" usava a mesma tecla de \"" + changedName + "\". Limpando \"" + item + "\" (Not Set)."));
						_isApplyingConflict = true;
						try
						{
							val.Value = KeyboardShortcut.Empty;
						}
						finally
						{
							_isApplyingConflict = false;
						}
					}
				}
			}
			ApplyToZInput(changedName);
		}

		private static bool ShortcutsEqual(KeyboardShortcut a, KeyboardShortcut b)
		{
			return ((KeyboardShortcut)(ref a)).Serialize() == ((KeyboardShortcut)(ref b)).Serialize();
		}

		public static void ApplyToZInput(string internalName, ZInput zInput = null)
		{
			//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)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			if (zInput == null)
			{
				zInput = ZInput.instance;
			}
			if (zInput == null || !_entries.TryGetValue(internalName, out var value))
			{
				return;
			}
			KeyboardShortcut value2 = value.Value;
			string text = (((int)((KeyboardShortcut)(ref value2)).MainKey == 0) ? "<Keyboard>/None" : KeyCodePathMap.ToPath(((KeyboardShortcut)(ref value2)).MainKey));
			if (string.IsNullOrEmpty(text))
			{
				Plugin.Log.LogWarning((object)$"Não foi possível mapear a tecla {((KeyboardShortcut)(ref value2)).MainKey} para \"{internalName}\".");
				return;
			}
			ButtonDef buttonDef = zInput.GetButtonDef(internalName);
			if (buttonDef == null)
			{
				Plugin.Log.LogWarning((object)("Ação \"" + internalName + "\" não encontrada no ZInput."));
			}
			else
			{
				buttonDef.Rebind(text);
			}
		}

		public static bool TryGetShortcut(string internalName, out KeyboardShortcut shortcut)
		{
			//IL_0025: 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_001d: Unknown result type (might be due to invalid IL or missing references)
			if (_entries != null && _entries.TryGetValue(internalName, out var value))
			{
				shortcut = value.Value;
				return true;
			}
			shortcut = default(KeyboardShortcut);
			return false;
		}

		public static void ApplyAllToZInput(ZInput zInput = null)
		{
			if (_entries == null)
			{
				return;
			}
			foreach (string key in _entries.Keys)
			{
				ApplyToZInput(key, zInput);
			}
		}

		public static KeyboardShortcut GetShortcut(string actionName)
		{
			//IL_001d: 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)
			if (_entries != null && _entries.TryGetValue(actionName, out var value))
			{
				return value.Value;
			}
			return KeyboardShortcut.Empty;
		}

		public static string GetShortcutDisplayName(string internalName, bool richText = false)
		{
			//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_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			KeyboardShortcut shortcut = GetShortcut(internalName);
			if ((int)((KeyboardShortcut)(ref shortcut)).MainKey == 0)
			{
				return "-";
			}
			List<string> list = new List<string>();
			foreach (KeyCode item2 in ((KeyboardShortcut)(ref shortcut)).Modifiers ?? Enumerable.Empty<KeyCode>())
			{
				string text = KeyCodeToShortLabel(item2);
				if (richText)
				{
					text = "<size=75%>" + text + "</size>";
				}
				list.Add(text);
			}
			string item = KeyCodeToShortLabel(((KeyboardShortcut)(ref shortcut)).MainKey);
			list.Add(item);
			return string.Join("+", list);
		}

		private unsafe static string KeyCodeToShortLabel(KeyCode key)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Invalid comparison between Unknown and I4
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Invalid comparison between Unknown and I4
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Invalid comparison between Unknown and I4
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Expected I4, but got Unknown
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Invalid comparison between Unknown and I4
			//IL_000a: 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: Expected I4, but got Unknown
			if ((int)key >= 48 && (int)key <= 57)
			{
				return (key - 48).ToString();
			}
			if ((int)key >= 97 && (int)key <= 122)
			{
				return ((object)(*(KeyCode*)(&key))/*cast due to .constrained prefix*/).ToString();
			}
			return (key - 323) switch
			{
				0 => "Mouse Esq", 
				1 => "Mouse Dir", 
				2 => "Mouse Meio", 
				_ => ((object)(*(KeyCode*)(&key))/*cast due to .constrained prefix*/).ToString(), 
			};
		}

		private static void DoResetToDefaults()
		{
			//IL_004e: 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)
			Plugin.Log.LogInfo((object)"Resetando todos os atalhos para os valores padrão...");
			bool value = CanRepeatShortcut.Value;
			CanRepeatShortcut.Value = true;
			ActionDefault[] actions = Actions;
			for (int i = 0; i < actions.Length; i++)
			{
				ActionDefault actionDefault = actions[i];
				if (_entries.TryGetValue(actionDefault.InternalName, out var value2))
				{
					value2.Value = new KeyboardShortcut(actionDefault.DefaultKey, Array.Empty<KeyCode>());
				}
			}
			CanRepeatShortcut.Value = value;
			Plugin.Log.LogInfo((object)"Reset concluído.");
		}
	}
	[HarmonyPatch(typeof(ZInput))]
	internal static class ModifierGatePatch
	{
		[HarmonyPatch("GetButtonDown", new Type[] { typeof(string) })]
		[HarmonyPostfix]
		private static void PostfixDown(string name, ref bool __result)
		{
			Gate(name, ref __result);
		}

		[HarmonyPatch("GetButton", new Type[] { typeof(string) })]
		[HarmonyPostfix]
		private static void PostfixHeld(string name, ref bool __result)
		{
			Gate(name, ref __result);
		}

		[HarmonyPatch("GetButtonUp", new Type[] { typeof(string) })]
		[HarmonyPostfix]
		private static void PostfixUp(string name, ref bool __result)
		{
			Gate(name, ref __result);
		}

		private static void Gate(string name, ref bool result)
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			if (!result || !ModConfig.IsInitialized || !ModConfig.TryGetShortcut(name, out var shortcut))
			{
				return;
			}
			IEnumerable<KeyCode> modifiers = ((KeyboardShortcut)(ref shortcut)).Modifiers;
			if (modifiers == null || !modifiers.Any())
			{
				return;
			}
			foreach (KeyCode item in modifiers)
			{
				if (!Input.GetKey(item))
				{
					result = false;
					break;
				}
			}
		}
	}
	[BepInPlugin("hz.FixedKeybinds", "HZ_FixedKeybinds", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		public const string ModGuid = "hz.FixedKeybinds";

		public const string ModName = "HZ_FixedKeybinds";

		public const string ModVersion = "1.0.0";

		internal static Plugin Instance { get; private set; }

		internal static Harmony Harmony { get; private set; }

		internal static ManualLogSource Log => ((BaseUnityPlugin)Instance).Logger;

		private void Awake()
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Expected O, but got Unknown
			Instance = this;
			ModConfig.Init(((BaseUnityPlugin)this).Config);
			Harmony = new Harmony("hz.FixedKeybinds");
			Harmony.PatchAll();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"HZ_FixedKeybinds 1.0.0 loaded.");
		}

		private void OnDestroy()
		{
			Harmony harmony = Harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
		}
	}
	[HarmonyPatch(typeof(Settings), "Awake")]
	internal class HideKeyboardMouseTabPatch
	{
		[HarmonyPrefix]
		private static void Prefix(Settings __instance)
		{
			TabHandler componentInChildren = ((Component)__instance).GetComponentInChildren<TabHandler>();
			if ((Object)(object)componentInChildren == (Object)null)
			{
				return;
			}
			for (int num = componentInChildren.m_tabs.Count - 1; num >= 0; num--)
			{
				Tab val = componentInChildren.m_tabs[num];
				string text = (((Object)(object)val.m_page != (Object)null) ? ((Object)val.m_page).name : "");
				if (text.Contains("KeyboardMouse", StringComparison.OrdinalIgnoreCase))
				{
					Plugin.Log.LogInfo((object)$"Removendo aba \"{text}\" (índice {num}) do menu de configurações.");
					if ((Object)(object)val.m_button != (Object)null)
					{
						((Component)val.m_button).gameObject.SetActive(false);
					}
					if ((Object)(object)val.m_page != (Object)null)
					{
						((Component)val.m_page).gameObject.SetActive(false);
					}
					componentInChildren.m_tabs.RemoveAt(num);
					break;
				}
			}
		}
	}
	[HarmonyPatch(typeof(ZInput), "Reset")]
	internal class ZInputResetPatch
	{
		[HarmonyPostfix]
		private static void Postfix(ZInput __instance)
		{
			ModConfig.ApplyAllToZInput(__instance);
		}
	}
}