using 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; [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("StartingEitrBonus")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("StartingEitrBonus")] [assembly: AssemblyTitle("StartingEitrBonus")] [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 StartingEitrBonus { [BepInPlugin("com.bcbry.valheim.startingeitrbonus", "Starting Eitr Bonus", "1.0.0")] public sealed class StartingEitrBonusPlugin : BaseUnityPlugin { public const string PluginGuid = "com.bcbry.valheim.startingeitrbonus"; public const string PluginName = "Starting Eitr Bonus"; public const string PluginVersion = "1.0.0"; internal static ConfigEntry ModEnabled; internal static ConfigEntry BaseEitrBonus; private readonly Harmony _harmony = new Harmony("com.bcbry.valheim.startingeitrbonus"); private void Awake() { //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Expected O, but got Unknown ModEnabled = ((BaseUnityPlugin)this).Config.Bind("General", "Enabled", true, "Enable or disable the starting Eitr bonus."); BaseEitrBonus = ((BaseUnityPlugin)this).Config.Bind("General", "BaseEitrBonus", 25f, new ConfigDescription("Amount of base Eitr to add before food bonuses. Set to 0 to keep vanilla behavior.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 500f), Array.Empty())); PatchTotalFoodValue(); ((BaseUnityPlugin)this).Logger.LogInfo((object)string.Format("{0} {1} loaded. Base Eitr bonus: {2}", "Starting Eitr Bonus", "1.0.0", BaseEitrBonus.Value)); } private void OnDestroy() { _harmony.UnpatchSelf(); } private void PatchTotalFoodValue() { //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Expected O, but got Unknown MethodInfo methodInfo = AccessTools.Method(typeof(Player), "GetTotalFoodValue", (Type[])null, (Type[])null) ?? AccessTools.Method(typeof(Player), "getTotalFoodValue", (Type[])null, (Type[])null); if (methodInfo == null) { ((BaseUnityPlugin)this).Logger.LogWarning((object)"Could not find Player.GetTotalFoodValue. The Eitr bonus patch was not applied."); return; } HarmonyMethod val = new HarmonyMethod(typeof(PlayerGetTotalFoodValuePatch), "Postfix", (Type[])null); _harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, val, (HarmonyMethod)null, (HarmonyMethod)null); } } internal static class PlayerGetTotalFoodValuePatch { internal static void Postfix(ref float eitr) { if (StartingEitrBonusPlugin.ModEnabled.Value) { float value = StartingEitrBonusPlugin.BaseEitrBonus.Value; if (!(value <= 0f)) { eitr += value; } } } } }