AAV.dll

Decompiled 6 months ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using HarmonyLib;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("AAV")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("AAV")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("7419a03a-6330-44ae-94f4-8c1987b7aa20")]
[assembly: AssemblyFileVersion("1.0.2")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.2.0")]
namespace AAV
{
	[BepInPlugin("mayo.is.an.instrument.aav", "AAV", "1.0.2")]
	public class AAV : BaseUnityPlugin
	{
		public const string PluginGuid = "mayo.is.an.instrument.aav";

		public const string PluginName = "AAV";

		public const string PluginVersion = "1.0.2";

		public static float HPercent;

		public static float SPercent;

		private Harmony _harmony;

		public void Awake()
		{
			_harmony = Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "mayo.is.an.instrument.aav");
		}

		public void OnDestroy()
		{
			Harmony harmony = _harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
		}
	}
}
namespace AAV.Patches
{
	[HarmonyPatch(typeof(Player))]
	internal class PlayerPatch
	{
		[HarmonyPostfix]
		[HarmonyPatch("CanConsumeItem")]
		private static void CanConsumeItemPostfix(Player __instance, ref bool __result, ItemData item)
		{
			AAV.HPercent = ((Character)__instance).GetHealthPercentage();
			AAV.SPercent = ((Character)__instance).GetStaminaPercentage();
			string name = item.m_shared.m_name;
			switch (name)
			{
			case "$item_mead_hp_major":
			case "$item_mead_hp_medium":
			case "$item_mead_hp_minor":
				if ((double)AAV.HPercent >= 0.9)
				{
					ZLog.Log((object)$"Health Percentage is {AAV.HPercent * 100f} so {name} should not be consumed.");
					((Character)__instance).Message((MessageType)2, "You've had enough", 0, (Sprite)null);
					__result = false;
				}
				break;
			}
			if ((name == "$item_mead_stamina_medium" || name == "$item_mead_stamina_minor") && (double)AAV.SPercent >= 0.9)
			{
				ZLog.Log((object)$"Stamina Percentage is {AAV.SPercent * 100f} so {name} should not be consumed.");
				((Character)__instance).Message((MessageType)2, "You've had enough", 0, (Sprite)null);
				__result = false;
			}
		}
	}
}