Decompiled source of LcTZPHealing v1.0.0

LC TZP Healing.dll

Decompiled 2 weeks ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using LC_TZP_Healing.Patches;
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("LC TZP Healing")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("LC TZP Healing")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("108f8939-171a-4d6d-97d7-0dc21f2ed811")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace LC_TZP_Healing
{
	[BepInPlugin("Fury.TZPHealing", "TZPHealing", "1.1.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class LCTZPHealingBase : BaseUnityPlugin
	{
		private const string modGUID = "Fury.TZPHealing";

		private const string modName = "TZPHealing";

		private const string modVersion = "1.1.0";

		private readonly Harmony harmony = new Harmony("Fury.TZPHealing");

		private static LCTZPHealingBase Instance;

		internal ManualLogSource mls;

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			mls = Logger.CreateLogSource("Fury.TZPHealing");
			mls.LogInfo((object)"The TZP healing mod has awoken :)");
			harmony.PatchAll(typeof(LCTZPHealingBase));
			harmony.PatchAll(typeof(TetraChemicalItemPatch));
		}
	}
}
namespace LC_TZP_Healing.Patches
{
	[HarmonyPatch(typeof(TetraChemicalItem))]
	internal class TetraChemicalItemPatch
	{
		private static float healTimer;

		[HarmonyPatch("Update")]
		[HarmonyPrefix]
		public static void PrefixUpdatePatch(ref float ___fuel, ref Item ___itemProperties, ref Battery ___insertedBattery)
		{
			___itemProperties.requiresBattery = false;
			___insertedBattery.charge = ___fuel;
		}

		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		public static void UpdatePatch(ref bool ___emittingGas, ref float ___fuel, ref PlayerControllerB ___previousPlayerHeldBy, ref Item ___itemProperties, ref Battery ___insertedBattery)
		{
			___itemProperties.requiresBattery = true;
			___insertedBattery.charge = ___fuel;
			if (___emittingGas && ((NetworkBehaviour)___previousPlayerHeldBy).IsOwner && ___previousPlayerHeldBy.isPlayerControlled && ___previousPlayerHeldBy.AllowPlayerDeath() && !___previousPlayerHeldBy.isTestingPlayer)
			{
				healTimer += Time.deltaTime;
				if (healTimer >= 0.1f)
				{
					___previousPlayerHeldBy.health = Mathf.Clamp(___previousPlayerHeldBy.health + 1, 0, 100);
					healTimer = 0f;
				}
			}
		}
	}
}