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 Sated v1.3.3
Sated.dll
Decompiled 4 days agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using ConditionalConfigSync; using HarmonyLib; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("Sated")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("Crystal")] [assembly: AssemblyProduct("Sated")] [assembly: AssemblyCopyright("Copyright © 2026 Crystal")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("06b242d5-3a1a-407a-a9d1-a816c4750099")] [assembly: AssemblyFileVersion("1.3.3.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyVersion("1.3.3.0")] namespace Sated; [BepInPlugin("dev.crystal.sated", "Sated", "1.3.3.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInProcess("valheim.exe")] [BepInProcess("valheim_server.exe")] public class SatedPlugin : BaseUnityPlugin { [HarmonyPatch(typeof(Player))] private static class Player_Patches { private enum TranspilerState { Searching, Checking1, Checking2, ReplacingHp, ReplacingStamina, ReplacingEitr, Finishing } [HarmonyPatch("GetTotalFoodValue")] [HarmonyTranspiler] private static IEnumerable<CodeInstruction> GetTotalFoodValue_Transpiler(IEnumerable<CodeInstruction> instructions) { TranspilerState state = TranspilerState.Searching; foreach (CodeInstruction instruction in instructions) { switch (state) { case TranspilerState.Searching: if (instruction.opcode == OpCodes.Ldloca_S) { state = TranspilerState.Checking1; } yield return instruction; break; case TranspilerState.Checking1: state = ((instruction.opcode == OpCodes.Call) ? TranspilerState.Checking2 : TranspilerState.Searching); yield return instruction; break; case TranspilerState.Checking2: state = ((instruction.opcode == OpCodes.Stloc_1) ? TranspilerState.ReplacingHp : TranspilerState.Searching); yield return instruction; break; case TranspilerState.ReplacingHp: if (instruction.opcode == OpCodes.Ldfld) { yield return new CodeInstruction(OpCodes.Call, (object)typeof(Player_Patches).GetMethod("GetHp", BindingFlags.Static | BindingFlags.NonPublic)); state = TranspilerState.ReplacingStamina; } else { yield return instruction; } break; case TranspilerState.ReplacingStamina: if (instruction.opcode == OpCodes.Ldfld) { yield return new CodeInstruction(OpCodes.Call, (object)typeof(Player_Patches).GetMethod("GetStamina", BindingFlags.Static | BindingFlags.NonPublic)); state = TranspilerState.ReplacingEitr; } else { yield return instruction; } break; case TranspilerState.ReplacingEitr: if (instruction.opcode == OpCodes.Ldfld) { yield return new CodeInstruction(OpCodes.Call, (object)typeof(Player_Patches).GetMethod("GetEitr", BindingFlags.Static | BindingFlags.NonPublic)); state = TranspilerState.Finishing; } else { yield return instruction; } break; case TranspilerState.Finishing: yield return instruction; break; } } } private static float GetHp(Food food) { return (1f - Mathf.Pow(GetTime(food), HealthCurveExponent.Value)) * food.m_item.m_shared.m_food; } private static float GetStamina(Food food) { return (1f - Mathf.Pow(GetTime(food), StaminaCurveExponent.Value)) * food.m_item.m_shared.m_foodStamina; } private static float GetEitr(Food food) { return (1f - Mathf.Pow(GetTime(food), EitrCurveExponent.Value)) * food.m_item.m_shared.m_foodEitr; } private static float GetTime(Food food) { return 1f - food.m_time / food.m_item.m_shared.m_foodBurnTime; } } public const string ModId = "dev.crystal.sated"; public const string ModName = "Sated"; public const string ModVersion = "1.3.3.0"; internal static readonly ConfigSync ConfigSync; public static ConfigEntry<float> HealthCurveExponent; public static ConfigEntry<float> StaminaCurveExponent; public static ConfigEntry<float> EitrCurveExponent; private static Harmony sPlayerHarmony; static SatedPlugin() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0020: 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) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Expected O, but got Unknown ConfigSync = new ConfigSync("dev.crystal.sated") { DisplayName = "Sated", CurrentVersion = "1.3.3.0", MinimumRequiredVersion = "1.3.3.0", ModRequired = false, ModRequirementMode = (ModRequirementMode)1 }; } private void Awake() { //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Expected O, but got Unknown HealthCurveExponent = ((BaseUnityPlugin)this).Config.Bind<float>("Food", "HealthCurveExponent", 8f, "The value of the exponent 'e' used in the food curve formula 'y = 1 - x^e' for calculating added health. Valid range 0.1 - 100. Higher values make you full longer, but also drop off more suddenly. A value of 1 indicates a linear decline. Values less than 1 invert the curve, causing a faster initial decline which gradually slows down. [The value will be enforced on a server.]"); HealthCurveExponent.SettingChanged += CurveExponent_SettingChanged; ((ConditionalConfigSync)ConfigSync).AddConfigEntry<float>(HealthCurveExponent, (ConfigSyncMode)0); StaminaCurveExponent = ((BaseUnityPlugin)this).Config.Bind<float>("Food", "StaminaCurveExponent", 8f, "The value of the exponent 'e' used in the food curve formula 'y = 1 - x^e' for calculating added stamina. Valid range 0.1 - 100. Higher values make you full longer, but also drop off more suddenly. A value of 1 indicates a linear decline. Values less than 1 invert the curve, causing a faster initial decline which gradually slows down. [The value will be enforced on a server.]"); StaminaCurveExponent.SettingChanged += CurveExponent_SettingChanged; ((ConditionalConfigSync)ConfigSync).AddConfigEntry<float>(StaminaCurveExponent, (ConfigSyncMode)0); EitrCurveExponent = ((BaseUnityPlugin)this).Config.Bind<float>("Food", "EitrCurveExponent", 8f, "The value of the exponent 'e' used in the food curve formula 'y = 1 - x^e' for calculating added eitr. Valid range 0.1 - 100. Higher values make you full longer, but also drop off more suddenly. A value of 1 indicates a linear decline. Values less than 1 invert the curve, causing a faster initial decline which gradually slows down. [The value will be enforced on a server.]"); EitrCurveExponent.SettingChanged += CurveExponent_SettingChanged; ((ConditionalConfigSync)ConfigSync).AddConfigEntry<float>(EitrCurveExponent, (ConfigSyncMode)0); ClampConfig(); sPlayerHarmony = new Harmony("dev.crystal.sated_Player"); sPlayerHarmony.PatchAll(typeof(Player_Patches)); } private void OnDestroy() { sPlayerHarmony.UnpatchSelf(); } private static void ClampConfig() { if (HealthCurveExponent.Value < 0.1f) { HealthCurveExponent.Value = 0.1f; } if (HealthCurveExponent.Value > 100f) { HealthCurveExponent.Value = 100f; } if (StaminaCurveExponent.Value < 0.1f) { StaminaCurveExponent.Value = 0.1f; } if (StaminaCurveExponent.Value > 100f) { StaminaCurveExponent.Value = 100f; } if (EitrCurveExponent.Value < 0.1f) { EitrCurveExponent.Value = 0.1f; } if (EitrCurveExponent.Value > 100f) { EitrCurveExponent.Value = 100f; } } private void CurveExponent_SettingChanged(object sender, EventArgs e) { ClampConfig(); } private static AssetBundle LoadAssetBundle(string name) { Assembly callingAssembly = Assembly.GetCallingAssembly(); return AssetBundle.LoadFromStream(callingAssembly.GetManifestResourceStream(callingAssembly.GetName().Name + "." + name)); } }