Decompiled source of HPANGGen v1.0.0

HPRegen.dll

Decompiled 4 hours 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 HPRegen.Patch;
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("HPRegen")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("HPRegen")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("65a7af94-3ec3-46f1-b2ce-2fa31f529836")]
[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 HPRegen
{
	[BepInPlugin("sunsetos.hpregen", "hpregen", "1.0.0")]
	internal class Plugin : BaseUnityPlugin
	{
		public const string PLUGIN_GUID = "sunsetos.hpregen";

		public const string PLUGIN_NAME = "hpregen";

		public const string PLUGIN_VERSION = "1.0.0";

		private readonly Harmony harmony = new Harmony("sunsetos.hpregen");

		public static Plugin Instance;

		internal static ManualLogSource Log;

		public static uint times;

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			Log = ((BaseUnityPlugin)this).Logger;
			Log = Logger.CreateLogSource("sunsetos.hpregen");
			Log.LogInfo((object)"sunsetos.hpregen has loaded");
			harmony.PatchAll(typeof(Plugin));
			harmony.PatchAll(typeof(HealthRegen));
		}
	}
}
namespace HPRegen.Patch
{
	[HarmonyPatch]
	internal class HealthRegen
	{
		[HarmonyPatch(typeof(PlayerControllerB), "LateUpdate")]
		[HarmonyPostfix]
		public static void Regen(PlayerControllerB __instance)
		{
			if (__instance.health <= 20 || __instance.health >= 80)
			{
				return;
			}
			if (__instance.healthRegenerateTimer <= 0f)
			{
				__instance.healthRegenerateTimer = 4f;
				__instance.health++;
				if (__instance.health >= 20)
				{
					__instance.MakeCriticallyInjured(false);
				}
				HUDManager.Instance.UpdateHealthUI(__instance.health, false);
			}
			else
			{
				__instance.healthRegenerateTimer -= Time.deltaTime;
			}
		}
	}
}