using System; using 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 HarmonyLib; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("InfiniteStaminaMod")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("InfiniteStaminaMod")] [assembly: AssemblyCopyright("Copyright © 2026")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("a6c4c790-44bf-4084-8891-1faaea953dfd")] [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 InfiniteStaminaMod { [BepInPlugin("com.hex.infinitestamina", "HexInfiniteStamina", "1.1.0")] public class InfiniteStaminaPlugin : BaseUnityPlugin { private const string PluginGuid = "com.hex.infinitestamina"; private const string PluginName = "HexInfiniteStamina"; private const string PluginVersion = "1.1.0"; private Harmony _harmony; private ConfigEntry _toggleKey; private ConfigEntry _modEnabled; private ConfigEntry _enableOnlyWhileRunning; private float _lastMessageTime; private static readonly KeyboardShortcut DefaultHotKey = new KeyboardShortcut((KeyCode)287, Array.Empty()); private const float MessageCooldown = 0.2f; internal static InfiniteStaminaPlugin Instance { get; private set; } internal static ManualLogSource Log { get; private set; } internal bool IsInfiniteStaminaEnabled { get { if (_modEnabled != null) { return _modEnabled.Value; } return false; } } internal bool IsEnableOnlyWhileRunning { get { if (_enableOnlyWhileRunning != null) { return _enableOnlyWhileRunning.Value; } return false; } } private void Awake() { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Expected O, but got Unknown Instance = this; Log = ((BaseUnityPlugin)this).Logger; _toggleKey = ((BaseUnityPlugin)this).Config.Bind("General", "ToggleKey", DefaultHotKey, "Hotkey to toggle infinite stamina."); _modEnabled = ((BaseUnityPlugin)this).Config.Bind("General", "Enabled", true, "Whether infinite stamina is enabled."); _enableOnlyWhileRunning = ((BaseUnityPlugin)this).Config.Bind("General", "EnableOnlyWhileRunning", false, "If true, stamina is only infinite while the player is running."); _toggleKey.SettingChanged += OnToggleKeyChanged; _harmony = new Harmony("com.hex.infinitestamina"); _harmony.PatchAll(); Log.LogInfo((object)"v1.1.0 loaded."); } private void Update() { //IL_000f: Unknown result type (might be due to invalid IL or missing references) if (!IsGameActive() || !IsShortcutPressedAllowingExtraKeys(_toggleKey.Value)) { return; } Player localPlayer = Player.m_localPlayer; _modEnabled.Value = !_modEnabled.Value; bool value = _modEnabled.Value; if (value) { float num = ((Character)localPlayer).GetMaxStamina() - localPlayer.GetStamina(); if (num > 0f) { ((Character)localPlayer).AddStamina(num); } } ShowStatus(value); } private void OnDestroy() { if (_toggleKey != null) { _toggleKey.SettingChanged -= OnToggleKeyChanged; } Harmony harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } _harmony = null; Log.LogInfo((object)"v1.1.0 unloaded."); Instance = null; } private bool IsGameActive() { if (Time.timeScale != 0f) { return (Object)(object)Player.m_localPlayer != (Object)null; } return false; } private void ShowStatus(bool isEnabled) { if (!(Time.time - _lastMessageTime < 0.2f)) { _lastMessageTime = Time.time; string text = (isEnabled ? "Infinite Stamina: ENABLED" : "Infinite Stamina: DISABLED"); Log.LogInfo((object)text); if ((Object)(object)MessageHud.instance != (Object)null) { MessageHud.instance.ShowMessage((MessageType)2, text, 0, (Sprite)null, false); } } } private void OnToggleKeyChanged(object sender, EventArgs e) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) string text = $"Hotkey updated -> {_toggleKey.Value}"; Log.LogInfo((object)text); if ((Object)(object)MessageHud.instance != (Object)null) { MessageHud.instance.ShowMessage((MessageType)2, text, 0, (Sprite)null, false); } } private static bool IsShortcutPressedAllowingExtraKeys(KeyboardShortcut shortcut) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) if ((int)((KeyboardShortcut)(ref shortcut)).MainKey == 0) { return false; } if (!Input.GetKeyDown(((KeyboardShortcut)(ref shortcut)).MainKey)) { return false; } foreach (KeyCode modifier in ((KeyboardShortcut)(ref shortcut)).Modifiers) { if (!Input.GetKey(modifier)) { return false; } } return true; } } } namespace InfiniteStaminaMod.Patches { [HarmonyPatch(typeof(Player), "CheckRun")] internal static class PlayerCheckRunPatch { internal static bool IsInsideCheckRun; [HarmonyPrefix] internal static void Prefix(Player __instance) { IsInsideCheckRun = false; InfiniteStaminaPlugin instance = InfiniteStaminaPlugin.Instance; if (!((Object)(object)instance == (Object)null) && instance.IsInfiniteStaminaEnabled && instance.IsEnableOnlyWhileRunning && !((Object)(object)Player.m_localPlayer == (Object)null) && !((Object)(object)__instance != (Object)(object)Player.m_localPlayer)) { IsInsideCheckRun = true; } } [HarmonyFinalizer] internal static void Finalizer() { IsInsideCheckRun = false; } } [HarmonyPatch(typeof(Player), "HaveStamina")] internal static class PlayerHaveStaminaPatch { [HarmonyPrefix] internal static bool ForceHaveStamina(ref bool __result, Player __instance) { InfiniteStaminaPlugin instance = InfiniteStaminaPlugin.Instance; if ((Object)(object)instance == (Object)null || !instance.IsInfiniteStaminaEnabled) { return true; } if (instance.IsEnableOnlyWhileRunning && !PlayerCheckRunPatch.IsInsideCheckRun) { return true; } if ((Object)(object)Player.m_localPlayer == (Object)null || (Object)(object)__instance != (Object)(object)Player.m_localPlayer) { return true; } __result = true; return false; } } [HarmonyPatch(typeof(Player), "UseStamina")] internal static class PlayerUseStaminaPatch { [HarmonyPrefix] internal static bool PreventStaminaUse(Player __instance) { InfiniteStaminaPlugin instance = InfiniteStaminaPlugin.Instance; if ((Object)(object)instance == (Object)null || !instance.IsInfiniteStaminaEnabled) { return true; } if ((Object)(object)Player.m_localPlayer == (Object)null || (Object)(object)__instance != (Object)(object)Player.m_localPlayer) { return true; } if (!instance.IsEnableOnlyWhileRunning) { return false; } if (PlayerCheckRunPatch.IsInsideCheckRun) { return false; } return true; } } }