using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using JetBrains.Annotations;
using Jotunn.Entities;
using Jotunn.Managers;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.6.2", FrameworkDisplayName = ".NET Framework 4.6.2")]
[assembly: AssemblyCompany("VitalityFix")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("VitalityFix")]
[assembly: AssemblyTitle("VitalityFix")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace VitalityFix;
[BepInPlugin("com.dew.vitalityfix", "VitalityFix", "0.0.1")]
[BepInDependency("com.jotunn.jotunn", "2.20.1")]
[BepInDependency("org.bepinex.plugins.vitality", "1.1.2")]
public class Plugin : BaseUnityPlugin
{
private class ReloadConfigCommand : ConsoleCommand
{
public override string Name => "vitality_reloadconfig";
public override string Help => "Reloads the config for Vitality";
public override bool IsCheat => true;
public override bool OnlyServer => true;
public override void Run(string[] args)
{
((BaseUnityPlugin)_instance).Config.Reload();
}
}
[HarmonyPatch]
private static class Patches
{
[HarmonyPatch(typeof(Player), "Load")]
[HarmonyPostfix]
private static void Player_Load(Player __instance)
{
//IL_001b: 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)
SkillDef skill = SkillManager.Instance.GetSkill("Vitality");
if (skill != null)
{
Vitality = skill.m_skill;
}
}
[HarmonyPatch(typeof(Player), "EatFood")]
[HarmonyPostfix]
private static void Player_EatFood(Player __instance, ItemData item, ref bool __result)
{
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
if (__result)
{
float food = item.m_shared.m_food;
float foodStamina = item.m_shared.m_foodStamina;
float num = (float)Math.Sqrt((food > foodStamina) ? food : foodStamina);
((Character)__instance).RaiseSkill(Vitality, num);
}
}
[HarmonyPatch(typeof(Player), "SetMaxHealth")]
[HarmonyPrefix]
private static void Player_SetMaxHealth(Player __instance, ref float health, bool flashBar)
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
health += ((Character)__instance).GetSkillFactor(Vitality) * cfgMaxHealth.Value;
}
[HarmonyPatch(typeof(Player), "GetMaxCarryWeight")]
[HarmonyPostfix]
private static void Player_GetMaxCarryWeight(Player __instance, ref float __result)
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
__result += ((Character)__instance).GetSkillFactor(Vitality) * cfgMaxWeight.Value;
}
}
public const string GUID = "com.dew.vitalityfix";
public const string ModName = "VitalityFix";
public const string Version = "0.0.1";
public static SkillType Vitality;
private static ConfigEntry<float> cfgMaxHealth;
private static ConfigEntry<float> cfgMaxWeight;
public static Plugin _instance;
[UsedImplicitly]
private void Awake()
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Expected O, but got Unknown
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: Expected O, but got Unknown
//IL_006e: Unknown result type (might be due to invalid IL or missing references)
//IL_0078: Expected O, but got Unknown
_instance = this;
ConfigurationManagerAttributes val = new ConfigurationManagerAttributes
{
IsAdminOnly = true
};
cfgMaxHealth = ((BaseUnityPlugin)this).Config.Bind<float>("General", "MaxHealth", 150f, new ConfigDescription("Max health a player can have without food", (AcceptableValueBase)null, new object[1] { val }));
cfgMaxWeight = ((BaseUnityPlugin)this).Config.Bind<float>("General", "MaxWeight", 100f, new ConfigDescription("Max weight", (AcceptableValueBase)null, new object[1] { val }));
CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new ReloadConfigCommand());
Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "com.dew.vitalityfix");
}
}