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 EquipWhileRunning v1.0.0
plugins/EquipWhileRunning.dll
Decompiled a day agousing System; 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 BepInEx; using BepInEx.Configuration; using HarmonyLib; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("EquipWhileRunning")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("EquipWhileRunning")] [assembly: AssemblyCopyright("Copyright © 2026")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("57d83928-d14a-44c1-a89f-9da8067d326d")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] namespace EquipWhileRunning { [BepInPlugin("hex.EquipWhileRunning", "Equip While Running", "1.0.0")] public class EquipWhileRunningPlugin : BaseUnityPlugin { private const string pluginGUID = "hex.EquipWhileRunning"; private const string pluginName = "Equip While Running"; private const string pluginVersion = "1.0.0"; private const float messageCooldown = 0.2f; private const KeyCode defaultKeyCode = 288; private Harmony _harmony; private ConfigEntry<bool> _modEnabled; private ConfigEntry<KeyboardShortcut> _toggleKey; private float _lastMessageTime; public static EquipWhileRunningPlugin Instance { get; private set; } public bool IsModEnabled => _modEnabled.Value; private void Awake() { //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Expected O, but got Unknown ((BaseUnityPlugin)this).Logger.LogInfo((object)"Loading Equip While Running"); Instance = this; _modEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "Allow equip and unequip actions while running"); _toggleKey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Key Binds", "ToggleKey", new KeyboardShortcut((KeyCode)288, Array.Empty<KeyCode>()), "Hotkey to toggle equip while running"); _toggleKey.SettingChanged += OnToggleKeyChanged; _harmony = new Harmony("hex.EquipWhileRunning"); _harmony.PatchAll(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Equip While Running 1.0.0 loaded."); } private void Update() { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) if (Time.timeScale == 0f || (Object)(object)Player.m_localPlayer == (Object)null) { return; } KeyboardShortcut value = _toggleKey.Value; if (((KeyboardShortcut)(ref value)).IsDown()) { _modEnabled.Value = !_modEnabled.Value; if ((Object)(object)MessageHud.instance != (Object)null) { ShowStatus(_modEnabled.Value); } } } private void OnDestroy() { if (_toggleKey != null) { _toggleKey.SettingChanged -= OnToggleKeyChanged; } Instance = null; Harmony harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } } private void OnToggleKeyChanged(object sender, EventArgs e) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) ((BaseUnityPlugin)this).Logger.LogInfo((object)$"Toggle key changed to {_toggleKey.Value}"); } private void ShowStatus(bool isEnabled) { if (!(Time.time - _lastMessageTime < 0.2f)) { _lastMessageTime = Time.time; string text = (isEnabled ? "Equip While Running: ENABLED" : "Equip While Running: DISABLED"); ((BaseUnityPlugin)this).Logger.LogInfo((object)text); MessageHud.instance.ShowMessage((MessageType)2, text, 0, (Sprite)null, false); } } } } namespace EquipWhileRunning.Patches { [HarmonyPatch(typeof(Player), "CheckRun")] public static class PlayerCheckRunPatch { private static readonly FieldInfo ActionQueueField = AccessTools.Field(typeof(Player), "m_actionQueue"); private static readonly FieldInfo ActionTypeField = AccessTools.Field(typeof(MinorActionData), "m_type"); private static readonly HashSet<ActionType> AllowedActionTypes = new HashSet<ActionType> { (ActionType)0, (ActionType)1 }; [HarmonyPrefix] private static void SaveAllowedActionsBeforeCheckRun(Player __instance, ref List<MinorActionData> __state) { //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) __state = null; if ((Object)(object)EquipWhileRunningPlugin.Instance == (Object)null || !EquipWhileRunningPlugin.Instance.IsModEnabled || (Object)(object)__instance != (Object)(object)Player.m_localPlayer || ActionQueueField == null || ActionTypeField == null || !(ActionQueueField.GetValue(__instance) is List<MinorActionData> list) || list.Count == 0) { return; } List<MinorActionData> list2 = new List<MinorActionData>(); foreach (MinorActionData item2 in list) { if (item2 != null) { ActionType item = (ActionType)ActionTypeField.GetValue(item2); if (AllowedActionTypes.Contains(item)) { list2.Add(item2); } } } if (list2.Count > 0) { __state = list2; } } [HarmonyPostfix] private static void RestoreAllowedActionsAfterCheckRun(Player __instance, List<MinorActionData> __state) { if ((Object)(object)EquipWhileRunningPlugin.Instance == (Object)null || !EquipWhileRunningPlugin.Instance.IsModEnabled || (Object)(object)__instance != (Object)(object)Player.m_localPlayer || __state == null || __state.Count == 0 || ActionQueueField == null || !(ActionQueueField.GetValue(__instance) is List<MinorActionData> list)) { return; } HashSet<MinorActionData> hashSet = new HashSet<MinorActionData>(list); foreach (MinorActionData item in __state) { if (item != null && !hashSet.Contains(item)) { list.Add(item); hashSet.Add(item); } } } } [HarmonyPatch(typeof(Player), "InMinorActionSlowdown")] public static class PlayerInMinorActionSlowdownPatch { [HarmonyPrefix] private static bool PreventMinorActionSlowdownWhenRunning(Player __instance, ref bool __result) { if ((Object)(object)EquipWhileRunningPlugin.Instance == (Object)null || !EquipWhileRunningPlugin.Instance.IsModEnabled) { return true; } if ((Object)(object)__instance != (Object)(object)Player.m_localPlayer) { return true; } if (!((Character)__instance).IsRunning()) { return true; } __result = false; return false; } } }