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 HealthTics v1.0.0
plugins\Oakwood.HealthTics\Oakwood.HealthTics.dll
Decompiled 4 days agousing System; using System.Diagnostics; using System.Reflection; 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.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyCompany("Oakwood.HealthTics")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("Oakwood.HealthTics")] [assembly: AssemblyTitle("Oakwood.HealthTics")] [assembly: AssemblyVersion("1.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [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 Oakwood.HealthTics { [BepInPlugin("org.oakwood.healthtics", "HealthTics", "1.0.0")] public sealed class HealthTicsPlugin : BaseUnityPlugin { [HarmonyPatch(typeof(Player), "UpdateFood")] private static class PlayerFoodPatch { private static void Prefix(Player __instance, float dt, bool forceUpdate, out float __state) { __state = 0f; if (!_enabled.Value || (Object)(object)__instance != (Object)(object)Player.m_localPlayer || forceUpdate) { return; } float num = 0f; foreach (Food food in __instance.GetFoods()) { if (food.m_item?.m_shared != null) { num += food.m_item.m_shared.m_foodRegen; } } if (num > 0f && ((Character)__instance).GetHealth() < ((Character)__instance).GetMaxHealth()) { float num2 = Mathf.Max(1f, _tickIntervalSeconds.Value); __state = num / num2 * dt; } AccessTools.Field(typeof(Player), "m_foodRegenTimer")?.SetValue(__instance, 0f); } private static void Postfix(Player __instance, float __state) { if (!(__state <= 0f) && !((Character)__instance).IsDead()) { float num = 1f; SEMan sEMan = ((Character)__instance).GetSEMan(); if (sEMan != null) { sEMan.ModifyHealthRegen(ref num); } float num2 = __state * Mathf.Max(0f, num); if (num2 > 0f) { ((Character)__instance).Heal(num2, false); } } } } public const string PluginGuid = "org.oakwood.healthtics"; public const string PluginName = "HealthTics"; public const string PluginVersion = "1.0.0"; private static ConfigEntry<bool> _enabled; private static ConfigEntry<float> _tickIntervalSeconds; private readonly Harmony _harmony = new Harmony("org.oakwood.healthtics"); private void Awake() { //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Expected O, but got Unknown _enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "Replace Valheim's 10-second food healing ticks with smooth continuous health regeneration."); _tickIntervalSeconds = ((BaseUnityPlugin)this).Config.Bind<float>("General", "VanillaTickInterval", 10f, new ConfigDescription("Vanilla food regen interval in seconds used to compute per-second rate (default 10s).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 30f), Array.Empty<object>())); _harmony.PatchAll(typeof(PlayerFoodPatch)); ((BaseUnityPlugin)this).Logger.LogInfo((object)"HealthTics v1.0.0 loaded."); } private void OnDestroy() { _harmony.UnpatchSelf(); } } }