Decompiled source of PowerLab v1.0.0

Mods/PowerLab.dll

Decompiled 2 hours ago
using System;
using System.Collections;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BoneLib;
using BoneLib.BoneMenu;
using BoneLib.Notifications;
using Il2CppSLZ.Marrow;
using MelonLoader;
using PowerLab;
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(Main), "PowerLab", "1.0.0", "zak_sao or 8esp on discord", null)]
[assembly: MelonGame("Stress Level Zero", "BONELAB")]
[assembly: AssemblyTitle("PowerLab")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("PowerLab")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("c73c4d6d-229c-4e9b-b83f-a7565b176866")]
[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 PowerLab;

public class Main : MelonMod
{
	private static bool isPowerEnabled = true;

	private static float powerMultiplier = 1f;

	private static FunctionElement statusTextElement;

	private static FunctionElement rainbowTitleElement;

	private static GameObject activeConfettiAura;

	public override void OnInitializeMelon()
	{
		Hooking.OnLevelLoaded += OnLevelLoaded;
		SetupBoneMenu();
	}

	private void SetupBoneMenu()
	{
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		//IL_001e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0034: Unknown result type (might be due to invalid IL or missing references)
		//IL_004a: Unknown result type (might be due to invalid IL or missing references)
		//IL_007f: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_0105: Unknown result type (might be due to invalid IL or missing references)
		Page val = Page.Root.CreatePage("PowerLab", Color.yellow, 0, true);
		rainbowTitleElement = val.CreateFunction("PowerLab", Color.magenta, (Action)null);
		statusTextElement = val.CreateFunction("Status: Working", Color.green, (Action)null);
		val.CreateBool("Enable PowerLab", Color.cyan, isPowerEnabled, (Action<bool>)delegate(bool value)
		{
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Expected O, but got Unknown
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Expected O, but got Unknown
			isPowerEnabled = value;
			UpdateStatusUI();
			if (isPowerEnabled)
			{
				SpawnConfettiAura();
				Notifier.Send(new Notification
				{
					Title = NotificationText.op_Implicit("PowerLab Mod"),
					Message = NotificationText.op_Implicit("Status: Working / Enabled\nMade by 8esp add me on discord for any questions :D"),
					Type = (NotificationType)0
				});
			}
			else
			{
				ResetPlayerPower();
				Notifier.Send(new Notification
				{
					Title = NotificationText.op_Implicit("PowerLab Mod"),
					Message = NotificationText.op_Implicit("Status: Not Working / Disabled\nMade by 8esp add me on discord for any questions :D"),
					Type = (NotificationType)1
				});
			}
		});
		val.CreateFloat("Power Level Multiplier", Color.yellow, powerMultiplier, 0.1f, 0.1f, 100f, (Action<float>)delegate(float value)
		{
			powerMultiplier = value;
			if (isPowerEnabled)
			{
				ApplyPlayerPower();
				SpawnConfettiAura();
			}
		});
		val.CreateFunction("Reset Power to Normal (1.0x)", Color.white, (Action)delegate
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Expected O, but got Unknown
			powerMultiplier = 1f;
			ResetPlayerPower();
			Notifier.Send(new Notification
			{
				Title = NotificationText.op_Implicit("PowerLab Mod"),
				Message = NotificationText.op_Implicit("Power reset to default (1.0x)!\nMade by 8esp add me on discord for any questions :D"),
				Type = (NotificationType)0
			});
		});
		val.CreateFunction("------------------", Color.gray, (Action)null);
		val.CreateFunction("Mod made by 8esp on discord :D", Color.yellow, (Action)null);
	}

	public override void OnUpdate()
	{
		//IL_0029: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0034: Unknown result type (might be due to invalid IL or missing references)
		if (rainbowTitleElement != null)
		{
			Color elementColor = Color.HSVToRGB(Time.time * 0.5f % 1f, 1f, 1f);
			((Element)rainbowTitleElement).ElementColor = elementColor;
		}
		if (isPowerEnabled)
		{
			ApplyPlayerPower();
		}
	}

	private void OnLevelLoaded(LevelInfo levelInfo)
	{
		if (isPowerEnabled)
		{
			MelonCoroutines.Start(DelayedApplyPower());
		}
	}

	private static IEnumerator DelayedApplyPower()
	{
		yield return (object)new WaitForSeconds(2f);
		ApplyPlayerPower();
		UpdateStatusUI();
		SpawnConfettiAura();
	}

	private static void SpawnConfettiAura()
	{
		//IL_003a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0044: Expected O, but got Unknown
		//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fb: Expected O, but got Unknown
		//IL_0078: Unknown result type (might be due to invalid IL or missing references)
		if (!((Object)(object)Player.RigManager == (Object)null))
		{
			if ((Object)(object)activeConfettiAura != (Object)null)
			{
				Object.Destroy((Object)(object)activeConfettiAura);
			}
			activeConfettiAura = new GameObject("PowerLab_ConfettiAura");
			Transform val = (((Object)(object)Player.PhysicsRig != (Object)null) ? ((Rig)Player.PhysicsRig).m_pelvis : null);
			if ((Object)(object)val != (Object)null)
			{
				activeConfettiAura.transform.position = val.position;
				activeConfettiAura.transform.SetParent(val);
			}
			ParticleSystem val2 = activeConfettiAura.AddComponent<ParticleSystem>();
			MainModule main = val2.main;
			main.startLifetime = MinMaxCurve.op_Implicit(2.5f);
			main.startSpeed = MinMaxCurve.op_Implicit(3.5f);
			main.startSize = MinMaxCurve.op_Implicit(0.15f);
			main.maxParticles = 150;
			main.startColor = new MinMaxGradient(Color.cyan, Color.magenta);
			EmissionModule emission = val2.emission;
			emission.rateOverTime = MinMaxCurve.op_Implicit(60f);
			ShapeModule shape = val2.shape;
			shape.shapeType = (ParticleSystemShapeType)0;
			shape.radius = 1.2f;
			Object.Destroy((Object)(object)activeConfettiAura, 4f);
		}
	}

	private static void ApplyPlayerPower()
	{
		if (!((Object)(object)Player.RigManager == (Object)null))
		{
			Player_Health componentInChildren = ((Component)Player.RigManager).GetComponentInChildren<Player_Health>();
			if ((Object)(object)componentInChildren != (Object)null)
			{
				float curr_Health = (((Health)componentInChildren).max_Health = 100f * powerMultiplier);
				((Health)componentInChildren).curr_Health = curr_Health;
			}
		}
	}

	private static void ResetPlayerPower()
	{
		if (!((Object)(object)Player.RigManager == (Object)null))
		{
			Player_Health componentInChildren = ((Component)Player.RigManager).GetComponentInChildren<Player_Health>();
			if ((Object)(object)componentInChildren != (Object)null)
			{
				((Health)componentInChildren).max_Health = 100f;
				((Health)componentInChildren).curr_Health = 100f;
			}
		}
	}

	private static void UpdateStatusUI()
	{
		//IL_0051: Unknown result type (might be due to invalid IL or missing references)
		//IL_002d: Unknown result type (might be due to invalid IL or missing references)
		if (statusTextElement != null)
		{
			if (isPowerEnabled)
			{
				((Element)statusTextElement).ElementName = "Status: Working";
				((Element)statusTextElement).ElementColor = Color.green;
			}
			else
			{
				((Element)statusTextElement).ElementName = "Status: Not working";
				((Element)statusTextElement).ElementColor = Color.red;
			}
		}
	}
}