using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("InstantRestoreStamina")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("InstantRestoreStamina")] [assembly: AssemblyCopyright("Copyright © 2025")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("fe8851ca-746a-411a-b889-605e2e2ab95a")] [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 InstantRestoreStamina { [BepInPlugin("nexor.InstantRestoreStamina", "InstantRestoreStamina", "1.0.0")] public class InstantRestoreStamina : BaseUnityPlugin { private const string modGUID = "nexor.InstantRestoreStamina"; private const string modName = "InstantRestoreStamina"; private const string modVersion = "1.0.0"; private readonly Harmony harmony = new Harmony("nexor.InstantRestoreStamina"); public static InstantRestoreStamina Instance; internal static ConfigEntry BaseMultiplier; internal static ConfigEntry EnableTemperatureScaling; internal const float BaseThreshold = 0.1f; internal const float AfflictionFullValue = 600f; internal const bool VerboseLog = false; private void Awake() { if ((Object)(object)Instance == (Object)null) { Instance = this; } BaseMultiplier = ((BaseUnityPlugin)this).Config.Bind("General", "BaseMultiplier", 10f, "基础体力恢复倍率(默认10)"); EnableTemperatureScaling = ((BaseUnityPlugin)this).Config.Bind("General", "EnableTemperatureScaling", true, "是否让恢复倍率受异常温度影响"); harmony.PatchAll(); ((BaseUnityPlugin)this).Logger.LogInfo((object)string.Format("{0} {1} loaded. BaseMultiplier={2}, EnableTemperatureScaling={3}", "InstantRestoreStamina", "1.0.0", BaseMultiplier.Value, EnableTemperatureScaling.Value)); } } } namespace InstantRestoreStamina.Patches { [HarmonyPatch(typeof(StaminaBar))] internal static class StaminaBarTap { internal static readonly Dictionary AffRaw = new Dictionary(); private static float lastLogTime; [HarmonyPatch("Update")] [HarmonyPostfix] private static void PostUpdate(StaminaBar __instance) { //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) if (__instance?.afflictions == null) { return; } BarAffliction[] afflictions = __instance.afflictions; foreach (BarAffliction val in afflictions) { if (!((Object)(object)val == (Object)null)) { STATUSTYPE afflictionType = val.afflictionType; AffRaw[afflictionType] = val.size; } } bool flag = false; } internal static float GetRaw(STATUSTYPE t) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) float value; return AffRaw.TryGetValue(t, out value) ? value : 0f; } internal static float GetNorm(STATUSTYPE t) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return GetRaw(t) / 600f; } } [HarmonyPatch(typeof(Character))] internal class CharacterPatch { [HarmonyPatch("AddStamina")] [HarmonyPrefix] private static void AddStaminaPrefix(ref float add) { float value = InstantRestoreStamina.BaseMultiplier.Value; float num = value; if (InstantRestoreStamina.EnableTemperatureScaling.Value) { float norm = StaminaBarTap.GetNorm((STATUSTYPE)2); float norm2 = StaminaBarTap.GetNorm((STATUSTYPE)8); float num2 = Mathf.Max(0.1f - (norm + norm2), 0f) / 0.1f; num = Mathf.Max((value - 1f) * num2 + 1f, 1f); bool flag = false; } add *= num; } } }