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 Health Stamina Eitr Manager v1.0.1
HSEManager.dll
Decompiled 2 days agousing System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Jotunn.Utils; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyVersion("0.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace HSEManager { [BepInPlugin("valesthor.hsemanager", "Health, Stamina & Eitr - Manager", "1.0.1")] [BepInDependency(/*Could not decode attribute arguments.*/)] [NetworkCompatibility(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { public const string PluginGUID = "valesthor.hsemanager"; public const string PluginName = "Health, Stamina & Eitr - Manager"; public const string PluginVersion = "1.0.1"; internal static ManualLogSource Log; public static ConfigEntry<float> BaseHealth; public static ConfigEntry<float> BaseStamina; public static ConfigEntry<float> BaseEitr; public static ConfigEntry<float> HealthRegenPerSecond; public static ConfigEntry<float> StaminaRegenPerSecond; public static ConfigEntry<float> EitrRegenPerSecond; public static ConfigEntry<bool> InfiniteStamina; public static ConfigEntry<bool> InfiniteEitr; public static ConfigEntry<bool> FixedHealthBar; public static ConfigEntry<bool> FixedStaminaBar; public static ConfigEntry<bool> FixedEitrBar; public static ConfigEntry<bool> AlwaysShowStaminaBar; public static ConfigEntry<bool> AlwaysShowEitrBar; private Harmony _harmony; private void Awake() { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected O, but got Unknown //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Expected O, but got Unknown //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Expected O, but got Unknown //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Expected O, but got Unknown //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Expected O, but got Unknown //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Expected O, but got Unknown //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Expected O, but got Unknown //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Expected O, but got Unknown //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Expected O, but got Unknown //IL_0256: Unknown result type (might be due to invalid IL or missing references) //IL_0260: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; ConfigurationManagerAttributes val = new ConfigurationManagerAttributes { IsAdminOnly = true }; BaseHealth = ((BaseUnityPlugin)this).Config.Bind<float>("01. Health", "BaseHealth", 25f, new ConfigDescription("Base health value for the local player, before food bonuses are added. Vanilla default is 25. Server-authoritative: locked to the server's value while connected to a multiplayer server.", (AcceptableValueBase)null, new object[1] { val })); BaseStamina = ((BaseUnityPlugin)this).Config.Bind<float>("02. Stamina", "BaseStamina", 75f, new ConfigDescription("Base stamina value for the local player, before food bonuses are added. Vanilla default is 75. Server-authoritative: locked to the server's value while connected to a multiplayer server.", (AcceptableValueBase)null, new object[1] { val })); InfiniteStamina = ((BaseUnityPlugin)this).Config.Bind<bool>("02. Stamina", "InfiniteStamina", false, new ConfigDescription("If enabled, stamina is never actually consumed. All vanilla actions and their calculations still run normally. Default: disabled. Server-authoritative: locked to the server's value while connected to a multiplayer server.", (AcceptableValueBase)null, new object[1] { val })); BaseEitr = ((BaseUnityPlugin)this).Config.Bind<float>("03. Eitr", "BaseEitr", 0f, new ConfigDescription("Base Eitr value for the local player, before food bonuses are added. Vanilla default is 0 (Eitr normally comes entirely from food). Server-authoritative: locked to the server's value while connected to a multiplayer server.", (AcceptableValueBase)null, new object[1] { val })); InfiniteEitr = ((BaseUnityPlugin)this).Config.Bind<bool>("03. Eitr", "InfiniteEitr", false, new ConfigDescription("If enabled, Eitr is never actually consumed. All vanilla spells and their calculations still run normally. Default: disabled. Server-authoritative: locked to the server's value while connected to a multiplayer server.", (AcceptableValueBase)null, new object[1] { val })); HealthRegenPerSecond = ((BaseUnityPlugin)this).Config.Bind<float>("04. Regeneration", "HealthRegenPerSecond", 0f, new ConfigDescription("Extra health regeneration per second, on top of vanilla regen. Works independently of food and Comfort. 0 = disabled (default). Server-authoritative: locked to the server's value while connected to a multiplayer server.", (AcceptableValueBase)null, new object[1] { val })); StaminaRegenPerSecond = ((BaseUnityPlugin)this).Config.Bind<float>("04. Regeneration", "StaminaRegenPerSecond", 0f, new ConfigDescription("Extra stamina regeneration per second, on top of vanilla regen. Works independently of food and Comfort. 0 = disabled (default). Server-authoritative: locked to the server's value while connected to a multiplayer server.", (AcceptableValueBase)null, new object[1] { val })); EitrRegenPerSecond = ((BaseUnityPlugin)this).Config.Bind<float>("04. Regeneration", "EitrRegenPerSecond", 0f, new ConfigDescription("Extra Eitr regeneration per second, on top of vanilla regen. Works independently of food and Comfort. 0 = disabled (default). Server-authoritative: locked to the server's value while connected to a multiplayer server.", (AcceptableValueBase)null, new object[1] { val })); FixedHealthBar = ((BaseUnityPlugin)this).Config.Bind<bool>("05. HUD", "FixedHealthBar", false, "If enabled, the health bar keeps a fixed visual width (as if max health were 100), regardless of actual max health. Values and fill percentage are unaffected. Default: disabled."); FixedStaminaBar = ((BaseUnityPlugin)this).Config.Bind<bool>("05. HUD", "FixedStaminaBar", false, "If enabled, the stamina bar keeps a fixed visual width (as if max stamina were 100), regardless of actual max stamina. Values and fill percentage are unaffected. Default: disabled."); AlwaysShowStaminaBar = ((BaseUnityPlugin)this).Config.Bind<bool>("05. HUD", "AlwaysShowStaminaBar", false, "If enabled, the stamina bar stays visible at all times, even when full and unused. Has no effect if Infinite Stamina is on (bar already stays hidden in that case). Default: disabled."); FixedEitrBar = ((BaseUnityPlugin)this).Config.Bind<bool>("05. HUD", "FixedEitrBar", false, "If enabled, the Eitr bar keeps a fixed visual width (as if max Eitr were 100), regardless of actual max Eitr. Values and fill percentage are unaffected. Default: disabled."); AlwaysShowEitrBar = ((BaseUnityPlugin)this).Config.Bind<bool>("05. HUD", "AlwaysShowEitrBar", false, "If enabled, the Eitr bar stays visible at all times, even when full and unused. Has no effect if Infinite Eitr is on (bar already stays hidden in that case). Default: disabled."); _harmony = new Harmony("valesthor.hsemanager"); _harmony.PatchAll(); Log.LogInfo((object)string.Format("{0} v{1} loaded. BaseHealth = {2}, BaseStamina = {3}, BaseEitr = {4} HealthRegenPerSecond = {5}, StaminaRegenPerSecond = {6}, EitrRegenPerSecond = {7} InfiniteStamina = {8}, InfiniteEitr = {9} FixedHealthBar = {10}, FixedStaminaBar = {11}, FixedEitrBar = {12} AlwaysShowStaminaBar = {13}, AlwaysShowEitrBar = {14}", "Health, Stamina & Eitr - Manager", "1.0.1", BaseHealth.Value, BaseStamina.Value, BaseEitr.Value, HealthRegenPerSecond.Value, StaminaRegenPerSecond.Value, EitrRegenPerSecond.Value, InfiniteStamina.Value, InfiniteEitr.Value, FixedHealthBar.Value, FixedStaminaBar.Value, FixedEitrBar.Value, AlwaysShowStaminaBar.Value, AlwaysShowEitrBar.Value)); } } } namespace HSEManager.Patches { [HarmonyPatch(typeof(Player), "GetTotalFoodValue")] public static class Player_GetTotalFoodValue_BaseEitr_Patch { [HarmonyPostfix] public static void Postfix(ref float eitr) { eitr += Plugin.BaseEitr.Value; } } public static class FixedHudPatch { [HarmonyPatch(typeof(Hud), "SetHealthBarSize")] public static class SetHealthBarSize_Patch { [HarmonyPrefix] public static void Prefix(ref float size) { if (Plugin.FixedHealthBar.Value) { size = 128f; } } } [HarmonyPatch(typeof(Hud), "SetStaminaBarSize")] public static class SetStaminaBarSize_Patch { [HarmonyPrefix] public static void Prefix(ref float size) { if (Plugin.FixedStaminaBar.Value) { size = 128f; } } } [HarmonyPatch(typeof(Hud), "SetEitrBarSize")] public static class SetEitrBarSize_Patch { [HarmonyPrefix] public static void Prefix(ref float size) { if (Plugin.FixedEitrBar.Value) { size = 128f; } } } private const float ReferenceBarSize = 128f; } [HarmonyPatch(typeof(Hud), "UpdateStamina")] public static class Hud_UpdateStamina_AlwaysShow_Patch { [HarmonyPostfix] public static void Postfix(Hud __instance) { if (Plugin.AlwaysShowStaminaBar.Value) { __instance.m_staminaAnimator.SetBool("Visible", true); } } } [HarmonyPatch(typeof(Hud), "UpdateEitr")] public static class Hud_UpdateEitr_AlwaysShow_Patch { [HarmonyPostfix] public static void Postfix(Hud __instance) { if (Plugin.AlwaysShowEitrBar.Value) { __instance.m_eitrAnimator.SetBool("Visible", true); } } } [HarmonyPatch(typeof(Player), "Awake")] public static class Player_Awake_BaseHealth_Patch { [HarmonyPostfix] public static void Postfix(Player __instance) { __instance.m_baseHP = Plugin.BaseHealth.Value; Plugin.Log.LogInfo((object)$"[HSE] Applied BaseHealth={Plugin.BaseHealth.Value} to Player instance."); } } [HarmonyPatch(typeof(Player), "RPC_UseStamina")] public static class Player_RPC_UseStamina_Infinite_Patch { [HarmonyPrefix] public static bool Prefix(Player __instance) { if ((Object)(object)__instance != (Object)(object)Player.m_localPlayer) { return true; } return !Plugin.InfiniteStamina.Value; } } [HarmonyPatch(typeof(Player), "RPC_UseEitr")] public static class Player_RPC_UseEitr_Infinite_Patch { [HarmonyPrefix] public static bool Prefix(Player __instance) { if ((Object)(object)__instance != (Object)(object)Player.m_localPlayer) { return true; } return !Plugin.InfiniteEitr.Value; } } [HarmonyPatch(typeof(Player), "UpdateStats", new Type[] { typeof(float) })] public static class Player_UpdateStats_ExtraRegen_Patch { [HarmonyPostfix] public static void Postfix(Player __instance, float dt) { if (!((Object)(object)__instance != (Object)(object)Player.m_localPlayer)) { float value = Plugin.HealthRegenPerSecond.Value; if (value > 0f) { ((Character)__instance).Heal(value * dt, false); } float value2 = Plugin.StaminaRegenPerSecond.Value; if (value2 > 0f) { ((Character)__instance).AddStamina(value2 * dt); } float value3 = Plugin.EitrRegenPerSecond.Value; if (value3 > 0f) { ((Character)__instance).AddEitr(value3 * dt); } } } } [HarmonyPatch(typeof(Player), "Awake")] public static class Player_Awake_BaseStamina_Patch { [HarmonyPostfix] public static void Postfix(Player __instance) { __instance.m_baseStamina = Plugin.BaseStamina.Value; Plugin.Log.LogInfo((object)$"[HSE] Applied BaseStamina={Plugin.BaseStamina.Value} to Player instance."); } } }