Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of Shortcuts v1.8.0
Shortcuts.dll
Decompiled 7 months agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using ComfyLib; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.InputSystem; using UnityEngine.InputSystem.Controls; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("Shortcuts")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("Shortcuts")] [assembly: AssemblyCopyright("Copyright © 2022")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("149d97c3-4482-49c6-ab51-74f0164d425a")] [assembly: AssemblyFileVersion("1.8.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.8.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.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace Shortcuts { public static class PluginConfig { public static ConfigFile CurrentConfig { get; private set; } public static ConfigEntry<bool> IsModEnabled { get; private set; } public static ShortcutConfigEntry ToggleConsoleShortcut { get; private set; } public static ShortcutConfigEntry ToggleHudShortcut { get; private set; } public static ShortcutConfigEntry ToggleConnectPanelShortcut { get; private set; } public static ShortcutConfigEntry TakeScreenshotShortcut { get; private set; } public static ShortcutConfigEntry ToggleMouseCaptureShortcut { get; private set; } public static ShortcutConfigEntry ToggleDebugFlyShortcut { get; private set; } public static ShortcutConfigEntry ToggleDebugNoCostShortcut { get; private set; } public static ShortcutConfigEntry DebugKillAllShortcut { get; private set; } public static ShortcutConfigEntry DebugRemoveDropsShortcut { get; private set; } public static ShortcutConfigEntry HotbarItem1Shortcut { get; private set; } public static ShortcutConfigEntry HotbarItem2Shortcut { get; private set; } public static ShortcutConfigEntry HotbarItem3Shortcut { get; private set; } public static ShortcutConfigEntry HotbarItem4Shortcut { get; private set; } public static ShortcutConfigEntry HotbarItem5Shortcut { get; private set; } public static ShortcutConfigEntry HotbarItem6Shortcut { get; private set; } public static ShortcutConfigEntry HotbarItem7Shortcut { get; private set; } public static ShortcutConfigEntry HotbarItem8Shortcut { get; private set; } public static void BindConfig(ConfigFile config) { CurrentConfig = config; IsModEnabled = config.BindInOrder("_Global", "isModEnabled", defaultValue: true, "Globally enable or disable this mod (restart required)."); } public static void BindShortcutConfig(ConfigFile config) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01ea: Unknown result type (might be due to invalid IL or missing references) //IL_021b: Unknown result type (might be due to invalid IL or missing references) //IL_024c: Unknown result type (might be due to invalid IL or missing references) //IL_027d: Unknown result type (might be due to invalid IL or missing references) //IL_02ae: Unknown result type (might be due to invalid IL or missing references) //IL_02df: Unknown result type (might be due to invalid IL or missing references) //IL_0310: Unknown result type (might be due to invalid IL or missing references) //IL_0341: Unknown result type (might be due to invalid IL or missing references) ToggleConsoleShortcut = new ShortcutConfigEntry(config.BindInOrder<KeyboardShortcut>("Console", "toggleConsoleShortcut", new KeyboardShortcut((KeyCode)286, Array.Empty<KeyCode>()), "Shortcut to toggle the Console on/off.")); ToggleHudShortcut = new ShortcutConfigEntry(config.BindInOrder<KeyboardShortcut>("Hud", "toggleHudShortcut", new KeyboardShortcut((KeyCode)284, (KeyCode[])(object)new KeyCode[1] { (KeyCode)306 }), "Shortcut to toggle the Hud on/off.")); ToggleConnectPanelShortcut = new ShortcutConfigEntry(config.BindInOrder<KeyboardShortcut>("ConnectPanel", "toggleConnectPanelShortcut", new KeyboardShortcut((KeyCode)283, Array.Empty<KeyCode>()), "Shortcut to toggle the ConnectPanel on/off.")); TakeScreenshotShortcut = new ShortcutConfigEntry(config.BindInOrder<KeyboardShortcut>("GameCamera", "takeScreenshotShortcut", new KeyboardShortcut((KeyCode)292, Array.Empty<KeyCode>()), "Shortcut to take a screenshot.")); ToggleMouseCaptureShortcut = new ShortcutConfigEntry(config.BindInOrder<KeyboardShortcut>("GameCamera", "toggleMouseCaptureShortcut", new KeyboardShortcut((KeyCode)282, (KeyCode[])(object)new KeyCode[1] { (KeyCode)306 }), "Shortcut to toggle mouse capture from the GameCamera.")); ToggleDebugFlyShortcut = new ShortcutConfigEntry(config.BindInOrder<KeyboardShortcut>("Debugmode", "toggleDebugFlyShortcut", new KeyboardShortcut((KeyCode)122, Array.Empty<KeyCode>()), "Shortcut to toggle flying when in debugmode.")); ToggleDebugNoCostShortcut = new ShortcutConfigEntry(config.BindInOrder<KeyboardShortcut>("Debugmode", "toggleDebugNoCostShortcut", new KeyboardShortcut((KeyCode)98, Array.Empty<KeyCode>()), "Shortcut to toggle no-cost building when in debugmode.")); DebugKillAllShortcut = new ShortcutConfigEntry(config.BindInOrder<KeyboardShortcut>("Debugmode", "debugKillAllShortcut", new KeyboardShortcut((KeyCode)0, Array.Empty<KeyCode>()), "Shortcut to kill/damage all mobs around player. Unbound by default.")); DebugRemoveDropsShortcut = new ShortcutConfigEntry(config.BindInOrder<KeyboardShortcut>("Debugmode", "debugRemoveDropsShortcut", new KeyboardShortcut((KeyCode)0, Array.Empty<KeyCode>()), "Shortcut to 'removedrops' command. Unbound by default.")); HotbarItem1Shortcut = new ShortcutConfigEntry(config.BindInOrder<KeyboardShortcut>("Hotbar", "hotbarItem1Shortcut", new KeyboardShortcut((KeyCode)49, Array.Empty<KeyCode>()), "Shortcut for the first slot in the Hotbar.")); HotbarItem2Shortcut = new ShortcutConfigEntry(config.BindInOrder<KeyboardShortcut>("Hotbar", "hotbarItem2Shortcut", new KeyboardShortcut((KeyCode)50, Array.Empty<KeyCode>()), "Shortcut for the second slot in the Hotbar.")); HotbarItem3Shortcut = new ShortcutConfigEntry(config.BindInOrder<KeyboardShortcut>("Hotbar", "hotbarItem3Shortcut", new KeyboardShortcut((KeyCode)51, Array.Empty<KeyCode>()), "Shortcut for the third slot in the Hotbar.")); HotbarItem4Shortcut = new ShortcutConfigEntry(config.BindInOrder<KeyboardShortcut>("Hotbar", "hotbarItem4Shortcut", new KeyboardShortcut((KeyCode)52, Array.Empty<KeyCode>()), "Shortcut for the fourth slot in the Hotbar.")); HotbarItem5Shortcut = new ShortcutConfigEntry(config.BindInOrder<KeyboardShortcut>("Hotbar", "hotbarItem5Shortcut", new KeyboardShortcut((KeyCode)53, Array.Empty<KeyCode>()), "Shortcut for the fifth slot in the Hotbar.")); HotbarItem6Shortcut = new ShortcutConfigEntry(config.BindInOrder<KeyboardShortcut>("Hotbar", "hotbarItem6Shortcut", new KeyboardShortcut((KeyCode)54, Array.Empty<KeyCode>()), "Shortcut for the sixth slot in the Hotbar.")); HotbarItem7Shortcut = new ShortcutConfigEntry(config.BindInOrder<KeyboardShortcut>("Hotbar", "hotbarItem7Shortcut", new KeyboardShortcut((KeyCode)55, Array.Empty<KeyCode>()), "Shortcut for the seventh slot in the Hotbar.")); HotbarItem8Shortcut = new ShortcutConfigEntry(config.BindInOrder<KeyboardShortcut>("Hotbar", "hotbarItem8Shortcut", new KeyboardShortcut((KeyCode)56, Array.Empty<KeyCode>()), "Shortcut for the eight slot in the Hotbar.")); } } public sealed class ShortcutConfigEntry { public readonly ConfigEntry<KeyboardShortcut> BaseConfigEntry; private KeyboardShortcut _shortcut = KeyboardShortcut.Empty; private KeyCode _mainKey; private KeyCode[] _modifierKeys = Array.Empty<KeyCode>(); private int _modifierKeyCount; private ButtonControl _mainKeyControl; private ButtonControl[] _modifierKeyControls = Array.Empty<ButtonControl>(); public ShortcutConfigEntry(ConfigEntry<KeyboardShortcut> configEntry) { //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_004c: Unknown result type (might be due to invalid IL or missing references) BaseConfigEntry = configEntry; BaseConfigEntry.SettingChanged += OnSettingChanged; SetShortcut(BaseConfigEntry.Value); } private void OnSettingChanged(object sender, EventArgs eventArgs) { //IL_0002: 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) SetShortcut(((ConfigEntry<KeyboardShortcut>)(object)((SettingChangedEventArgs)eventArgs).ChangedSetting).Value); } public void SetShortcut(KeyboardShortcut shortcut) { //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_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_003e: Unknown result type (might be due to invalid IL or missing references) _shortcut = shortcut; _mainKey = ((KeyboardShortcut)(ref _shortcut)).MainKey; _modifierKeys = ((KeyboardShortcut)(ref _shortcut)).Modifiers.ToArray(); _modifierKeyCount = _modifierKeys.Length; _mainKeyControl = GetButtonControl(_mainKey); _modifierKeyControls = (ButtonControl[])((_modifierKeyCount > 0) ? ((Array)new ButtonControl[_modifierKeyCount]) : ((Array)Array.Empty<ButtonControl>())); for (int i = 0; i < _modifierKeyCount; i++) { _modifierKeyControls[i] = GetButtonControl(_modifierKeys[i]); } } public static ButtonControl GetButtonControl(KeyCode keyCode) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown return (ButtonControl)InputSystem.FindControl(ZInput.KeyCodeToPath(keyCode, false)); } public bool IsKeyDown() { if (_mainKeyControl == null || !_mainKeyControl.wasPressedThisFrame) { return false; } if (_modifierKeyCount > 0) { for (int i = 0; i < _modifierKeyCount; i++) { if (!_modifierKeyControls[i].isPressed) { return false; } } } return true; } } public static class CodeMatcherExtensions { public static readonly CodeMatch ZInputGetButtonDown = new CodeMatch((OpCode?)OpCodes.Call, (object)AccessTools.Method(typeof(ZInput), "GetButtonDown", new Type[1] { typeof(string) }, (Type[])null), (string)null); public static readonly CodeMatch ZInputGetKeyDownMatch = new CodeMatch((OpCode?)OpCodes.Call, (object)AccessTools.Method(typeof(ZInput), "GetKeyDown", new Type[2] { typeof(KeyCode), typeof(bool) }, (Type[])null), (string)null); public static readonly CodeMatch ZInputGetKeyMatch = new CodeMatch((OpCode?)OpCodes.Call, (object)AccessTools.Method(typeof(ZInput), "GetKey", new Type[2] { typeof(KeyCode), typeof(bool) }, (Type[])null), (string)null); public static CodeMatcher MatchGetButtonDown(this CodeMatcher matcher, string keyName) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown return matcher.MatchStartForward((CodeMatch[])(object)new CodeMatch[2] { new CodeMatch((OpCode?)OpCodes.Ldstr, (object)keyName, (string)null), ZInputGetButtonDown }).ThrowIfInvalid("Could not patch ZInput.GetButtonDown() for Key: " + keyName).Advance(1); } public static CodeMatcher MatchGetKeyDown(this CodeMatcher matcher, int key) { //IL_003c: 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_0042: Expected O, but got Unknown //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Expected O, but got Unknown return matcher.MatchStartForward((CodeMatch[])(object)new CodeMatch[3] { (key > 127) ? new CodeMatch((OpCode?)OpCodes.Ldc_I4, (object)key, (string)null) : new CodeMatch((OpCode?)OpCodes.Ldc_I4_S, (object)Convert.ToSByte(key), (string)null), new CodeMatch((OpCode?)OpCodes.Ldc_I4_1, (object)null, (string)null), ZInputGetKeyDownMatch }).ThrowIfInvalid($"Could not patch ZInput.GetKeyDown() for Key: {key}!").Advance(2); } public static CodeMatcher MatchGetKey(this CodeMatcher matcher, int key) { //IL_003c: 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_0042: Expected O, but got Unknown //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Expected O, but got Unknown return matcher.MatchStartForward((CodeMatch[])(object)new CodeMatch[3] { (key > 127) ? new CodeMatch((OpCode?)OpCodes.Ldc_I4, (object)key, (string)null) : new CodeMatch((OpCode?)OpCodes.Ldc_I4_S, (object)Convert.ToSByte(key), (string)null), new CodeMatch((OpCode?)OpCodes.Ldc_I4_1, (object)null, (string)null), ZInputGetKeyMatch }).ThrowIfInvalid($"Could not patch ZInput.GetKey() for Key: {key}!").Advance(2); } } [HarmonyPatch(typeof(ConnectPanel))] internal static class ConnectPanelPatch { [HarmonyTranspiler] [HarmonyPatch("Update")] private static IEnumerable<CodeInstruction> UpdateTranspiler(IEnumerable<CodeInstruction> instructions) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown return CodeMatcherExtensions.MatchGetKeyDown(new CodeMatcher(instructions, (ILGenerator)null), 283).SetInstructionAndAdvance(new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(ConnectPanelPatch), "ToggleConnectPanelDelegate", (Type[])null, (Type[])null))).InstructionEnumeration(); } private static bool ToggleConnectPanelDelegate(KeyCode key, bool logWarning) { return PluginConfig.ToggleConnectPanelShortcut.IsKeyDown(); } } [HarmonyPatch(typeof(Console))] internal static class ConsolePatch { [HarmonyTranspiler] [HarmonyPatch("Update")] private static IEnumerable<CodeInstruction> UpdateTranspiler(IEnumerable<CodeInstruction> instructions) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown return CodeMatcherExtensions.MatchGetButtonDown(new CodeMatcher(instructions, (ILGenerator)null), "Console").SetInstructionAndAdvance(new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(ConsolePatch), "ToggleConsoleDelgate", (Type[])null, (Type[])null))).InstructionEnumeration(); } private static bool ToggleConsoleDelgate(string name) { return PluginConfig.ToggleConsoleShortcut.IsKeyDown(); } } [HarmonyPatch(typeof(FejdStartup))] internal static class FejdStartupPatch { [HarmonyTranspiler] [HarmonyPatch("LateUpdate")] private static IEnumerable<CodeInstruction> LateUpdateTranspiler(IEnumerable<CodeInstruction> instructions) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown return CodeMatcherExtensions.MatchGetKeyDown(new CodeMatcher(instructions, (ILGenerator)null), 292).SetInstructionAndAdvance(new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(FejdStartupPatch), "TakeScreenshotDelegate", (Type[])null, (Type[])null))).InstructionEnumeration(); } private static bool TakeScreenshotDelegate(KeyCode key, bool logWarning) { return PluginConfig.TakeScreenshotShortcut.IsKeyDown(); } } [HarmonyPatch(typeof(GameCamera))] internal static class GameCameraPatch { [HarmonyTranspiler] [HarmonyPatch("LateUpdate")] private static IEnumerable<CodeInstruction> LateUpdateTranspiler(IEnumerable<CodeInstruction> instructions) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown return CodeMatcherExtensions.MatchGetKeyDown(new CodeMatcher(instructions, (ILGenerator)null), 292).SetInstructionAndAdvance(new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(GameCameraPatch), "TakeScreenshotDelegate", (Type[])null, (Type[])null))).InstructionEnumeration(); } private static bool TakeScreenshotDelegate(KeyCode key, bool logWarning) { return PluginConfig.TakeScreenshotShortcut.IsKeyDown(); } [HarmonyTranspiler] [HarmonyPatch("UpdateMouseCapture")] private static IEnumerable<CodeInstruction> UpdateMouseCaptureTranspiler(IEnumerable<CodeInstruction> instructions) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Expected O, but got Unknown return CodeMatcherExtensions.MatchGetKey(new CodeMatcher(instructions, (ILGenerator)null), 306).SetInstructionAndAdvance(new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(GameCameraPatch), "IgnoreKeyDelegate", (Type[])null, (Type[])null))).MatchGetKeyDown(282) .SetInstructionAndAdvance(new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(GameCameraPatch), "ToggleMouseCaptureDelegate", (Type[])null, (Type[])null))) .InstructionEnumeration(); } private static bool ToggleMouseCaptureDelegate(KeyCode key, bool logWarning) { return PluginConfig.ToggleMouseCaptureShortcut.IsKeyDown(); } private static bool IgnoreKeyDelegate(KeyCode key, bool logWarning) { return true; } } [HarmonyPatch(typeof(Hud))] internal static class HudPatch { [HarmonyTranspiler] [HarmonyPatch("Update")] private static IEnumerable<CodeInstruction> UpdateTranspiler(IEnumerable<CodeInstruction> instructions) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Expected O, but got Unknown return CodeMatcherExtensions.MatchGetKeyDown(new CodeMatcher(instructions, (ILGenerator)null), 284).SetInstructionAndAdvance(new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(HudPatch), "ToggleHudDelegate", (Type[])null, (Type[])null))).MatchGetKey(306) .SetInstructionAndAdvance(new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(HudPatch), "IgnoreKeyDelegate", (Type[])null, (Type[])null))) .InstructionEnumeration(); } private static bool ToggleHudDelegate(KeyCode key, bool logWarning) { return PluginConfig.ToggleHudShortcut.IsKeyDown(); } private static bool IgnoreKeyDelegate(KeyCode key, bool logWarning) { return true; } } [HarmonyPatch(typeof(Player))] internal static class PlayerPatch { [HarmonyTranspiler] [HarmonyPatch("Update")] private static IEnumerable<CodeInstruction> UpdateTranspiler(IEnumerable<CodeInstruction> instructions) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Expected O, but got Unknown //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Expected O, but got Unknown //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Expected O, but got Unknown //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Expected O, but got Unknown //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Expected O, but got Unknown //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Expected O, but got Unknown //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Expected O, but got Unknown //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Expected O, but got Unknown //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Expected O, but got Unknown //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Expected O, but got Unknown //IL_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: Expected O, but got Unknown //IL_01f6: Unknown result type (might be due to invalid IL or missing references) //IL_0200: Expected O, but got Unknown //IL_0225: Unknown result type (might be due to invalid IL or missing references) //IL_022f: Expected O, but got Unknown return CodeMatcherExtensions.MatchGetKeyDown(new CodeMatcher(instructions, (ILGenerator)null), 122).SetInstructionAndAdvance(new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(PlayerPatch), "ToggleDebugFlyDelegate", (Type[])null, (Type[])null))).MatchGetKeyDown(98) .SetInstructionAndAdvance(new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(PlayerPatch), "ToggleDebugNoCostDelegate", (Type[])null, (Type[])null))) .MatchGetKeyDown(107) .SetInstructionAndAdvance(new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(PlayerPatch), "DebugKillAllDelegate", (Type[])null, (Type[])null))) .MatchGetKeyDown(108) .SetInstructionAndAdvance(new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(PlayerPatch), "DebugRemoveDropsDelegate", (Type[])null, (Type[])null))) .MatchGetButtonDown("Hotbar1") .SetInstructionAndAdvance(new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(PlayerPatch), "HotbarItem1Delegate", (Type[])null, (Type[])null))) .MatchGetButtonDown("Hotbar2") .SetInstructionAndAdvance(new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(PlayerPatch), "HotbarItem2Delegate", (Type[])null, (Type[])null))) .MatchGetButtonDown("Hotbar3") .SetInstructionAndAdvance(new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(PlayerPatch), "HotbarItem3Delegate", (Type[])null, (Type[])null))) .MatchGetButtonDown("Hotbar4") .SetInstructionAndAdvance(new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(PlayerPatch), "HotbarItem4Delegate", (Type[])null, (Type[])null))) .MatchGetButtonDown("Hotbar5") .SetInstructionAndAdvance(new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(PlayerPatch), "HotbarItem5Delegate", (Type[])null, (Type[])null))) .MatchGetButtonDown("Hotbar6") .SetInstructionAndAdvance(new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(PlayerPatch), "HotbarItem6Delegate", (Type[])null, (Type[])null))) .MatchGetButtonDown("Hotbar7") .SetInstructionAndAdvance(new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(PlayerPatch), "HotbarItem7Delegate", (Type[])null, (Type[])null))) .MatchGetButtonDown("Hotbar8") .SetInstructionAndAdvance(new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(PlayerPatch), "HotbarItem8Delegate", (Type[])null, (Type[])null))) .InstructionEnumeration(); } private static bool ToggleDebugFlyDelegate(KeyCode key, bool logWarning) { return PluginConfig.ToggleDebugFlyShortcut.IsKeyDown(); } private static bool ToggleDebugNoCostDelegate(KeyCode key, bool logWarning) { return PluginConfig.ToggleDebugNoCostShortcut.IsKeyDown(); } private static bool DebugKillAllDelegate(KeyCode key, bool logWarning) { return PluginConfig.DebugKillAllShortcut.IsKeyDown(); } private static bool DebugRemoveDropsDelegate(KeyCode key, bool logWarning) { return PluginConfig.DebugRemoveDropsShortcut.IsKeyDown(); } private static bool HotbarItem1Delegate(string name) { return PluginConfig.HotbarItem1Shortcut.IsKeyDown(); } private static bool HotbarItem2Delegate(string name) { return PluginConfig.HotbarItem2Shortcut.IsKeyDown(); } private static bool HotbarItem3Delegate(string name) { return PluginConfig.HotbarItem3Shortcut.IsKeyDown(); } private static bool HotbarItem4Delegate(string name) { return PluginConfig.HotbarItem4Shortcut.IsKeyDown(); } private static bool HotbarItem5Delegate(string name) { return PluginConfig.HotbarItem5Shortcut.IsKeyDown(); } private static bool HotbarItem6Delegate(string name) { return PluginConfig.HotbarItem6Shortcut.IsKeyDown(); } private static bool HotbarItem7Delegate(string name) { return PluginConfig.HotbarItem7Shortcut.IsKeyDown(); } private static bool HotbarItem8Delegate(string name) { return PluginConfig.HotbarItem8Shortcut.IsKeyDown(); } } [HarmonyPatch(typeof(ZInput))] internal static class ZInputPatch { [HarmonyPostfix] [HarmonyPatch(/*Could not decode attribute arguments.*/)] private static void ConstructorPatch() { if (PluginConfig.IsModEnabled.Value) { PluginConfig.BindShortcutConfig(PluginConfig.CurrentConfig); } } } [BepInPlugin("redseiko.valheim.shortcuts", "Shortcuts", "1.8.0")] public sealed class Shortcuts : BaseUnityPlugin { public const string PluginGUID = "redseiko.valheim.shortcuts"; public const string PluginName = "Shortcuts"; public const string PluginVersion = "1.8.0"; private void Awake() { PluginConfig.BindConfig(((BaseUnityPlugin)this).Config); if (PluginConfig.IsModEnabled.Value) { Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "redseiko.valheim.shortcuts"); } } } } namespace ComfyLib { public static class ConfigFileExtensions { internal sealed class ConfigurationManagerAttributes { public Action<ConfigEntryBase> CustomDrawer; public bool? Browsable; public bool? HideDefaultButton; public bool? HideSettingName; public bool? IsAdvanced; public int? Order; public bool? ReadOnly; } private static readonly Dictionary<string, int> _sectionToSettingOrder = new Dictionary<string, int>(); private static int GetSettingOrder(string section) { if (!_sectionToSettingOrder.TryGetValue(section, out var value)) { value = 0; } _sectionToSettingOrder[section] = value - 1; return value; } public static ConfigEntry<T> BindInOrder<T>(this ConfigFile config, string section, string key, T defaultValue, string description, AcceptableValueBase acceptableValues, bool browsable = true, bool hideDefaultButton = false, bool hideSettingName = false, bool isAdvanced = false, bool readOnly = false) { //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Expected O, but got Unknown return config.Bind<T>(section, key, defaultValue, new ConfigDescription(description, acceptableValues, new object[1] { new ConfigurationManagerAttributes { Browsable = browsable, CustomDrawer = null, HideDefaultButton = hideDefaultButton, HideSettingName = hideSettingName, IsAdvanced = isAdvanced, Order = GetSettingOrder(section), ReadOnly = readOnly } })); } public static ConfigEntry<T> BindInOrder<T>(this ConfigFile config, string section, string key, T defaultValue, string description, Action<ConfigEntryBase> customDrawer = null, bool browsable = true, bool hideDefaultButton = false, bool hideSettingName = false, bool isAdvanced = false, bool readOnly = false) { //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Expected O, but got Unknown return config.Bind<T>(section, key, defaultValue, new ConfigDescription(description, (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Browsable = browsable, CustomDrawer = customDrawer, HideDefaultButton = hideDefaultButton, HideSettingName = hideSettingName, IsAdvanced = isAdvanced, Order = GetSettingOrder(section), ReadOnly = readOnly } })); } public static void OnSettingChanged<T>(this ConfigEntry<T> configEntry, Action settingChangedHandler) { configEntry.SettingChanged += delegate { settingChangedHandler(); }; } public static void OnSettingChanged<T>(this ConfigEntry<T> configEntry, Action<T> settingChangedHandler) { configEntry.SettingChanged += delegate(object _, EventArgs eventArgs) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) settingChangedHandler((T)((SettingChangedEventArgs)eventArgs).ChangedSetting.BoxedValue); }; } public static void OnSettingChanged<T>(this ConfigEntry<T> configEntry, Action<ConfigEntry<T>> settingChangedHandler) { configEntry.SettingChanged += delegate(object _, EventArgs eventArgs) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) settingChangedHandler((ConfigEntry<T>)((SettingChangedEventArgs)eventArgs).ChangedSetting.BoxedValue); }; } } }