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 CursorToggle v1.0.1
CursorToggle.dll
Decompiled 3 hours agousing System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using GameNetcodeStuff; using HarmonyLib; using UnityEngine; using UnityEngine.InputSystem; using UnityEngine.InputSystem.Controls; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("CursorToggle")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("CursorToggle")] [assembly: AssemblyCopyright("Copyright © 2026")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("8710dd5c-1486-43bd-9224-a0812ff4567a")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyVersion("1.0.0.0")] namespace CursorToggle; [BepInPlugin("azumi.cursortoggle", "CursorToggle", "1.0.1")] public class CursorTogglePlugin : BaseUnityPlugin { public class PluginConfig { public static PluginConfig Instance; public ConfigEntry<bool> EnabledMod; public ConfigEntry<Key> ToggleKey; public ConfigEntry<bool> BlockToggleInTerminalAndChat; public PluginConfig(ConfigFile config) { Instance = this; ToggleKey = config.Bind<Key>("Controls", "Toggle Key", (Key)17, "Key to toggle cursor lock state."); EnabledMod = config.Bind<bool>("General", "Enable Mod", true, "Enable or disable Cursor Toggle."); BlockToggleInTerminalAndChat = config.Bind<bool>("General", "Block Toggle In Terminal And Chat", false, "Prevent the cursor toggle key from working while using the terminal or chat."); } } internal static ManualLogSource Log; private Harmony harmony; public static PluginConfig ModConfig { get; private set; } public static bool CursorMode { get; private set; } private void Awake() { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; ModConfig = new PluginConfig(((BaseUnityPlugin)this).Config); harmony = new Harmony("azumi.cursortoggle"); harmony.PatchAll(); CursorMode = false; ApplyCursorState(); ApplyLookState(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"CursorToggle loaded."); } public static void SetCursorMode(bool enabled) { CursorMode = enabled; Log.LogInfo((object)$"Cursor Mode: {enabled}"); ApplyCursorState(); ApplyLookState(); } public static void ApplyCursorState() { if (CursorMode) { Cursor.visible = true; Cursor.lockState = (CursorLockMode)0; } else { Cursor.visible = false; Cursor.lockState = (CursorLockMode)1; } } public static void ApplyLookState() { if (!((Object)(object)GameNetworkManager.Instance == (Object)null)) { PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController; if (!((Object)(object)localPlayerController == (Object)null)) { localPlayerController.disableLookInput = CursorMode; } } } public static bool IsUsingTerminalOrChat() { PlayerControllerB val = GameNetworkManager.Instance?.localPlayerController; if ((Object)(object)val == (Object)null) { return false; } if (val.isTypingChat) { return true; } if (val.inTerminalMenu) { return true; } Terminal val2 = Object.FindObjectOfType<Terminal>(); if ((Object)(object)val2 != (Object)null && val2.terminalInUse) { return true; } return false; } public static bool ShouldBlockToggle() { if (!ModConfig.BlockToggleInTerminalAndChat.Value) { return false; } return IsUsingTerminalOrChat(); } } [HarmonyPatch(typeof(HUDManager))] internal class CursorToggleInputPatch { [HarmonyPatch("Update")] [HarmonyPostfix] private static void UpdatePatch() { //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) if (CursorTogglePlugin.ModConfig == null || !CursorTogglePlugin.ModConfig.EnabledMod.Value || Keyboard.current == null || CursorTogglePlugin.ShouldBlockToggle()) { return; } Key value = CursorTogglePlugin.ModConfig.ToggleKey.Value; ButtonControl val = (ButtonControl)(object)Keyboard.current[value]; if (val != null && val.wasPressedThisFrame) { CursorTogglePlugin.SetCursorMode(!CursorTogglePlugin.CursorMode); } if (CursorTogglePlugin.CursorMode && Mouse.current != null) { if (Mouse.current.leftButton.wasPressedThisFrame) { Vector2 val2 = ((InputControl<Vector2>)(object)((Pointer)Mouse.current).position).ReadValue(); CursorTogglePlugin.Log.LogInfo((object)$"Cursor Mouse Click: Left | Position: {val2}"); } if (Mouse.current.rightButton.wasPressedThisFrame) { Vector2 val3 = ((InputControl<Vector2>)(object)((Pointer)Mouse.current).position).ReadValue(); CursorTogglePlugin.Log.LogInfo((object)$"Cursor Mouse Click: Right | Position: {val3}"); } if (Mouse.current.middleButton.wasPressedThisFrame) { Vector2 val4 = ((InputControl<Vector2>)(object)((Pointer)Mouse.current).position).ReadValue(); CursorTogglePlugin.Log.LogInfo((object)$"Cursor Mouse Click: Middle | Position: {val4}"); } } } } [HarmonyPatch(typeof(HUDManager))] internal class CursorEnforcerPatch { [HarmonyPatch("Update")] [HarmonyPostfix] private static void UpdatePatch() { if (CursorTogglePlugin.ModConfig != null && CursorTogglePlugin.ModConfig.EnabledMod.Value && CursorTogglePlugin.CursorMode) { CursorTogglePlugin.ApplyCursorState(); CursorTogglePlugin.ApplyLookState(); } } }