Decompiled source of MegabonkInput v1.0.0

MegabonkInput.dll

Decompiled 2 months ago
using System;
using System.CodeDom.Compiler;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using Assets.Scripts.Actors.Player;
using BepInEx;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using BepInEx.Unity.IL2CPP.Utils.Collections;
using HarmonyLib;
using Il2CppInterop.Runtime;
using Il2CppInterop.Runtime.Injection;
using Microsoft.CodeAnalysis;
using UnityEngine;
using Windows.Win32;
using Windows.Win32.Foundation;
using Windows.Win32.UI.WindowsAndMessaging;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("MegabonkInput")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+bb99ad1237fad731e0f306eb47d6d96336f49b75")]
[assembly: AssemblyProduct("MegabonkInput")]
[assembly: AssemblyTitle("MegabonkInput")]
[assembly: AssemblyMetadata("Microsoft.Windows.CsWin32", "0.3.205+c676a8cdc6.RR")]
[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 NativeIntegerAttribute : Attribute
	{
		public readonly bool[] TransformFlags;

		public NativeIntegerAttribute()
		{
			TransformFlags = new bool[1] { true };
		}

		public NativeIntegerAttribute(bool[] P_0)
		{
			TransformFlags = 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 Windows.Win32
{
	[GeneratedCode("Microsoft.Windows.CsWin32", "0.3.205+c676a8cdc6.RR")]
	internal static class PInvoke
	{
		[DllImport("KERNEL32.dll", ExactSpelling = true, SetLastError = true)]
		[DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
		[SupportedOSPlatform("windows5.0")]
		internal static extern BOOL CloseHandle(HANDLE hObject);

		[DllImport("KERNEL32.dll", ExactSpelling = true)]
		[DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
		[SupportedOSPlatform("windows5.1.2600")]
		internal static extern uint GetCurrentProcessId();

		[DllImport("USER32.dll", ExactSpelling = true, SetLastError = true)]
		[DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
		[SupportedOSPlatform("windows5.0")]
		internal static extern BOOL EnumWindows([MarshalAs(UnmanagedType.FunctionPtr)] WNDENUMPROC lpEnumFunc, LPARAM lParam);

		[DllImport("USER32.dll", ExactSpelling = true)]
		[DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
		[SupportedOSPlatform("windows5.0")]
		internal unsafe static extern uint GetWindowThreadProcessId(HWND hWnd, [Optional] uint* lpdwProcessId);

		[DllImport("USER32.dll", EntryPoint = "SetWindowLongPtrW", ExactSpelling = true, SetLastError = true)]
		[DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
		[SupportedOSPlatform("windows5.0")]
		internal static extern nint SetWindowLongPtr(HWND hWnd, WINDOW_LONG_PTR_INDEX nIndex, nint dwNewLong);

		[DllImport("USER32.dll", EntryPoint = "CallWindowProcW", ExactSpelling = true)]
		[DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
		[SupportedOSPlatform("windows5.0")]
		internal static extern LRESULT CallWindowProc([MarshalAs(UnmanagedType.FunctionPtr)] WNDPROC lpPrevWndFunc, HWND hWnd, uint Msg, WPARAM wParam, LPARAM lParam);

		[SupportedOSPlatform("windows5.0")]
		internal unsafe static int GetWindowText(HWND hWnd, Span<char> lpString)
		{
			fixed (char* ptr = lpString)
			{
				return GetWindowText(hWnd, ptr, lpString.Length);
			}
		}

		[DllImport("USER32.dll", EntryPoint = "GetWindowTextW", ExactSpelling = true, SetLastError = true)]
		[DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
		[SupportedOSPlatform("windows5.0")]
		internal static extern int GetWindowText(HWND hWnd, PWSTR lpString, int nMaxCount);

		[SupportedOSPlatform("windows5.0")]
		internal unsafe static int GetClassName(HWND hWnd, Span<char> lpClassName)
		{
			fixed (char* ptr = lpClassName)
			{
				return GetClassName(hWnd, ptr, lpClassName.Length);
			}
		}

		[DllImport("USER32.dll", EntryPoint = "GetClassNameW", ExactSpelling = true, SetLastError = true)]
		[DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
		[SupportedOSPlatform("windows5.0")]
		internal static extern int GetClassName(HWND hWnd, PWSTR lpClassName, int nMaxCount);

		[DllImport("USER32.dll", EntryPoint = "DefWindowProcW", ExactSpelling = true)]
		[DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
		[SupportedOSPlatform("windows5.0")]
		internal static extern LRESULT DefWindowProc(HWND hWnd, uint Msg, WPARAM wParam, LPARAM lParam);
	}
}
namespace Windows.Win32.UI.Input.KeyboardAndMouse
{
	[GeneratedCode("Microsoft.Windows.CsWin32", "0.3.205+c676a8cdc6.RR")]
	internal enum VIRTUAL_KEY : ushort
	{
		VK_0 = 48,
		VK_1 = 49,
		VK_2 = 50,
		VK_3 = 51,
		VK_4 = 52,
		VK_5 = 53,
		VK_6 = 54,
		VK_7 = 55,
		VK_8 = 56,
		VK_9 = 57,
		VK_A = 65,
		VK_B = 66,
		VK_C = 67,
		VK_D = 68,
		VK_E = 69,
		VK_F = 70,
		VK_G = 71,
		VK_H = 72,
		VK_I = 73,
		VK_J = 74,
		VK_K = 75,
		VK_L = 76,
		VK_M = 77,
		VK_N = 78,
		VK_O = 79,
		VK_P = 80,
		VK_Q = 81,
		VK_R = 82,
		VK_S = 83,
		VK_T = 84,
		VK_U = 85,
		VK_V = 86,
		VK_W = 87,
		VK_X = 88,
		VK_Y = 89,
		VK_Z = 90,
		VK_ABNT_C1 = 193,
		VK_ABNT_C2 = 194,
		VK_DBE_ALPHANUMERIC = 240,
		VK_DBE_CODEINPUT = 250,
		VK_DBE_DBCSCHAR = 244,
		VK_DBE_DETERMINESTRING = 252,
		VK_DBE_ENTERDLGCONVERSIONMODE = 253,
		VK_DBE_ENTERIMECONFIGMODE = 248,
		VK_DBE_ENTERWORDREGISTERMODE = 247,
		VK_DBE_FLUSHSTRING = 249,
		VK_DBE_HIRAGANA = 242,
		VK_DBE_KATAKANA = 241,
		VK_DBE_NOCODEINPUT = 251,
		VK_DBE_NOROMAN = 246,
		VK_DBE_ROMAN = 245,
		VK_DBE_SBCSCHAR = 243,
		VK__none_ = 255,
		VK_LBUTTON = 1,
		VK_RBUTTON = 2,
		VK_CANCEL = 3,
		VK_MBUTTON = 4,
		VK_XBUTTON1 = 5,
		VK_XBUTTON2 = 6,
		VK_BACK = 8,
		VK_TAB = 9,
		VK_CLEAR = 12,
		VK_RETURN = 13,
		VK_SHIFT = 16,
		VK_CONTROL = 17,
		VK_MENU = 18,
		VK_PAUSE = 19,
		VK_CAPITAL = 20,
		VK_KANA = 21,
		VK_HANGEUL = 21,
		VK_HANGUL = 21,
		VK_IME_ON = 22,
		VK_JUNJA = 23,
		VK_FINAL = 24,
		VK_HANJA = 25,
		VK_KANJI = 25,
		VK_IME_OFF = 26,
		VK_ESCAPE = 27,
		VK_CONVERT = 28,
		VK_NONCONVERT = 29,
		VK_ACCEPT = 30,
		VK_MODECHANGE = 31,
		VK_SPACE = 32,
		VK_PRIOR = 33,
		VK_NEXT = 34,
		VK_END = 35,
		VK_HOME = 36,
		VK_LEFT = 37,
		VK_UP = 38,
		VK_RIGHT = 39,
		VK_DOWN = 40,
		VK_SELECT = 41,
		VK_PRINT = 42,
		VK_EXECUTE = 43,
		VK_SNAPSHOT = 44,
		VK_INSERT = 45,
		VK_DELETE = 46,
		VK_HELP = 47,
		VK_LWIN = 91,
		VK_RWIN = 92,
		VK_APPS = 93,
		VK_SLEEP = 95,
		VK_NUMPAD0 = 96,
		VK_NUMPAD1 = 97,
		VK_NUMPAD2 = 98,
		VK_NUMPAD3 = 99,
		VK_NUMPAD4 = 100,
		VK_NUMPAD5 = 101,
		VK_NUMPAD6 = 102,
		VK_NUMPAD7 = 103,
		VK_NUMPAD8 = 104,
		VK_NUMPAD9 = 105,
		VK_MULTIPLY = 106,
		VK_ADD = 107,
		VK_SEPARATOR = 108,
		VK_SUBTRACT = 109,
		VK_DECIMAL = 110,
		VK_DIVIDE = 111,
		VK_F1 = 112,
		VK_F2 = 113,
		VK_F3 = 114,
		VK_F4 = 115,
		VK_F5 = 116,
		VK_F6 = 117,
		VK_F7 = 118,
		VK_F8 = 119,
		VK_F9 = 120,
		VK_F10 = 121,
		VK_F11 = 122,
		VK_F12 = 123,
		VK_F13 = 124,
		VK_F14 = 125,
		VK_F15 = 126,
		VK_F16 = 127,
		VK_F17 = 128,
		VK_F18 = 129,
		VK_F19 = 130,
		VK_F20 = 131,
		VK_F21 = 132,
		VK_F22 = 133,
		VK_F23 = 134,
		VK_F24 = 135,
		VK_NAVIGATION_VIEW = 136,
		VK_NAVIGATION_MENU = 137,
		VK_NAVIGATION_UP = 138,
		VK_NAVIGATION_DOWN = 139,
		VK_NAVIGATION_LEFT = 140,
		VK_NAVIGATION_RIGHT = 141,
		VK_NAVIGATION_ACCEPT = 142,
		VK_NAVIGATION_CANCEL = 143,
		VK_NUMLOCK = 144,
		VK_SCROLL = 145,
		VK_OEM_NEC_EQUAL = 146,
		VK_OEM_FJ_JISHO = 146,
		VK_OEM_FJ_MASSHOU = 147,
		VK_OEM_FJ_TOUROKU = 148,
		VK_OEM_FJ_LOYA = 149,
		VK_OEM_FJ_ROYA = 150,
		VK_LSHIFT = 160,
		VK_RSHIFT = 161,
		VK_LCONTROL = 162,
		VK_RCONTROL = 163,
		VK_LMENU = 164,
		VK_RMENU = 165,
		VK_BROWSER_BACK = 166,
		VK_BROWSER_FORWARD = 167,
		VK_BROWSER_REFRESH = 168,
		VK_BROWSER_STOP = 169,
		VK_BROWSER_SEARCH = 170,
		VK_BROWSER_FAVORITES = 171,
		VK_BROWSER_HOME = 172,
		VK_VOLUME_MUTE = 173,
		VK_VOLUME_DOWN = 174,
		VK_VOLUME_UP = 175,
		VK_MEDIA_NEXT_TRACK = 176,
		VK_MEDIA_PREV_TRACK = 177,
		VK_MEDIA_STOP = 178,
		VK_MEDIA_PLAY_PAUSE = 179,
		VK_LAUNCH_MAIL = 180,
		VK_LAUNCH_MEDIA_SELECT = 181,
		VK_LAUNCH_APP1 = 182,
		VK_LAUNCH_APP2 = 183,
		VK_OEM_1 = 186,
		VK_OEM_PLUS = 187,
		VK_OEM_COMMA = 188,
		VK_OEM_MINUS = 189,
		VK_OEM_PERIOD = 190,
		VK_OEM_2 = 191,
		VK_OEM_3 = 192,
		VK_GAMEPAD_A = 195,
		VK_GAMEPAD_B = 196,
		VK_GAMEPAD_X = 197,
		VK_GAMEPAD_Y = 198,
		VK_GAMEPAD_RIGHT_SHOULDER = 199,
		VK_GAMEPAD_LEFT_SHOULDER = 200,
		VK_GAMEPAD_LEFT_TRIGGER = 201,
		VK_GAMEPAD_RIGHT_TRIGGER = 202,
		VK_GAMEPAD_DPAD_UP = 203,
		VK_GAMEPAD_DPAD_DOWN = 204,
		VK_GAMEPAD_DPAD_LEFT = 205,
		VK_GAMEPAD_DPAD_RIGHT = 206,
		VK_GAMEPAD_MENU = 207,
		VK_GAMEPAD_VIEW = 208,
		VK_GAMEPAD_LEFT_THUMBSTICK_BUTTON = 209,
		VK_GAMEPAD_RIGHT_THUMBSTICK_BUTTON = 210,
		VK_GAMEPAD_LEFT_THUMBSTICK_UP = 211,
		VK_GAMEPAD_LEFT_THUMBSTICK_DOWN = 212,
		VK_GAMEPAD_LEFT_THUMBSTICK_RIGHT = 213,
		VK_GAMEPAD_LEFT_THUMBSTICK_LEFT = 214,
		VK_GAMEPAD_RIGHT_THUMBSTICK_UP = 215,
		VK_GAMEPAD_RIGHT_THUMBSTICK_DOWN = 216,
		VK_GAMEPAD_RIGHT_THUMBSTICK_RIGHT = 217,
		VK_GAMEPAD_RIGHT_THUMBSTICK_LEFT = 218,
		VK_OEM_4 = 219,
		VK_OEM_5 = 220,
		VK_OEM_6 = 221,
		VK_OEM_7 = 222,
		VK_OEM_8 = 223,
		VK_OEM_AX = 225,
		VK_OEM_102 = 226,
		VK_ICO_HELP = 227,
		VK_ICO_00 = 228,
		VK_PROCESSKEY = 229,
		VK_ICO_CLEAR = 230,
		VK_PACKET = 231,
		VK_OEM_RESET = 233,
		VK_OEM_JUMP = 234,
		VK_OEM_PA1 = 235,
		VK_OEM_PA2 = 236,
		VK_OEM_PA3 = 237,
		VK_OEM_WSCTRL = 238,
		VK_OEM_CUSEL = 239,
		VK_OEM_ATTN = 240,
		VK_OEM_FINISH = 241,
		VK_OEM_COPY = 242,
		VK_OEM_AUTO = 243,
		VK_OEM_ENLW = 244,
		VK_OEM_BACKTAB = 245,
		VK_ATTN = 246,
		VK_CRSEL = 247,
		VK_EXSEL = 248,
		VK_EREOF = 249,
		VK_PLAY = 250,
		VK_ZOOM = 251,
		VK_NONAME = 252,
		VK_PA1 = 253,
		VK_OEM_CLEAR = 254
	}
}
namespace Windows.Win32.UI.WindowsAndMessaging
{
	[UnmanagedFunctionPointer(CallingConvention.Winapi)]
	[GeneratedCode("Microsoft.Windows.CsWin32", "0.3.205+c676a8cdc6.RR")]
	internal delegate LRESULT WNDPROC(HWND param0, uint param1, WPARAM param2, LPARAM param3);
	[UnmanagedFunctionPointer(CallingConvention.Winapi)]
	[GeneratedCode("Microsoft.Windows.CsWin32", "0.3.205+c676a8cdc6.RR")]
	internal delegate BOOL WNDENUMPROC(HWND param0, LPARAM param1);
	[GeneratedCode("Microsoft.Windows.CsWin32", "0.3.205+c676a8cdc6.RR")]
	internal enum WINDOW_LONG_PTR_INDEX
	{
		GWL_EXSTYLE = -20,
		GWLP_HINSTANCE = -6,
		GWLP_HWNDPARENT = -8,
		GWLP_ID = -12,
		GWL_STYLE = -16,
		GWLP_USERDATA = -21,
		GWLP_WNDPROC = -4,
		GWL_HINSTANCE = -6,
		GWL_ID = -12,
		GWL_USERDATA = -21,
		GWL_WNDPROC = -4,
		GWL_HWNDPARENT = -8
	}
}
namespace Windows.Win32.Foundation
{
	[DebuggerDisplay("{Value}")]
	[GeneratedCode("Microsoft.Windows.CsWin32", "0.3.205+c676a8cdc6.RR")]
	internal readonly struct BOOL : IEquatable<BOOL>
	{
		internal readonly int Value;

		internal BOOL(int value)
		{
			Value = value;
		}

		public static implicit operator int(BOOL value)
		{
			return value.Value;
		}

		public static explicit operator BOOL(int value)
		{
			return new BOOL(value);
		}

		public static bool operator ==(BOOL left, BOOL right)
		{
			return left.Value == right.Value;
		}

		public static bool operator !=(BOOL left, BOOL right)
		{
			return !(left == right);
		}

		public bool Equals(BOOL other)
		{
			return Value == other.Value;
		}

		public override bool Equals(object obj)
		{
			return obj is BOOL other && Equals(other);
		}

		public override int GetHashCode()
		{
			return Value.GetHashCode();
		}

		public override string ToString()
		{
			return $"0x{Value:x}";
		}

		internal BOOL(bool value)
		{
			Value = (value ? 1 : 0);
		}

		public static implicit operator bool(BOOL value)
		{
			return value.Value != 0;
		}

		public static implicit operator BOOL(bool value)
		{
			return new BOOL(value);
		}
	}
	[DebuggerDisplay("{Value}")]
	[GeneratedCode("Microsoft.Windows.CsWin32", "0.3.205+c676a8cdc6.RR")]
	internal readonly struct HANDLE : IEquatable<HANDLE>
	{
		internal unsafe readonly void* Value;

		internal static HANDLE Null => default(HANDLE);

		internal unsafe bool IsNull => Value == null;

		internal unsafe HANDLE(void* value)
		{
			Value = value;
		}

		internal unsafe HANDLE(IntPtr value)
			: this((void*)value)
		{
		}

		public unsafe static implicit operator void*(HANDLE value)
		{
			return value.Value;
		}

		public unsafe static explicit operator HANDLE(void* value)
		{
			return new HANDLE(value);
		}

		public unsafe static bool operator ==(HANDLE left, HANDLE right)
		{
			return left.Value == right.Value;
		}

		public static bool operator !=(HANDLE left, HANDLE right)
		{
			return !(left == right);
		}

		public unsafe bool Equals(HANDLE other)
		{
			return Value == other.Value;
		}

		public override bool Equals(object obj)
		{
			return obj is HANDLE other && Equals(other);
		}

		public unsafe override int GetHashCode()
		{
			return (int)Value;
		}

		public unsafe override string ToString()
		{
			return $"0x{Value:x}";
		}

		public unsafe static implicit operator IntPtr(HANDLE value)
		{
			return new IntPtr(value.Value);
		}

		public unsafe static explicit operator HANDLE(IntPtr value)
		{
			return new HANDLE(value.ToPointer());
		}

		public unsafe static explicit operator HANDLE(UIntPtr value)
		{
			return new HANDLE(value.ToPointer());
		}
	}
	[DebuggerDisplay("{Value}")]
	[GeneratedCode("Microsoft.Windows.CsWin32", "0.3.205+c676a8cdc6.RR")]
	internal readonly struct HWND : IEquatable<HWND>
	{
		internal unsafe readonly void* Value;

		internal static HWND Null => default(HWND);

		internal unsafe bool IsNull => Value == null;

		internal unsafe HWND(void* value)
		{
			Value = value;
		}

		internal unsafe HWND(IntPtr value)
			: this((void*)value)
		{
		}

		public unsafe static implicit operator void*(HWND value)
		{
			return value.Value;
		}

		public unsafe static explicit operator HWND(void* value)
		{
			return new HWND(value);
		}

		public unsafe static bool operator ==(HWND left, HWND right)
		{
			return left.Value == right.Value;
		}

		public static bool operator !=(HWND left, HWND right)
		{
			return !(left == right);
		}

		public unsafe bool Equals(HWND other)
		{
			return Value == other.Value;
		}

		public override bool Equals(object obj)
		{
			return obj is HWND other && Equals(other);
		}

		public unsafe override int GetHashCode()
		{
			return (int)Value;
		}

		public unsafe override string ToString()
		{
			return $"0x{Value:x}";
		}

		public unsafe static implicit operator IntPtr(HWND value)
		{
			return new IntPtr(value.Value);
		}

		public unsafe static explicit operator HWND(IntPtr value)
		{
			return new HWND(value.ToPointer());
		}

		public unsafe static explicit operator HWND(UIntPtr value)
		{
			return new HWND(value.ToPointer());
		}

		public unsafe static implicit operator HANDLE(HWND value)
		{
			return new HANDLE(value.Value);
		}
	}
	[DebuggerDisplay("{Value}")]
	[GeneratedCode("Microsoft.Windows.CsWin32", "0.3.205+c676a8cdc6.RR")]
	internal readonly struct LPARAM : IEquatable<LPARAM>
	{
		internal readonly nint Value;

		internal LPARAM(nint value)
		{
			Value = value;
		}

		public static implicit operator nint(LPARAM value)
		{
			return value.Value;
		}

		public static implicit operator LPARAM(nint value)
		{
			return new LPARAM(value);
		}

		public static bool operator ==(LPARAM left, LPARAM right)
		{
			return left.Value == right.Value;
		}

		public static bool operator !=(LPARAM left, LPARAM right)
		{
			return !(left == right);
		}

		public bool Equals(LPARAM other)
		{
			return Value == other.Value;
		}

		public override bool Equals(object obj)
		{
			return obj is LPARAM other && Equals(other);
		}

		public override int GetHashCode()
		{
			return ((IntPtr)Value).GetHashCode();
		}

		public override string ToString()
		{
			return $"0x{Value:x}";
		}
	}
	[DebuggerDisplay("{Value}")]
	[GeneratedCode("Microsoft.Windows.CsWin32", "0.3.205+c676a8cdc6.RR")]
	internal readonly struct LRESULT : IEquatable<LRESULT>
	{
		internal readonly nint Value;

		internal LRESULT(nint value)
		{
			Value = value;
		}

		public static implicit operator nint(LRESULT value)
		{
			return value.Value;
		}

		public static explicit operator LRESULT(nint value)
		{
			return new LRESULT(value);
		}

		public static bool operator ==(LRESULT left, LRESULT right)
		{
			return left.Value == right.Value;
		}

		public static bool operator !=(LRESULT left, LRESULT right)
		{
			return !(left == right);
		}

		public bool Equals(LRESULT other)
		{
			return Value == other.Value;
		}

		public override bool Equals(object obj)
		{
			return obj is LRESULT other && Equals(other);
		}

		public override int GetHashCode()
		{
			return ((IntPtr)Value).GetHashCode();
		}

		public override string ToString()
		{
			return $"0x{Value:x}";
		}
	}
	[DebuggerDisplay("{DebuggerDisplay}")]
	internal readonly struct PCWSTR : IEquatable<PCWSTR>
	{
		internal unsafe readonly char* Value;

		internal unsafe int Length
		{
			get
			{
				char* ptr = Value;
				if (ptr == null)
				{
					return 0;
				}
				for (; *ptr != 0; ptr++)
				{
				}
				return checked((int)(ptr - Value));
			}
		}

		private string DebuggerDisplay => ToString();

		internal unsafe PCWSTR(char* value)
		{
			Value = value;
		}

		public unsafe static explicit operator char*(PCWSTR value)
		{
			return value.Value;
		}

		public unsafe static implicit operator PCWSTR(char* value)
		{
			return new PCWSTR(value);
		}

		public unsafe bool Equals(PCWSTR other)
		{
			return Value == other.Value;
		}

		public override bool Equals(object obj)
		{
			return obj is PCWSTR other && Equals(other);
		}

		public unsafe override int GetHashCode()
		{
			return (int)Value;
		}

		public unsafe override string ToString()
		{
			return (Value == null) ? null : new string(Value);
		}

		internal unsafe ReadOnlySpan<char> AsSpan()
		{
			return (Value == null) ? default(ReadOnlySpan<char>) : new ReadOnlySpan<char>(Value, Length);
		}
	}
	[DebuggerDisplay("{DebuggerDisplay,nq}")]
	[GeneratedCode("Microsoft.Windows.CsWin32", "0.3.205+c676a8cdc6.RR")]
	internal readonly struct PWSTR : IEquatable<PWSTR>
	{
		internal unsafe readonly char* Value;

		internal unsafe int Length => new PCWSTR(Value).Length;

		private string DebuggerDisplay => ToString();

		internal unsafe PWSTR(char* value)
		{
			Value = value;
		}

		internal unsafe PWSTR(IntPtr value)
			: this((char*)(void*)value)
		{
		}

		public unsafe static implicit operator char*(PWSTR value)
		{
			return value.Value;
		}

		public unsafe static implicit operator PWSTR(char* value)
		{
			return new PWSTR(value);
		}

		public unsafe static bool operator ==(PWSTR left, PWSTR right)
		{
			return left.Value == right.Value;
		}

		public static bool operator !=(PWSTR left, PWSTR right)
		{
			return !(left == right);
		}

		public unsafe bool Equals(PWSTR other)
		{
			return Value == other.Value;
		}

		public override bool Equals(object obj)
		{
			return obj is PWSTR other && Equals(other);
		}

		public unsafe override int GetHashCode()
		{
			return (int)Value;
		}

		public unsafe override string ToString()
		{
			return new PCWSTR(Value).ToString();
		}

		public unsafe static implicit operator PCWSTR(PWSTR value)
		{
			return new PCWSTR(value.Value);
		}

		internal unsafe Span<char> AsSpan()
		{
			return (Value == null) ? default(Span<char>) : new Span<char>(Value, Length);
		}
	}
	[DebuggerDisplay("{Value}")]
	[GeneratedCode("Microsoft.Windows.CsWin32", "0.3.205+c676a8cdc6.RR")]
	internal readonly struct WPARAM : IEquatable<WPARAM>
	{
		internal readonly nuint Value;

		internal WPARAM(nuint value)
		{
			Value = value;
		}

		public static implicit operator nuint(WPARAM value)
		{
			return value.Value;
		}

		public static implicit operator WPARAM(nuint value)
		{
			return new WPARAM(value);
		}

		public static bool operator ==(WPARAM left, WPARAM right)
		{
			return left.Value == right.Value;
		}

		public static bool operator !=(WPARAM left, WPARAM right)
		{
			return !(left == right);
		}

		public bool Equals(WPARAM other)
		{
			return Value == other.Value;
		}

		public override bool Equals(object obj)
		{
			return obj is WPARAM other && Equals(other);
		}

		public override int GetHashCode()
		{
			return ((UIntPtr)Value).GetHashCode();
		}

		public override string ToString()
		{
			return $"0x{Value:x}";
		}
	}
}
namespace MegabonkInput
{
	public class Keybind
	{
		public static readonly List<Keybind> allBinds = new List<Keybind>();

		private static int maxDescriptionLength = 32;

		private bool released = false;

		private InputLayer activeLayers;

		private VirtualKey key;

		private PressType press;

		private string description;

		internal Action onPress;

		private uint id;

		private bool enabled = false;

		public InputLayer ActiveLayers
		{
			get
			{
				return activeLayers;
			}
			set
			{
				if (activeLayers != value)
				{
					activeLayers = value;
					Reload();
				}
			}
		}

		public VirtualKey Key
		{
			get
			{
				return key;
			}
			set
			{
				if (key != value)
				{
					key = value;
					Reload();
				}
			}
		}

		public PressType Press
		{
			get
			{
				return press;
			}
			set
			{
				if (press != value)
				{
					press = value;
					Reload();
				}
			}
		}

		public string Description => description;

		public bool Enabled
		{
			get
			{
				return enabled;
			}
			set
			{
				if (enabled != value && !(released && value) && onPress != null)
				{
					enabled = value;
					if (enabled)
					{
						Load();
					}
					else
					{
						Unload();
					}
				}
			}
		}

		private void Load()
		{
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Expected O, but got Unknown
			id = (uint)(((int)press << 16) | (int)key);
			InputLayer[] managedLayers = KeybindCollection.managedLayers;
			foreach (InputLayer inputLayer in managedLayers)
			{
				if (activeLayers.HasFlag(inputLayer))
				{
					switch (inputLayer)
					{
					case InputLayer.ExternalUI:
					{
						Keymapping keymapping = MegabonkInput.inputLayer_ExternalUI.Get(id);
						keymapping.AddBoundAction(this);
						break;
					}
					case InputLayer.Game:
					{
						Keymapping keymapping = MegabonkInput.inputLayer_Game.Get(id);
						keymapping.AddBoundAction(this);
						break;
					}
					case InputLayer.GameUI:
					{
						Keymapping keymapping = MegabonkInput.inputLayer_GameUI.Get(id);
						keymapping.AddBoundAction(this);
						break;
					}
					}
				}
			}
			ManualLogSource log = MegabonkInput.Log;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(13, 3, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Bound ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<PressType>(press);
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<VirtualKey>(key);
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", id: ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<uint>(id);
			}
			log.LogInfo(val);
		}

		private void Unload()
		{
			InputLayer[] managedLayers = KeybindCollection.managedLayers;
			foreach (InputLayer inputLayer in managedLayers)
			{
				if (activeLayers.HasFlag(inputLayer))
				{
					switch (inputLayer)
					{
					case InputLayer.ExternalUI:
					{
						Keymapping keymapping = MegabonkInput.inputLayer_ExternalUI.Get(id);
						keymapping.RemoveBoundAction(this);
						break;
					}
					case InputLayer.Game:
					{
						Keymapping keymapping = MegabonkInput.inputLayer_Game.Get(id);
						keymapping.RemoveBoundAction(this);
						break;
					}
					case InputLayer.GameUI:
					{
						Keymapping keymapping = MegabonkInput.inputLayer_GameUI.Get(id);
						keymapping.RemoveBoundAction(this);
						break;
					}
					}
				}
			}
		}

		private void Reload()
		{
			if (enabled)
			{
				Unload();
				Load();
			}
		}

		public void Release()
		{
			released = true;
			Enabled = false;
			allBinds.Remove(this);
		}

		public Keybind(VirtualKey newKey, PressType newPressType, Action newOnPress, InputLayer newActiveLayers, string newDescription = null, bool enableOnCreation = true)
		{
			key = newKey;
			press = newPressType;
			onPress = newOnPress;
			activeLayers = newActiveLayers;
			if (newDescription != null)
			{
				if (newDescription.Length > 0)
				{
					newDescription = newDescription.Trim();
					if (newDescription.Length > maxDescriptionLength)
					{
						newDescription = newDescription.Substring(0, maxDescriptionLength - 3) + "...";
					}
				}
				description = newDescription;
			}
			else
			{
				description = "";
			}
			allBinds.Add(this);
			Enabled = enableOnCreation;
		}
	}
	internal class Keymapping
	{
		private List<Action> actions = new List<Action>();

		internal Action[] actionsArray;

		internal void AddBoundAction(Keybind toAdd)
		{
			actions.Add(toAdd.onPress);
			GenerateActionArray();
		}

		internal void RemoveBoundAction(Keybind toRemove)
		{
			actions.Remove(toRemove.onPress);
			GenerateActionArray();
		}

		private void GenerateActionArray()
		{
			HashSet<Action> hashSet = new HashSet<Action>(actions);
			actionsArray = new Action[hashSet.Count];
			hashSet.CopyTo(actionsArray);
		}
	}
	internal class KeybindCollection : Dictionary<ulong, Keymapping>
	{
		internal static readonly InputLayer[] managedLayers = new InputLayer[3]
		{
			InputLayer.ExternalUI,
			InputLayer.Game,
			InputLayer.GameUI
		};

		public Keymapping Get(ulong testID)
		{
			if (TryGetValue(testID, out var value))
			{
				return value;
			}
			value = new Keymapping();
			Add(testID, value);
			return value;
		}
	}
	[Flags]
	public enum InputLayer
	{
		Disabled = 1,
		ExternalUI = 2,
		Game = 4,
		GameUI = 8
	}
	public enum PressType : ulong
	{
		WM_KEYDOWN = 256uL,
		WM_KEYUP
	}
	public enum VirtualKey : ulong
	{
		VK_LBUTTON = 1uL,
		VK_RBUTTON = 2uL,
		VK_MBUTTON = 4uL,
		VK_XBUTTON1 = 5uL,
		VK_XBUTTON2 = 6uL,
		VK_BACK = 8uL,
		VK_TAB = 9uL,
		VK_CLEAR = 12uL,
		VK_RETURN = 13uL,
		VK_SHIFT = 16uL,
		VK_CONTROL = 17uL,
		VK_MENU = 18uL,
		VK_PAUSE = 19uL,
		VK_SPACE = 32uL,
		VK_PRIOR = 33uL,
		VK_NEXT = 34uL,
		VK_END = 35uL,
		VK_HOME = 36uL,
		VK_LEFT = 37uL,
		VK_UP = 38uL,
		VK_RIGHT = 39uL,
		VK_DOWN = 40uL,
		VK_SELECT = 41uL,
		VK_PRINT = 42uL,
		VK_EXECUTE = 43uL,
		VK_SNAPSHOT = 44uL,
		VK_INSERT = 45uL,
		VK_DELETE = 46uL,
		VK_HELP = 47uL,
		_0 = 48uL,
		_1 = 49uL,
		_2 = 50uL,
		_3 = 51uL,
		_4 = 52uL,
		_5 = 53uL,
		_6 = 54uL,
		_7 = 55uL,
		_8 = 56uL,
		_9 = 57uL,
		A = 65uL,
		B = 66uL,
		C = 67uL,
		D = 68uL,
		E = 69uL,
		F = 70uL,
		G = 71uL,
		H = 72uL,
		I = 73uL,
		J = 74uL,
		K = 75uL,
		L = 76uL,
		M = 77uL,
		N = 78uL,
		O = 79uL,
		P = 80uL,
		Q = 81uL,
		R = 82uL,
		S = 83uL,
		T = 84uL,
		U = 85uL,
		V = 86uL,
		W = 87uL,
		X = 88uL,
		Y = 89uL,
		Z = 90uL,
		VK_NUMPAD0 = 96uL,
		VK_NUMPAD1 = 97uL,
		VK_NUMPAD2 = 98uL,
		VK_NUMPAD3 = 99uL,
		VK_NUMPAD4 = 100uL,
		VK_NUMPAD5 = 101uL,
		VK_NUMPAD6 = 102uL,
		VK_NUMPAD7 = 103uL,
		VK_NUMPAD8 = 104uL,
		VK_NUMPAD9 = 105uL,
		VK_MULTIPLY = 106uL,
		VK_ADD = 107uL,
		VK_SEPARATOR = 108uL,
		VK_SUBTRACT = 109uL,
		VK_DECIMAL = 110uL,
		VK_DIVIDE = 111uL,
		VK_F1 = 112uL,
		VK_F2 = 113uL,
		VK_F3 = 114uL,
		VK_F4 = 115uL,
		VK_F5 = 116uL,
		VK_F6 = 117uL,
		VK_F7 = 118uL,
		VK_F8 = 119uL,
		VK_F9 = 120uL,
		VK_F10 = 121uL,
		VK_F11 = 122uL,
		VK_F12 = 123uL,
		VK_LSHIFT = 160uL,
		VK_RSHIFT = 161uL,
		VK_LCONTROL = 162uL,
		VK_RCONTROL = 163uL,
		VK_LMENU = 164uL,
		VK_RMENU = 165uL,
		VK_OEM_1 = 186uL,
		VK_OEM_PLUS = 187uL,
		VK_OEM_COMMA = 188uL,
		VK_OEM_MINUS = 189uL,
		VK_OEM_PERIOD = 190uL,
		VK_OEM_2 = 191uL,
		VK_OEM_3 = 192uL,
		VK_GAMEPAD_A = 195uL,
		VK_GAMEPAD_B = 196uL,
		VK_GAMEPAD_X = 197uL,
		VK_GAMEPAD_Y = 198uL,
		VK_GAMEPAD_RIGHT_SHOULDER = 199uL,
		VK_GAMEPAD_LEFT_SHOULDER = 200uL,
		VK_GAMEPAD_LEFT_TRIGGER = 201uL,
		VK_GAMEPAD_RIGHT_TRIGGER = 202uL,
		VK_GAMEPAD_DPAD_UP = 203uL,
		VK_GAMEPAD_DPAD_DOWN = 204uL,
		VK_GAMEPAD_DPAD_LEFT = 205uL,
		VK_GAMEPAD_DPAD_RIGHT = 206uL,
		VK_GAMEPAD_MENU = 207uL,
		VK_GAMEPAD_VIEW = 208uL,
		VK_GAMEPAD_LEFT_THUMBSTICK_BUTTON = 209uL,
		VK_GAMEPAD_RIGHT_THUMBSTICK_BUTTON = 210uL,
		VK_GAMEPAD_LEFT_THUMBSTICK_UP = 211uL,
		VK_GAMEPAD_LEFT_THUMBSTICK_DOWN = 212uL,
		VK_GAMEPAD_LEFT_THUMBSTICK_RIGHT = 213uL,
		VK_GAMEPAD_LEFT_THUMBSTICK_LEFT = 214uL,
		VK_GAMEPAD_RIGHT_THUMBSTICK_UP = 215uL,
		VK_GAMEPAD_RIGHT_THUMBSTICK_DOWN = 216uL,
		VK_GAMEPAD_RIGHT_THUMBSTICK_RIGHT = 217uL,
		VK_GAMEPAD_RIGHT_THUMBSTICK_LEFT = 218uL
	}
	[BepInPlugin("MegabonkInput", "MegabonkInput", "1.0.0")]
	public class MegabonkInput : BasePlugin
	{
		internal class MainThreadDispatcher : MonoBehaviour
		{
			[CompilerGenerated]
			private sealed class <ActionWrapper>d__8 : IEnumerator<object>, IEnumerator, IDisposable
			{
				private int <>1__state;

				private object <>2__current;

				public Action a;

				object IEnumerator<object>.Current
				{
					[DebuggerHidden]
					get
					{
						return <>2__current;
					}
				}

				object IEnumerator.Current
				{
					[DebuggerHidden]
					get
					{
						return <>2__current;
					}
				}

				[DebuggerHidden]
				public <ActionWrapper>d__8(int <>1__state)
				{
					this.<>1__state = <>1__state;
				}

				[DebuggerHidden]
				void IDisposable.Dispose()
				{
					<>1__state = -2;
				}

				private bool MoveNext()
				{
					switch (<>1__state)
					{
					default:
						return false;
					case 0:
						<>1__state = -1;
						a();
						<>2__current = null;
						<>1__state = 1;
						return true;
					case 1:
						<>1__state = -1;
						return false;
					}
				}

				bool IEnumerator.MoveNext()
				{
					//ILSpy generated this explicit interface implementation from .override directive in MoveNext
					return this.MoveNext();
				}

				[DebuggerHidden]
				void IEnumerator.Reset()
				{
					throw new NotSupportedException();
				}
			}

			private static readonly Queue<Action> _executionQueue = new Queue<Action>();

			private static MainThreadDispatcher _instance;

			public MainThreadDispatcher(IntPtr ptr)
				: base(ptr)
			{
			}

			private void Awake()
			{
				_instance = this;
			}

			private void OnDestroy()
			{
				_instance = null;
				lock (_executionQueue)
				{
					_executionQueue.Clear();
				}
			}

			public void Update()
			{
				lock (_executionQueue)
				{
					while (_executionQueue.Count > 0)
					{
						_executionQueue.Dequeue()();
					}
				}
			}

			public static void Enqueue(IEnumerator action)
			{
				lock (_executionQueue)
				{
					_executionQueue.Enqueue(delegate
					{
						((MonoBehaviour)_instance).StartCoroutine(CollectionExtensions.WrapToIl2Cpp(action));
					});
				}
			}

			public static void Enqueue(Action action)
			{
				Enqueue(ActionWrapper(action));
			}

			[IteratorStateMachine(typeof(<ActionWrapper>d__8))]
			public static IEnumerator ActionWrapper(Action a)
			{
				//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
				return new <ActionWrapper>d__8(0)
				{
					a = a
				};
			}
		}

		internal static KeybindCollection inputLayer_ExternalUI = new KeybindCollection();

		internal static KeybindCollection inputLayer_Game = new KeybindCollection();

		internal static KeybindCollection inputLayer_GameUI = new KeybindCollection();

		private static KeybindCollection currentCollection = null;

		internal static ManualLogSource Log;

		private static MainThreadDispatcher dispatcher;

		private static HWND windowHandle = (HWND)IntPtr.Zero;

		private static WNDPROC inputHandler = HandleInput;

		private static WNDPROC originalInputHandler;

		private static Harmony hooks;

		private static bool cursorPassthrough = true;

		private static InputLayer currentLayer = InputLayer.Disabled;

		private static bool playerExists = false;

		private static bool inMainMenu = false;

		private static bool inPauseMenu = false;

		private static bool inChestMenu = false;

		private static bool inTransition = false;

		private static bool inExternalMenu = false;

		private readonly BindingFlags allBindFlags = (BindingFlags)(-1);

		private static uint tempMessageID = 0u;

		private static Keymapping tempMap;

		private static bool actionHandled;

		public static InputLayer CurrentLayer
		{
			get
			{
				return currentLayer;
			}
			set
			{
				//IL_0035: Unknown result type (might be due to invalid IL or missing references)
				//IL_003b: Expected O, but got Unknown
				if (Enum.IsDefined(value) && currentLayer != value)
				{
					currentLayer = value;
					ManualLogSource log = Log;
					bool flag = default(bool);
					BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(16, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Input Layer ->  ");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<InputLayer>(currentLayer);
					}
					log.LogInfo(val);
					switch (currentLayer)
					{
					case InputLayer.ExternalUI:
						currentCollection = inputLayer_ExternalUI;
						cursorPassthrough = false;
						break;
					case InputLayer.Game:
						currentCollection = inputLayer_Game;
						cursorPassthrough = true;
						break;
					case InputLayer.GameUI:
						currentCollection = inputLayer_GameUI;
						cursorPassthrough = true;
						break;
					default:
						currentCollection = null;
						cursorPassthrough = false;
						break;
					}
				}
			}
		}

		public static bool PlayerExists
		{
			get
			{
				return playerExists;
			}
			set
			{
				if (playerExists != value)
				{
					playerExists = value;
					CalculateCurrentLayer();
				}
			}
		}

		public static bool InMainMenu
		{
			get
			{
				return inMainMenu;
			}
			set
			{
				if (inMainMenu != value)
				{
					inMainMenu = value;
					CalculateCurrentLayer();
				}
			}
		}

		public static bool InPauseMenu
		{
			get
			{
				return inPauseMenu;
			}
			set
			{
				if (inPauseMenu != value)
				{
					inPauseMenu = value;
					CalculateCurrentLayer();
				}
			}
		}

		public static bool InChestMenu
		{
			get
			{
				return inChestMenu;
			}
			set
			{
				if (inChestMenu != value)
				{
					inChestMenu = value;
					CalculateCurrentLayer();
				}
			}
		}

		public static bool InTransition
		{
			get
			{
				return inTransition;
			}
			set
			{
				if (inTransition != value)
				{
					inTransition = value;
					CalculateCurrentLayer();
				}
			}
		}

		public static bool InExternalMenu
		{
			get
			{
				return inExternalMenu;
			}
			set
			{
				if (inExternalMenu != value)
				{
					inExternalMenu = value;
					CalculateCurrentLayer();
				}
			}
		}

		private static void CalculateCurrentLayer()
		{
			if (inExternalMenu)
			{
				CurrentLayer = InputLayer.ExternalUI;
			}
			else if (inMainMenu || inChestMenu || inTransition || inPauseMenu)
			{
				CurrentLayer = InputLayer.GameUI;
			}
			else if (playerExists)
			{
				CurrentLayer = InputLayer.Game;
			}
			else
			{
				CurrentLayer = InputLayer.Disabled;
			}
		}

		public override void Load()
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Expected O, but got Unknown
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Expected O, but got Unknown
			//IL_0389: Unknown result type (might be due to invalid IL or missing references)
			//IL_0390: Expected O, but got Unknown
			Log = ((BasePlugin)this).Log;
			ManualLogSource log = Log;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(17, 0, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Loading plugin...");
			}
			log.LogInfo(val);
			hooks = new Harmony("MegabonkInput");
			TryPostHook(typeof(MainMenu), "Start", typeof(MegabonkInput), "MainMenuEntered");
			TryPostHook(typeof(MainMenu), "OnDestroy", typeof(MegabonkInput), "MainMenuExited");
			TryPostHook(typeof(PauseUi), "OnEnable", typeof(MegabonkInput), "PauseMenuEntered");
			TryPostHook(typeof(PauseUi), "OnDisable", typeof(MegabonkInput), "PauseMenuExited");
			TryPostHook(typeof(MyPlayer), "Start", typeof(MegabonkInput), "PlayerCreated");
			TryPostHook(typeof(MyPlayer), "Spawn", typeof(MegabonkInput), "PlayerCreated");
			TryPostHook(typeof(MyPlayer), "OnDestroy", typeof(MegabonkInput), "PlayerDestroyed");
			TryPostHook(typeof(MyPlayer), "TeleportEnd", typeof(MegabonkInput), "PlayerCreated");
			TryPostHook(typeof(MyPlayer), "TeleportPlayer", typeof(MegabonkInput), "PlayerDestroyed");
			TryPostHook(typeof(MyPlayer), "OnPlayerDied", typeof(MegabonkInput), "PlayerDestroyed");
			TryPostHook(typeof(TransitionUI), "StartTransition", typeof(MegabonkInput), "TransitionEntered");
			TryPostHook(typeof(TransitionUI), "DoTransition", typeof(MegabonkInput), "TransitionEntered");
			TryPostHook(typeof(TransitionUI), "EndTransition", typeof(MegabonkInput), "TransitionExited");
			TryPostHook(typeof(TransitionUI), "StopTransition", typeof(MegabonkInput), "TransitionExited");
			TryPostHook(typeof(LevelupScreen), "Open", typeof(MegabonkInput), "RewardMenuEntered");
			TryPostHook(typeof(LevelupScreen), "OnClose", typeof(MegabonkInput), "RewardMenuExited");
			TryPostHook(typeof(ChestWindowUi), "Open", typeof(MegabonkInput), "RewardMenuEntered");
			TryPostHook(typeof(ChestWindowUi), "OnClose", typeof(MegabonkInput), "RewardMenuExited");
			TryPostHook(typeof(EncounterUi), "Open", typeof(MegabonkInput), "RewardMenuEntered");
			TryPostHook(typeof(EncounterUi), "OnClose", typeof(MegabonkInput), "RewardMenuExited");
			TryPostHook(typeof(MicrowaveUi), "Open", typeof(MegabonkInput), "RewardMenuEntered");
			TryPostHook(typeof(MicrowaveUi), "OnClose", typeof(MegabonkInput), "RewardMenuExited");
			ClassInjector.RegisterTypeInIl2Cpp<MainThreadDispatcher>();
			if (dispatcher == null)
			{
				GameObject val2 = new GameObject("InputDispatcher");
				Object.DontDestroyOnLoad((Object)(object)val2);
				dispatcher = val2.AddComponent<MainThreadDispatcher>();
			}
			IL2CPP.il2cpp_thread_attach(IL2CPP.il2cpp_domain_get());
			HookInput();
		}

		private static void PlayerCreated()
		{
			PlayerExists = true;
		}

		private static void PlayerDestroyed()
		{
			PlayerExists = false;
		}

		private static void MainMenuEntered()
		{
			InMainMenu = true;
		}

		private static void MainMenuExited()
		{
			InMainMenu = false;
		}

		private static void TransitionEntered()
		{
			InTransition = true;
		}

		private static void TransitionExited()
		{
			InTransition = false;
		}

		private static void PauseMenuEntered()
		{
			InPauseMenu = true;
		}

		private static void PauseMenuExited()
		{
			InPauseMenu = false;
		}

		private static void RewardMenuEntered()
		{
			InChestMenu = true;
		}

		private static void RewardMenuExited()
		{
			InChestMenu = false;
		}

		internal bool TryPostHook(Type targetType, string targetMethod, Type hookType, string hookMethod)
		{
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_0177: Expected O, but got Unknown
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Expected O, but got Unknown
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Expected O, but got Unknown
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Expected O, but got Unknown
			if (hooks == null)
			{
				return false;
			}
			bool flag = default(bool);
			try
			{
				MethodInfo methodInfo = hooks.Patch((MethodBase)targetType.GetMethod(targetMethod, allBindFlags), (HarmonyMethod)null, new HarmonyMethod(hookType.GetMethod(hookMethod, allBindFlags)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
				if ((object)methodInfo != null)
				{
					ManualLogSource log = Log;
					BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(15, 4, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Hooked ");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Type>(targetType);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral(".");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(targetMethod);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" with ");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Type>(hookType);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral(".");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(hookMethod);
					}
					log.LogInfo(val);
				}
				else
				{
					ManualLogSource log2 = Log;
					BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(40, 4, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Failed to hook ");
						((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<Type>(targetType);
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(".");
						((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(targetMethod);
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" with ");
						((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<Type>(hookType);
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(".");
						((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(hookMethod);
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(", newInfo is null");
					}
					log2.LogWarning(val2);
				}
				return true;
			}
			catch (Exception ex)
			{
				ManualLogSource log3 = Log;
				BepInExErrorLogInterpolatedStringHandler val3 = new BepInExErrorLogInterpolatedStringHandler(25, 5, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("Failed to hook ");
					((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<Type>(targetType);
					((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(".");
					((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(targetMethod);
					((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" with ");
					((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<Type>(hookType);
					((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(".");
					((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(hookMethod);
					((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(": ");
					((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<Exception>(ex);
				}
				log3.LogError(val3);
				return false;
			}
		}

		private unsafe static void HookInput()
		{
			HWND foundWindowHandle = HWND.Null;
			uint currentProcessId = PInvoke.GetCurrentProcessId();
			PInvoke.EnumWindows(delegate(HWND hWnd, LPARAM lParam)
			{
				uint num = default(uint);
				uint* lpdwProcessId = &num;
				PInvoke.GetWindowThreadProcessId(hWnd, lpdwProcessId);
				if (num == currentProcessId)
				{
					string text;
					fixed (char* ptr = new char[32])
					{
						if (PInvoke.GetWindowText(hWnd, ptr, 32) == 0)
						{
							Log.LogError((object)("Couldnt GetWindowText: " + Marshal.GetLastWin32Error()));
							return true;
						}
						text = new string(ptr);
					}
					if (text == "Megabonk")
					{
						foundWindowHandle = hWnd;
						return false;
					}
				}
				return true;
			}, IntPtr.Zero);
			if (foundWindowHandle == HWND.Null)
			{
				Log.LogError((object)"Couldn't find unity window handle for input hooking");
			}
			else
			{
				HookWindowInput(foundWindowHandle);
			}
		}

		private static void HookWindowInput(HWND newHandle)
		{
			if (!(newHandle == IntPtr.Zero))
			{
				windowHandle = newHandle;
				nint functionPointerForDelegate = Marshal.GetFunctionPointerForDelegate(inputHandler);
				if (functionPointerForDelegate == IntPtr.Zero)
				{
					Log.LogError((object)"Failed to GetFunctionPointerForDelegate");
					Log.LogError((object)Marshal.GetLastWin32Error());
				}
				nint num = PInvoke.SetWindowLongPtr(windowHandle, WINDOW_LONG_PTR_INDEX.GWLP_WNDPROC, functionPointerForDelegate);
				if (num == IntPtr.Zero)
				{
					Log.LogError((object)"Failed to SetWindowLongPtr");
					Log.LogError((object)Marshal.GetLastWin32Error());
				}
				originalInputHandler = Marshal.GetDelegateForFunctionPointer<WNDPROC>(num);
				if (originalInputHandler == null)
				{
					Log.LogError((object)"Failed to return original wndproc");
					Log.LogError((object)Marshal.GetLastWin32Error());
				}
			}
		}

		private void Dispose()
		{
			PInvoke.SetWindowLongPtr(windowHandle, WINDOW_LONG_PTR_INDEX.GWLP_WNDPROC, Marshal.GetFunctionPointerForDelegate(originalInputHandler));
			windowHandle = HWND.Null;
			inputHandler = null;
			originalInputHandler = null;
		}

		internal static LRESULT HandleInput(HWND windowHandle, uint message, WPARAM wParam, LPARAM lParam)
		{
			actionHandled = false;
			if ((ulong)message != 256 || ((ulong)(nint)lParam & 0x40000000uL) == 0)
			{
				tempMessageID = (message << 16) ^ (uint)(int)(nuint)wParam;
				KeybindCollection keybindCollection = currentCollection;
				if (keybindCollection != null && keybindCollection.TryGetValue(tempMessageID, out tempMap))
				{
					Action[] actionsArray = tempMap.actionsArray;
					foreach (Action action in actionsArray)
					{
						actionHandled = true;
						MainThreadDispatcher.Enqueue(action);
					}
				}
			}
			if (cursorPassthrough)
			{
				return PInvoke.CallWindowProc(originalInputHandler, windowHandle, message, wParam, lParam);
			}
			if (actionHandled)
			{
				return new LRESULT(0);
			}
			return PInvoke.DefWindowProc(windowHandle, message, wParam, lParam);
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "MegabonkInput";

		public const string PLUGIN_NAME = "MegabonkInput";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}