using 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.1.0")] public class EquipWhileRunningPlugin : BaseUnityPlugin { private const string pluginGUID = "hex.EquipWhileRunning"; private const string pluginName = "Equip While Running"; private const string pluginVersion = "1.1.0"; private const float messageCooldown = 0.2f; private const KeyCode defaultKeyCode = 288; private Harmony _harmony; private ConfigEntry _modEnabled; private ConfigEntry _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("General", "Enabled", true, "Allow equip and unequip actions while running"); _toggleKey = ((BaseUnityPlugin)this).Config.Bind("Key Binds", "ToggleKey", new KeyboardShortcut((KeyCode)288, Array.Empty()), "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.1.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; } ((BaseUnityPlugin)this).Logger.LogInfo((object)"Equip While Running 1.1.0 unloaded."); Harmony harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } _harmony = null; Instance = null; } 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 AllowedActionTypes = new HashSet { (ActionType)0, (ActionType)1, (ActionType)2 }; [HarmonyPrefix] private static void SaveAllowedActionsBeforeCheckRun(Player __instance, ref List __state) { __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 list) || list.Count == 0) { return; } List list2 = new List(); foreach (MinorActionData item in list) { if (item != null) { list2.Add(item); } } if (list2.Count > 0) { __state = list2; } } [HarmonyPostfix] private static void RestoreAllowedActionsAfterCheckRun(Player __instance, List __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 list)) { return; } HashSet hashSet = new HashSet(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; } } }