Decompiled source of DeesTrollPanel v0.1.0

Mods/DeesTrollPanel.dll

Decompiled an hour ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BoneLib.BoneMenu;
using DeesTrollPanel;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using MelonLoader;
using MelonLoader.Preferences;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: MelonInfo(typeof(Main), "Dees Troll Panel", "1.0.0", "Dees", null)]
[assembly: MelonGame("Stress Level Zero", "BONELAB")]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyVersion("0.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace DeesTrollPanel
{
	public class Main : MelonMod
	{
		private Page mainPage;

		private Page effectsPage;

		private Page funPage;

		private Page infoPage;

		private readonly Stopwatch session = new Stopwatch();

		private readonly List<GameObject> orbitObjects = new List<GameObject>();

		private readonly List<GameObject> spawnedProps = new List<GameObject>();

		private MelonPreferences_Category settings;

		private MelonPreferences_Entry<bool> funnySetting;

		private MelonPreferences_Entry<bool> rgbSetting;

		private MelonPreferences_Entry<bool> orbitSetting;

		private bool orbitEnabled;

		private bool rgbEnabled;

		private bool lightweightEnabled;

		private float orbitAngle;

		private float rgbTimer;

		private Color currentTheme = Color.red;

		private const int MaxOrbitObjects = 6;

		private const int MaxSpawnedProps = 5;

		private readonly string[] funnyMessages = new string[5] { "DEES HAS ENTERED BONELAB!", "WHAT ARE YOU DOING?", "BONELAB MOMENT.", "WELCOME TO THE TROLL PANEL!", "SYSTEMS ARE OPERATIONAL." };

		public override void OnInitializeMelon()
		{
			((MelonBase)this).LoggerInstance.Msg("Loading Dees Troll Panel...");
			InitializeSettings();
			session.Start();
			InitializeMenus();
			((MelonBase)this).LoggerInstance.Msg("Dees Troll Panel initialized.");
		}

		private void InitializeSettings()
		{
			settings = MelonPreferences.CreateCategory("DeesTrollPanel");
			funnySetting = settings.CreateEntry<bool>("FunnyMessages", true, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
			rgbSetting = settings.CreateEntry<bool>("RGBEffects", false, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
			orbitSetting = settings.CreateEntry<bool>("OrbitObjects", false, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
			rgbEnabled = rgbSetting.Value;
			orbitEnabled = orbitSetting.Value;
		}

		private void InitializeMenus()
		{
			//IL_000b: 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_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			mainPage = Page.Root.CreatePage("<color=#FF2222>DEES TROLL PANEL</color>", Color.white, 8, true);
			effectsPage = mainPage.CreatePage("Visual Effects", Color.white, 0, true);
			funPage = mainPage.CreatePage("Fun Center", Color.white, 0, true);
			infoPage = mainPage.CreatePage("Information", Color.white, 0, true);
			BuildMainMenu();
			BuildEffectsMenu();
			BuildFunMenu();
			BuildInfoMenu();
		}

		private void BuildMainMenu()
		{
			//IL_000b: 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_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			mainPage.CreateFunction("Welcome Message", Color.white, (Action)delegate
			{
				Notify("WELCOME TO DEES TROLL PANEL!");
			});
			mainPage.CreateFunction("Random Funny Message", Color.white, (Action)FunnyMessage);
			mainPage.CreateFunction("Player Information", Color.white, (Action)ShowPlayerInfo);
			mainPage.CreateFunction("Session Timer", Color.white, (Action)ShowSession);
			mainPage.CreateFunction("Mod Information", Color.white, (Action)ShowModInfo);
			mainPage.CreateFunction("Save Settings", Color.white, (Action)SaveSettings);
		}

		private void BuildEffectsMenu()
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			effectsPage.CreateBool("Orbit Objects", Color.white, orbitEnabled, (Action<bool>)delegate(bool value)
			{
				orbitEnabled = value;
				orbitSetting.Value = value;
				if (value)
				{
					StartOrbit();
				}
				else
				{
					StopOrbit();
				}
			});
			effectsPage.CreateBool("RGB Effects", Color.white, rgbEnabled, (Action<bool>)delegate(bool value)
			{
				rgbEnabled = value;
				rgbSetting.Value = value;
			});
			effectsPage.CreateFunction("Random Color", Color.white, (Action)RandomColor);
			effectsPage.CreateBool("Lightweight Spawned Props", Color.white, false, (Action<bool>)delegate(bool value)
			{
				lightweightEnabled = value;
				Notify("Lightweight setting applies to newly spawned props.");
			});
			effectsPage.CreateFunction("Spawn Safe Test Prop", Color.white, (Action)SpawnSafeProp);
			effectsPage.CreateFunction("Clear Spawned Props", Color.white, (Action)ClearProps);
		}

		private void BuildFunMenu()
		{
			//IL_000b: 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_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			funPage.CreateBool("Funny Messages", Color.white, funnySetting.Value, (Action<bool>)delegate(bool value)
			{
				funnySetting.Value = value;
			});
			funPage.CreateFunction("Custom Notification Test", Color.white, (Action)delegate
			{
				Notify("DEES TROLL PANEL IS ACTIVE!");
			});
			funPage.CreateFunction("Random Sound", Color.white, (Action)SoundSystem.PlayRandomTone);
			funPage.CreateFunction("Soundboard - Beep", Color.white, (Action)SoundSystem.PlayBeep);
			funPage.CreateFunction("Soundboard - Double Beep", Color.white, (Action)SoundSystem.PlayDoubleBeep);
			funPage.CreateFunction("Random Message", Color.white, (Action)FunnyMessage);
			funPage.CreateFunction("Change Panel Theme", Color.white, (Action)RandomColor);
		}

		private void BuildInfoMenu()
		{
			//IL_000b: 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_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			infoPage.CreateFunction("Player Information", Color.white, (Action)ShowPlayerInfo);
			infoPage.CreateFunction("Avatar / Camera Information", Color.white, (Action)ShowAvatarInfo);
			infoPage.CreateFunction("Session Timer", Color.white, (Action)ShowSession);
			infoPage.CreateFunction("Mod Version", Color.white, (Action)ShowModInfo);
			infoPage.CreateFunction("Save Settings", Color.white, (Action)SaveSettings);
		}

		public override void OnUpdate()
		{
			if (orbitEnabled)
			{
				UpdateOrbit();
			}
			if (rgbEnabled)
			{
				UpdateRGB();
			}
		}

		private void StartOrbit()
		{
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			StopOrbit();
			if ((Object)(object)Camera.main == (Object)null)
			{
				orbitEnabled = false;
				orbitSetting.Value = false;
				Notify("Player camera unavailable.");
				return;
			}
			for (int i = 0; i < 6; i++)
			{
				GameObject val = GameObject.CreatePrimitive((PrimitiveType)0);
				((Object)val).name = "DeesTrollPanel_Orbit";
				val.transform.localScale = Vector3.one * 0.12f;
				Collider component = val.GetComponent<Collider>();
				if ((Object)(object)component != (Object)null)
				{
					Object.Destroy((Object)(object)component);
				}
				Renderer component2 = val.GetComponent<Renderer>();
				if ((Object)(object)component2 != (Object)null)
				{
					component2.material.color = currentTheme;
				}
				orbitObjects.Add(val);
			}
			Notify("Orbit effect enabled.");
		}

		private void UpdateOrbit()
		{
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			Camera main = Camera.main;
			if ((Object)(object)main == (Object)null)
			{
				return;
			}
			orbitAngle += Time.deltaTime * 1.5f;
			Vector3 val2 = default(Vector3);
			for (int i = 0; i < orbitObjects.Count; i++)
			{
				GameObject val = orbitObjects[i];
				if (!((Object)(object)val == (Object)null))
				{
					float num = orbitAngle + (float)i * (float)Math.PI * 2f / (float)orbitObjects.Count;
					((Vector3)(ref val2))..ctor(Mathf.Cos(num) * 0.65f, 0.3f + Mathf.Sin(num * 2f) * 0.12f, Mathf.Sin(num) * 0.65f);
					val.transform.position = ((Component)main).transform.position + ((Component)main).transform.rotation * val2;
				}
			}
		}

		private void StopOrbit()
		{
			for (int i = 0; i < orbitObjects.Count; i++)
			{
				if ((Object)(object)orbitObjects[i] != (Object)null)
				{
					Object.Destroy((Object)(object)orbitObjects[i]);
				}
			}
			orbitObjects.Clear();
		}

		private void UpdateRGB()
		{
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: 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)
			rgbTimer += Time.deltaTime;
			if (rgbTimer < 0.15f)
			{
				return;
			}
			rgbTimer = 0f;
			currentTheme = Color.HSVToRGB(Random.value, 1f, 1f);
			for (int i = 0; i < orbitObjects.Count; i++)
			{
				if (!((Object)(object)orbitObjects[i] == (Object)null))
				{
					Renderer component = orbitObjects[i].GetComponent<Renderer>();
					if ((Object)(object)component != (Object)null)
					{
						component.material.color = currentTheme;
					}
				}
			}
		}

		private void SpawnSafeProp()
		{
			//IL_0053: 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_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			if (spawnedProps.Count >= 5)
			{
				Notify("Spawn limit reached. Clear props first.");
				return;
			}
			Camera main = Camera.main;
			if ((Object)(object)main == (Object)null)
			{
				Notify("Player camera unavailable.");
				return;
			}
			GameObject val = GameObject.CreatePrimitive((PrimitiveType)3);
			((Object)val).name = "DeesTrollPanel_TestProp";
			val.transform.position = ((Component)main).transform.position + ((Component)main).transform.forward * 2f;
			val.transform.localScale = Vector3.one * 0.3f;
			val.AddComponent<Rigidbody>().mass = (lightweightEnabled ? 0.25f : 1f);
			Renderer component = val.GetComponent<Renderer>();
			if ((Object)(object)component != (Object)null)
			{
				component.material.color = currentTheme;
			}
			spawnedProps.Add(val);
			Notify("Test prop spawned.");
		}

		private void ClearProps()
		{
			for (int i = 0; i < spawnedProps.Count; i++)
			{
				if ((Object)(object)spawnedProps[i] != (Object)null)
				{
					Object.Destroy((Object)(object)spawnedProps[i]);
				}
			}
			spawnedProps.Clear();
			Notify("Spawned test props cleared.");
		}

		private void RandomColor()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			currentTheme = Color.HSVToRGB(Random.value, 1f, 1f);
			Notify("Theme color changed.");
		}

		private void FunnyMessage()
		{
			if (funnySetting.Value)
			{
				string message = funnyMessages[Random.Range(0, funnyMessages.Length)];
				Notify(message);
			}
		}

		private void ShowPlayerInfo()
		{
			//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)
			Camera main = Camera.main;
			if ((Object)(object)main == (Object)null)
			{
				Notify("Player camera unavailable.");
				return;
			}
			Vector3 position = ((Component)main).transform.position;
			Notify("Player camera position: " + ((Vector3)(ref position)).ToString("F2"));
		}

		private void ShowAvatarInfo()
		{
			Camera main = Camera.main;
			Notify(((Object)(object)main == (Object)null) ? "Camera/avatar tracking unavailable." : ("Camera object: " + ((Object)main).name));
		}

		private void ShowSession()
		{
			Notify("Session time: " + session.Elapsed.ToString("hh\\:mm\\:ss"));
		}

		private void ShowModInfo()
		{
			Notify("Dees Troll Panel v1.0.0 by Dees");
		}

		private void SaveSettings()
		{
			MelonPreferences.Save();
			Notify("Settings save requested.");
		}

		private void Notify(string message)
		{
			((MelonBase)this).LoggerInstance.Msg("[DEES] " + message);
		}

		public override void OnDeinitializeMelon()
		{
			StopOrbit();
			ClearProps();
		}
	}
	public static class SoundSystem
	{
		public static void PlayBeep()
		{
			PlayTone(600f);
		}

		public static void PlayDoubleBeep()
		{
			PlayTone(850f);
		}

		public static void PlayRandomTone()
		{
			PlayTone(Random.Range(250f, 1000f));
		}

		private static void PlayTone(float frequency)
		{
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			Camera main = Camera.main;
			if (!((Object)(object)main == (Object)null))
			{
				int num = 4410;
				AudioClip val = AudioClip.Create("DeesSound", num, 1, 22050, false);
				float[] array = new float[num];
				for (int i = 0; i < num; i++)
				{
					float num2 = 1f - (float)i / (float)num;
					array[i] = Mathf.Sin((float)Math.PI * 2f * frequency * (float)i / 22050f) * 0.15f * num2;
				}
				val.SetData(Il2CppStructArray<float>.op_Implicit(array), 0);
				AudioSource.PlayClipAtPoint(val, ((Component)main).transform.position, 0.3f);
				Object.Destroy((Object)(object)val, 2f);
			}
		}
	}
}