Decompiled source of SteadyFood v0.1.3

BepInEx/plugins/SteadyFood/SteadyFood.dll

Decompiled 3 days ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using Jotunn.Utils;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyCompany("SteadyFood")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.1.3.0")]
[assembly: AssemblyInformationalVersion("0.1.3")]
[assembly: AssemblyProduct("SteadyFood")]
[assembly: AssemblyTitle("SteadyFood")]
[assembly: AssemblyVersion("0.1.3.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 SteadyFood
{
	[BepInPlugin("branchofyore.steadyfood", "SteadyFood", "0.1.3")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
	public sealed class Plugin : BaseUnityPlugin
	{
		[HarmonyPatch(typeof(Player), "GetTotalFoodValue")]
		private static class FoodTotals
		{
			private static void Prefix(Player __instance)
			{
				foreach (Food food in __instance.GetFoods())
				{
					if (food.m_item != null)
					{
						float num = Strength(food.m_time);
						food.m_health = food.m_item.m_shared.m_food * num;
						food.m_stamina = food.m_item.m_shared.m_foodStamina * num;
					}
				}
			}
		}

		public const string Id = "branchofyore.steadyfood";

		private Harmony harmony;

		public static ConfigEntry<int> FadeDuration { get; private set; }

		private void Awake()
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Expected O, but got Unknown
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Expected O, but got Unknown
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Expected O, but got Unknown
			FadeDuration = ((BaseUnityPlugin)this).Config.Bind<int>("Food", "Fade Duration Seconds", 60, new ConfigDescription("Seconds before food expires when health and stamina bonuses start fading. Default 60 = one minute; 600 = ten minutes; 0 = full bonus until expiration. Adjustable in whole seconds. Server synchronized.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 600), new object[1] { (object)new ConfigurationManagerAttributes
			{
				IsAdminOnly = true
			} }));
			harmony = new Harmony("branchofyore.steadyfood");
			harmony.PatchAll();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"SteadyFood: configurable food bonus fade enabled.");
		}

		private void OnDestroy()
		{
			Harmony obj = harmony;
			if (obj != null)
			{
				obj.UnpatchSelf();
			}
		}

		public static float Strength(float remaining)
		{
			if (remaining <= 0f)
			{
				return 0f;
			}
			float num = FadeDuration.Value;
			if (!(num <= 0f))
			{
				return Mathf.Clamp01(remaining / num);
			}
			return 1f;
		}
	}
}