Decompiled source of PhysicalHealthbar v2.0.0

Mods/healthbar.dll

Decompiled 5 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using Healthbar;
using Il2CppRUMBLE.Managers;
using Il2CppRUMBLE.MoveSystem;
using MelonLoader;
using RumbleModdingAPI;
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(healthclass), "PhysicalHealthbar", "2.0.0", "Lunartik", null)]
[assembly: MelonGame("Buckethead Entertainment", "RUMBLE")]
[assembly: AssemblyTitle("healthbar")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("healthbar")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("46095d19-7c16-4a14-b28f-804e21ed6b8b")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Healthbar;

public class healthclass : MelonMod
{
	private string currentScene = "Loader";

	private bool sceneChanged = false;

	private PlayerManager playerManager;

	public int health;

	public int previoushealth;

	private bool loaded = false;

	private GameObject Cube;

	private GameObject Wall;

	private List<GameObject> Cubelist = new List<GameObject>();

	private GameObject defhealth;

	private bool enemyloaded = false;

	private int prevenh = 0;

	private List<GameObject> wallstor = new List<GameObject>();

	private int enhealth = 0;

	private GameObject enemyhealth;

	public override void OnSceneWasLoaded(int buildIndex, string sceneName)
	{
		currentScene = sceneName;
		sceneChanged = true;
		previoushealth = 0;
		prevenh = 0;
		Cubelist.Clear();
		wallstor.Clear();
		enemyloaded = false;
	}

	public override void OnFixedUpdate()
	{
		//IL_0094: Unknown result type (might be due to invalid IL or missing references)
		//IL_009b: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
		//IL_010d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0114: Unknown result type (might be due to invalid IL or missing references)
		//IL_011a: Unknown result type (might be due to invalid IL or missing references)
		//IL_013f: Unknown result type (might be due to invalid IL or missing references)
		//IL_049f: Unknown result type (might be due to invalid IL or missing references)
		//IL_035f: Unknown result type (might be due to invalid IL or missing references)
		//IL_038b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0395: Unknown result type (might be due to invalid IL or missing references)
		//IL_04c5: Unknown result type (might be due to invalid IL or missing references)
		//IL_04d6: Unknown result type (might be due to invalid IL or missing references)
		//IL_04ed: Unknown result type (might be due to invalid IL or missing references)
		//IL_04f7: Unknown result type (might be due to invalid IL or missing references)
		//IL_055a: Unknown result type (might be due to invalid IL or missing references)
		//IL_059e: Unknown result type (might be due to invalid IL or missing references)
		//IL_05e1: Unknown result type (might be due to invalid IL or missing references)
		//IL_05fd: Unknown result type (might be due to invalid IL or missing references)
		//IL_0619: Unknown result type (might be due to invalid IL or missing references)
		//IL_0629: Unknown result type (might be due to invalid IL or missing references)
		//IL_0669: Unknown result type (might be due to invalid IL or missing references)
		//IL_06a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_0962: Unknown result type (might be due to invalid IL or missing references)
		//IL_0971: Unknown result type (might be due to invalid IL or missing references)
		//IL_0803: Unknown result type (might be due to invalid IL or missing references)
		//IL_083a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0871: Unknown result type (might be due to invalid IL or missing references)
		//IL_09bc: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a2c: Unknown result type (might be due to invalid IL or missing references)
		//IL_09e7: Unknown result type (might be due to invalid IL or missing references)
		//IL_09f8: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a0f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a19: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a57: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a6d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a77: Unknown result type (might be due to invalid IL or missing references)
		if (!(currentScene != "Loader"))
		{
			return;
		}
		if (sceneChanged)
		{
			try
			{
				if (currentScene == "Gym" && !loaded)
				{
					playerManager = Managers.GetPlayerManager();
					defhealth = GameObject.Find("Health/Local");
					Cube = Object.Instantiate<GameObject>(((Component)RockCube.GetGameObject().transform.GetChild(0).GetChild(0)).gameObject, new Vector3(1000f, 100f, 1000f), default(Quaternion));
					Cube.transform.localScale = new Vector3(0.023f, 0.023f, 0.023f);
					Object.Destroy((Object)(object)Cube.GetComponent<BoxCollider>());
					Wall = Object.Instantiate<GameObject>(((Component)Wall.GetGameObject().transform.GetChild(0).GetChild(0)).gameObject, new Vector3(1000f, 100f, 1000f), default(Quaternion));
					Wall.transform.localScale = new Vector3(0.04f, 0.04f, 0.04f);
					Object.DontDestroyOnLoad((Object)(object)Wall);
					Object.Destroy((Object)(object)Wall.GetComponent<BoxCollider>());
					((Component)defhealth.transform.GetChild(0)).gameObject.SetActive(false);
					Object.DontDestroyOnLoad((Object)(object)Cube);
					loaded = true;
				}
				defhealth = GameObject.Find("Health/Local");
				((Component)defhealth.transform.GetChild(0)).gameObject.SetActive(false);
				if ((currentScene == "Map1" || currentScene == "Map0") && playerManager.AllPlayers.Count > 1)
				{
					enemyhealth = ((Component)((Component)playerManager.AllPlayers[1].Controller).gameObject.transform.GetChild(2).GetChild(0).GetChild(1)).gameObject;
					((Component)enemyhealth.transform.parent.GetChild(0)).gameObject.SetActive(false);
				}
			}
			catch
			{
				return;
			}
			sceneChanged = false;
		}
		if (!loaded)
		{
			return;
		}
		try
		{
			health = playerManager.localPlayer.Data.HealthPoints;
			if (health != previoushealth)
			{
				if (health > previoushealth)
				{
					for (int i = 0; i < health - previoushealth; i++)
					{
						Cubelist.Add(Object.Instantiate<GameObject>(Cube));
						Cubelist[Cubelist.Count - 1].transform.parent = defhealth.transform;
						Cubelist[Cubelist.Count - 1].transform.localPosition = new Vector3(Cubelist[Cubelist.Count - 1].transform.localPosition.x, -1.5f, Cubelist[Cubelist.Count - 1].transform.localPosition.z);
						Cubelist[Cubelist.Count - 1].SetActive(true);
						Cubelist[Cubelist.Count - 1].GetComponent<Structure>();
					}
				}
				else if (health < previoushealth)
				{
					for (int num = 0; num > health - previoushealth; num--)
					{
						Object.Destroy((Object)(object)Cubelist[Cubelist.Count - 1]);
						Cubelist.Remove(Cubelist[Cubelist.Count - 1]);
					}
				}
			}
			foreach (GameObject item in Cubelist)
			{
				if (item.transform.localPosition.y < 0f)
				{
					item.transform.localPosition = new Vector3(item.transform.localPosition.x, item.transform.localPosition.y + 0.03f, item.transform.localPosition.z);
				}
			}
			for (int j = 0; j < Cubelist.Count; j++)
			{
				Cubelist[j].transform.localPosition = new Vector3((float)j * 0.025f - 0.2375f, Cubelist[j].transform.localPosition.y, Math.Abs(0.0475f - (float)Math.Abs(Math.Pow(Math.Abs((float)j - 9.5f), 1.5)) / 600f) + 0.96f);
				if (j == 0 || j == 19)
				{
					Cubelist[j].transform.localPosition = new Vector3(Cubelist[j].transform.localPosition.x, Cubelist[j].transform.localPosition.y, Cubelist[j].transform.localPosition.z - 0.005f);
				}
				if (j <= 10)
				{
					Cubelist[j].transform.localEulerAngles = new Vector3(0f, (float)(3 * j + 60), 45f);
				}
				else if (j > 10)
				{
					Cubelist[j].transform.localEulerAngles = new Vector3(0f, (float)(3 * j + 57), 45f);
				}
			}
			previoushealth = health;
			if (currentScene != "Map0" && currentScene != "Map1")
			{
				return;
			}
			if (!enemyloaded && playerManager.AllPlayers.Count > 1)
			{
				enemyloaded = true;
			}
			if (!enemyloaded)
			{
				return;
			}
			enhealth = playerManager.AllPlayers[1].Data.HealthPoints;
			if (prevenh != enhealth)
			{
				for (int k = 0; k < enhealth - prevenh; k++)
				{
					wallstor.Add(Object.Instantiate<GameObject>(Wall));
					wallstor[wallstor.Count - 1].transform.parent = enemyhealth.transform;
					wallstor[wallstor.Count - 1].transform.localPosition = new Vector3(0f, -2f, 0f);
					wallstor[wallstor.Count - 1].transform.localEulerAngles = new Vector3(0f, 0f, 0f);
					wallstor[wallstor.Count - 1].transform.localScale = new Vector3(0.025f, 0.025f, 0.025f);
					wallstor[wallstor.Count - 1].SetActive(true);
				}
				for (int num2 = 0; num2 > enhealth - prevenh; num2--)
				{
					Object.Destroy((Object)(object)wallstor[wallstor.Count - 1]);
					wallstor.Remove(wallstor[wallstor.Count - 1]);
				}
				prevenh = enhealth;
			}
			for (int l = 0; l < wallstor.Count; l++)
			{
				wallstor[l].transform.localPosition = new Vector3((float)l * -0.035f, wallstor[l].transform.localPosition.y, 0f);
			}
			foreach (GameObject item2 in wallstor)
			{
				if ((double)item2.transform.localPosition.y < -0.1)
				{
					item2.transform.localPosition = new Vector3(item2.transform.localPosition.x, item2.transform.localPosition.y + 0.05f, item2.transform.localPosition.z);
				}
				if ((double)item2.transform.localPosition.y > -0.1)
				{
					item2.transform.localPosition = new Vector3(item2.transform.localPosition.x, 0f, item2.transform.localPosition.z);
				}
			}
		}
		catch
		{
		}
	}
}