Decompiled source of HpBooster v1.0.1

Mods/hpbooster.dll

Decompiled 3 hours ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BoneLib;
using BoneLib.BoneMenu;
using Il2CppSLZ.Marrow;
using Il2CppSystem;
using MelonLoader;
using MelonLoader.Preferences;
using UnityEngine;
using hpbooster;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: MelonInfo(typeof(Main), "HP Booster", "1.0.0", "Modder", null)]
[assembly: MelonGame("Stress Level Zero", "BONELAB")]
[assembly: AssemblyTitle("hpbooster")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("hpbooster")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("bdedfd37-04eb-472e-b78e-3508975ef369")]
[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 hpbooster;

public class Main : MelonMod
{
	private static MelonPreferences_Category prefsCategory;

	private static MelonPreferences_Entry<float> prefsMultiplier;

	public static float healthMultiplier = 2f;

	private float lastMultiplier = -1f;

	private int lastAvatarHash = 0;

	private float originalVitality = 1f;

	public override void OnInitializeMelon()
	{
		//IL_005c: Unknown result type (might be due to invalid IL or missing references)
		//IL_006f: Unknown result type (might be due to invalid IL or missing references)
		prefsCategory = MelonPreferences.CreateCategory("HPBooster", "HP Booster Settings");
		prefsMultiplier = prefsCategory.CreateEntry<float>("HealthMultiplier", 2f, "Health Multiplier", (string)null, false, false, (ValueValidator)null, (string)null);
		healthMultiplier = prefsMultiplier.Value;
		MelonLogger.Msg("HP Booster (Smart Vitality Engine) loaded successfully!");
		Page val = Page.Root.CreatePage("HP Booster", Color.red, 0, true);
		val.CreateFloat("Health Multiplier", Color.white, healthMultiplier, 0.5f, 1f, 20f, (Action<float>)delegate(float num)
		{
			healthMultiplier = num;
			prefsMultiplier.Value = num;
			prefsCategory.SaveToFile(true);
			MelonLogger.Msg($"Health multiplier set to: {num}x");
			ApplyMultiplier();
		});
	}

	public override void OnUpdate()
	{
		try
		{
			RigManager rigManager = Player.RigManager;
			if ((Object)(object)rigManager != (Object)null && (Object)(object)rigManager.avatar != (Object)null)
			{
				int hashCode = ((Object)rigManager.avatar).GetHashCode();
				if (hashCode != lastAvatarHash || healthMultiplier != lastMultiplier)
				{
					lastAvatarHash = hashCode;
					originalVitality = rigManager.avatar._vitality;
					ApplyMultiplier();
				}
			}
			else
			{
				lastAvatarHash = 0;
			}
		}
		catch (Exception)
		{
		}
	}

	private void ApplyMultiplier()
	{
		try
		{
			RigManager rigManager = Player.RigManager;
			if ((Object)(object)rigManager != (Object)null && (Object)(object)rigManager.avatar != (Object)null && (Object)(object)rigManager.health != (Object)null)
			{
				rigManager.avatar._vitality = originalVitality * healthMultiplier;
				rigManager.health.max_Health = 100f * rigManager.avatar._vitality;
				rigManager.health.curr_Health = rigManager.health.max_Health;
				lastMultiplier = healthMultiplier;
				MelonLogger.Msg($"Applied {healthMultiplier}x vitality. Current vitality: {rigManager.avatar._vitality}");
			}
		}
		catch (Exception ex)
		{
			MelonLogger.Error("Error applying vitality: " + ex.Message);
		}
	}
}