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 BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
[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.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("CappedHungerDrain")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("TumbleLaunchRebalance")]
[assembly: AssemblyTitle("CappedHungerDrain")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.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 CappedHungerDrain
{
[BepInPlugin("CappedHungerDrain", "TumbleLaunchRebalance", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
internal static ManualLogSource Logger;
public static ConfigEntry<float> maxHunger;
public static ConfigEntry<bool> isRounded;
private void Awake()
{
Logger = ((BaseUnityPlugin)this).Logger;
Logger.LogInfo((object)"Plugin CappedHungerDrain is loading...");
maxHunger = ((BaseUnityPlugin)this).Config.Bind<float>("Settings", "MaxHunger", 0.33f, "Maximum hunger level the player can starve to. Default is 0.33 (33% of the bar).");
isRounded = ((BaseUnityPlugin)this).Config.Bind<bool>("Settings", "IsRounded", true, "If true, the hunger level will be rounded to the nearest 0.025. If false, it will be set to the exact value.");
Harmony.CreateAndPatchAll(typeof(Plugin), "CappedHungerDrain");
Logger.LogInfo((object)"Plugin CappedHungerDrain is loaded...");
}
[HarmonyPatch(typeof(CharacterAfflictions), "UpdateNormalStatuses")]
[HarmonyPostfix]
public static void Postfix_CharacterAffliction_AddAffliction(CharacterAfflictions __instance)
{
float currentStatus = __instance.GetCurrentStatus((STATUSTYPE)1);
if (!(currentStatus < maxHunger.Value))
{
float num = __instance.GetCurrentStatus((STATUSTYPE)1) - maxHunger.Value;
if (isRounded.Value)
{
num = (float)Math.Round((double)num / 0.025) * 0.025f;
}
__instance.SubtractStatus((STATUSTYPE)1, num, false);
}
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "CappedHungerDrain";
public const string PLUGIN_NAME = "TumbleLaunchRebalance";
public const string PLUGIN_VERSION = "1.0.0";
}
}