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 SteadyHeart v1.1.0
SteadyHeart.dll
Decompiled a month agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.6.2", FrameworkDisplayName = ".NET Framework 4.6.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 SteadyHeart { [BepInPlugin("metalpietie.steadyheart", "SteadyHeart", "1.1.0")] public class SteadyHeartPlugin : BaseUnityPlugin { public const string PluginGuid = "metalpietie.steadyheart"; public const string PluginName = "SteadyHeart"; public const string PluginVersion = "1.1.0"; internal static ConfigEntry<float> DamageMultiplier; internal static ConfigEntry<float> StaminaMultiplier; internal static ConfigEntry<float> EitrMultiplier; internal static ConfigEntry<bool> KeepFoodHealth; internal static ConfigEntry<bool> KeepFoodStamina; internal static ConfigEntry<bool> KeepFoodEitr; private void Awake() { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Expected O, but got Unknown //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Expected O, but got Unknown //IL_011c: Unknown result type (might be due to invalid IL or missing references) DamageMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("General", "DamageMultiplier", 0.5f, new ConfigDescription("Damage you take is multiplied by this. 0.5 = half damage.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>())); StaminaMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("General", "StaminaMultiplier", 0.5f, new ConfigDescription("Stamina you use is multiplied by this. 0.5 = half stamina use.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>())); EitrMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("General", "EitrMultiplier", 0.5f, new ConfigDescription("Eitr you use is multiplied by this. 0.5 = half eitr use.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>())); KeepFoodHealth = ((BaseUnityPlugin)this).Config.Bind<bool>("Food", "KeepFoodHealthUntilExpired", false, "Normally the extra max health from food shrinks while the food timer runs down. On = the extra max health stays full until the food timer runs out."); KeepFoodStamina = ((BaseUnityPlugin)this).Config.Bind<bool>("Food", "KeepFoodStaminaUntilExpired", false, "Normally the extra max stamina from food shrinks while the food timer runs down. On = the extra max stamina stays full until the food timer runs out."); KeepFoodEitr = ((BaseUnityPlugin)this).Config.Bind<bool>("Food", "KeepFoodEitrUntilExpired", false, "Normally the extra max eitr from food shrinks while the food timer runs down. On = the extra max eitr stays full until the food timer runs out."); new Harmony("metalpietie.steadyheart").PatchAll(); } } [HarmonyPatch(typeof(Player), "UseStamina")] internal static class UseStaminaPatch { private static void Prefix(Player __instance, ref float v) { if ((Object)(object)__instance == (Object)(object)Player.m_localPlayer) { v *= SteadyHeartPlugin.StaminaMultiplier.Value; } } } [HarmonyPatch(typeof(Player), "UseEitr")] internal static class UseEitrPatch { private static void Prefix(Player __instance, ref float v) { if ((Object)(object)__instance == (Object)(object)Player.m_localPlayer) { v *= SteadyHeartPlugin.EitrMultiplier.Value; } } } [HarmonyPatch(typeof(Character), "RPC_Damage")] internal static class DamagePatch { private static void Prefix(Character __instance, HitData hit) { if (hit != null && (Object)(object)__instance == (Object)(object)Player.m_localPlayer) { ((DamageTypes)(ref hit.m_damage)).Modify(SteadyHeartPlugin.DamageMultiplier.Value); } } } [HarmonyPatch(typeof(Player), "UpdateFood")] internal static class UpdateFoodPatch { private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) { foreach (CodeInstruction instruction in instructions) { if (instruction.opcode == OpCodes.Stfld && instruction.operand is FieldInfo fieldInfo && fieldInfo.DeclaringType == typeof(Food)) { string text = null; if (fieldInfo.Name == "m_health") { text = "SetHealth"; } else if (fieldInfo.Name == "m_stamina") { text = "SetStamina"; } else if (fieldInfo.Name == "m_eitr") { text = "SetEitr"; } if (text != null) { yield return new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(UpdateFoodPatch), text, (Type[])null, (Type[])null)); continue; } } yield return instruction; } } private static void SetHealth(Food food, float shrunk) { food.m_health = (SteadyHeartPlugin.KeepFoodHealth.Value ? food.m_item.m_shared.m_food : shrunk); } private static void SetStamina(Food food, float shrunk) { food.m_stamina = (SteadyHeartPlugin.KeepFoodStamina.Value ? food.m_item.m_shared.m_foodStamina : shrunk); } private static void SetEitr(Food food, float shrunk) { food.m_eitr = (SteadyHeartPlugin.KeepFoodEitr.Value ? food.m_item.m_shared.m_foodEitr : shrunk); } } }