Decompiled source of HealingBanana v1.0.0

HealthDrink.dll

Decompiled 3 months ago
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using HealthDrink.Behavior;
using LethalLib.Modules;
using Unity.Netcode;
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("HealthDrink")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("HealthDrink")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("6d134475-e449-4c5b-be6e-38c9a31444b0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace HealthDrink
{
	[BepInPlugin("Nono.HealthDrink", "Health Drink", "1.0.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		private const string modGUID = "Nono.HealthDrink";

		private const string modName = "Health Drink";

		private const string modVersion = "1.0.0.0";

		private readonly Harmony harmony = new Harmony("Nono.HealthDrink");

		private static Plugin Instance;

		internal static ManualLogSource Logger;

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "healthitem");
			AssetBundle val = AssetBundle.LoadFromFile(text);
			Item val2 = val.LoadAsset<Item>("Assets/HealthDrink.asset");
			HealPlayer healPlayer = val2.spawnPrefab.AddComponent<HealPlayer>();
			((GrabbableObject)healPlayer).grabbable = true;
			((GrabbableObject)healPlayer).grabbableToEnemies = true;
			((GrabbableObject)healPlayer).itemProperties = val2;
			NetworkPrefabs.RegisterNetworkPrefab(val2.spawnPrefab);
			Utilities.FixMixerGroups(val2.spawnPrefab);
			Items.RegisterScrap(val2, 50, (LevelTypes)(-1));
			Logger = ((BaseUnityPlugin)this).Logger;
			Logger.LogInfo((object)"It's healing time!!!!");
			harmony.PatchAll(typeof(Plugin));
		}
	}
}
namespace HealthDrink.Behavior
{
	internal class HealPlayer : PhysicsProp
	{
		private readonly string[] allLines = new string[1] { "Consume Healing Banana: [RMB]" };

		public override void SetControlTipsForItem()
		{
			((GrabbableObject)this).SetControlTipsForItem();
			if (((NetworkBehaviour)this).IsOwner && (Object)(object)((GrabbableObject)this).playerHeldBy != (Object)null)
			{
				HUDManager.Instance.ChangeControlTipMultiple(allLines, true, ((GrabbableObject)this).itemProperties);
				Plugin.Logger.LogDebug((object)"UI THING");
			}
			else
			{
				HUDManager.Instance.ClearControlTips();
			}
		}

		public override void ItemActivate(bool used, bool buttonDown = true)
		{
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			((GrabbableObject)this).ItemActivate(used, buttonDown);
			Plugin.Logger.LogDebug((object)$"Health: {((GrabbableObject)this).playerHeldBy.health}");
			if (buttonDown && ((GrabbableObject)this).playerHeldBy.health < 100)
			{
				if (((GrabbableObject)this).playerHeldBy.health < 100)
				{
					int health = Mathf.Min(((GrabbableObject)this).playerHeldBy.health + 10, 100);
					((GrabbableObject)this).playerHeldBy.health = health;
					Plugin.Logger.LogDebug((object)$"Health (Healing): {((GrabbableObject)this).playerHeldBy.health}");
					if (((GrabbableObject)this).playerHeldBy.health >= 100)
					{
						HUDManager.Instance.selfRedCanvasGroup.alpha = 0f;
					}
				}
				HUDManager.Instance.flashFilter = 0.14f;
				Object.Destroy((Object)(object)((Component)this).gameObject);
				((GrabbableObject)this).playerHeldBy.DiscardHeldObject(false, (NetworkObject)null, default(Vector3), true);
			}
			else
			{
				Plugin.Logger.LogDebug((object)$"Health (Full): {((GrabbableObject)this).playerHeldBy.health}");
			}
		}
	}
}