Decompiled source of Health Display v1.1.0

Mods/HealthDisplay.dll

Decompiled 5 months ago
using System.Collections;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using HealthDisplay;
using Il2CppRUMBLE.Managers;
using Il2CppRUMBLE.Utilities;
using Il2CppSystem.Diagnostics;
using Il2CppTMPro;
using MelonLoader;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: MelonInfo(typeof(Class1), "HealthDisplay", "1.1.0", "CactusGod", null)]
[assembly: MelonGame("Buckethead Entertainment", "RUMBLE")]
[assembly: MelonColor(255, 255, 0, 0)]
[assembly: AssemblyTitle("HealthDesplay")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("HealthDisplay")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("c771db38-448e-459d-8d63-c01dc9eb87b3")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace HealthDisplay;

public class Class1 : MelonMod
{
	public static TextMeshPro textRef;

	public static GameObject healthBar;

	private Stopwatch stopwatch = new Stopwatch();

	public int health = 20;

	public override void OnSceneWasLoaded(int buildIndex, string sceneName)
	{
		if (sceneName != "Loader")
		{
			MelonCoroutines.Start(Wait());
		}
	}

	public IEnumerator Wait()
	{
		yield return (object)new WaitForSeconds(3f);
		healthBar = new GameObject();
		((Object)healthBar).name = "TextMeshPro";
		healthBar.transform.parent = ((Component)GameObject.Find("Health").transform.GetChild(1).GetChild(0)).transform;
		healthBar.AddComponent<TextMeshPro>();
		textRef = healthBar.GetComponent<TextMeshPro>();
		healthBar.transform.localPosition = new Vector3(-1.0564f, 0.0061f, 0.0907f);
		healthBar.transform.localRotation = Quaternion.Euler(62.9944f, 260f, 0f);
		healthBar.transform.localScale = new Vector3(0.015f, 0.007f, 0.015f);
		((TMP_Text)textRef).text = "20";
		MelonCoroutines.Start(WatchHealth());
	}

	public IEnumerator WatchHealth()
	{
		while (true)
		{
			try
			{
				((TMP_Text)textRef).text = Singleton<PlayerManager>.instance.localPlayer.Data.HealthPoints.ToString();
			}
			catch
			{
				break;
			}
			yield return (object)new WaitForFixedUpdate();
		}
	}
}