Decompiled source of Color Screen v2.3.0

Mods/ColorScreen.dll

Decompiled a month ago
using System;
using System.Diagnostics;
using System.Globalization;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using ColorScreenMod;
using Il2CppRUMBLE.Managers;
using Il2CppRUMBLE.Utilities;
using MelonLoader;
using RumbleModUI;
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), "Color Screen", "2.2.0", "UlvakSkillz", null)]
[assembly: MelonGame("Buckethead Entertainment", "RUMBLE")]
[assembly: MelonColor(255, 195, 0, 255)]
[assembly: MelonAuthorColor(255, 195, 0, 255)]
[assembly: VerifyLoaderVersion(0, 6, 2, true)]
[assembly: AssemblyTitle("ColorScreen")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ColorScreen")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("0bbb5e6e-12ca-4068-8a79-6605427fba1b")]
[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 ColorScreenMod;

public static class BuildInfo
{
	public const string ModName = "ColorSWcreen";

	public const string ModVersion = "2.3.0";

	public const string Author = "UlvakSkillz";
}
public class main : MelonMod
{
	private string currentScene = "Loader";

	private bool gKeyReleased = true;

	private bool gScreenActive = false;

	private bool fKeyReleased = true;

	private bool fPlainActive = false;

	private static string wallColorText = "FF44EC";

	private static string floorColorText = "FF44EC";

	private Color wallColor = hexToColor(wallColorText);

	private Color floorColor = hexToColor(floorColorText);

	private static Mod ColorScreen = new Mod();

	private void UIInit()
	{
		//IL_0015: Unknown result type (might be due to invalid IL or missing references)
		//IL_001f: Expected O, but got Unknown
		//IL_0034: Unknown result type (might be due to invalid IL or missing references)
		//IL_003e: Expected O, but got Unknown
		ColorScreen.AddToList("Wall Color", "FF44EC", "Sets The Wall Color to the Supplied Color", new Tags());
		ColorScreen.AddToList("Floor Color", "FF44EC", "Sets The Floor Color to the Supplied Color", new Tags());
		ColorScreen.GetFromFile();
		UI.instance.AddMod(ColorScreen);
	}

	public override void OnLateInitializeMelon()
	{
		ColorScreen.ModName = "ColorSWcreen";
		ColorScreen.ModVersion = "2.3.0";
		ColorScreen.SetFolder("ColorSWcreen");
		ColorScreen.ModSaved += Save;
		UI.instance.UI_Initialized += UIInit;
		Save();
	}

	private void Save()
	{
		//IL_0101: Unknown result type (might be due to invalid IL or missing references)
		//IL_0106: Unknown result type (might be due to invalid IL or missing references)
		//IL_0111: Unknown result type (might be due to invalid IL or missing references)
		//IL_0116: Unknown result type (might be due to invalid IL or missing references)
		wallColorText = (string)ColorScreen.Settings[0].SavedValue;
		floorColorText = (string)ColorScreen.Settings[1].SavedValue;
		if (wallColorText.Length < 6)
		{
			Log("Wall Color too Short!");
			wallColorText = "FF44EC";
			ColorScreen.Settings[5].SavedValue = "FFFFFF";
			ColorScreen.Settings[5].Value = "FFFFFF";
		}
		if (floorColorText.Length < 6)
		{
			Log("Floor Color too Short!");
			floorColorText = "FF44EC";
			ColorScreen.Settings[6].SavedValue = "000000";
			ColorScreen.Settings[6].Value = "000000";
		}
		wallColor = hexToColor(wallColorText);
		floorColor = hexToColor(floorColorText);
	}

	public static Color hexToColor(string hex)
	{
		//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_0072: Unknown result type (might be due to invalid IL or missing references)
		//IL_0076: Unknown result type (might be due to invalid IL or missing references)
		hex = hex.Replace("0x", "");
		hex = hex.Replace("#", "");
		byte b = byte.MaxValue;
		byte b2 = byte.Parse(hex.Substring(0, 2), NumberStyles.HexNumber);
		byte b3 = byte.Parse(hex.Substring(2, 2), NumberStyles.HexNumber);
		byte b4 = byte.Parse(hex.Substring(4, 2), NumberStyles.HexNumber);
		return Color32.op_Implicit(new Color32(b2, b3, b4, b));
	}

	public override void OnSceneWasLoaded(int buildIndex, string sceneName)
	{
		currentScene = sceneName;
	}

	public override void OnUpdate()
	{
		if (currentScene == "Loader")
		{
			return;
		}
		if (Input.GetKeyDown((KeyCode)103) && gKeyReleased)
		{
			gKeyReleased = false;
			if (gScreenActive)
			{
				Object.Destroy((Object)(object)GameObject.Find("ColorScreen"));
				gScreenActive = false;
			}
			else
			{
				CreateWall();
				gScreenActive = true;
			}
		}
		if (Input.GetKeyUp((KeyCode)103) && !gKeyReleased)
		{
			gKeyReleased = true;
		}
		if (Input.GetKeyDown((KeyCode)102) && fKeyReleased)
		{
			fKeyReleased = false;
			if (fPlainActive)
			{
				Object.Destroy((Object)(object)GameObject.Find("ColorPlain"));
				fPlainActive = false;
			}
			else
			{
				CreatePlane();
				fPlainActive = true;
			}
		}
		if (Input.GetKeyUp((KeyCode)102) && !fKeyReleased)
		{
			fKeyReleased = true;
		}
	}

	private void CreateWall()
	{
		//IL_003c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0084: Unknown result type (might be due to invalid IL or missing references)
		//IL_0089: Unknown result type (might be due to invalid IL or missing references)
		//IL_008c: 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_00d8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			GameObject val = GameObject.CreatePrimitive((PrimitiveType)3);
			((Object)val).name = "ColorScreen";
			val.GetComponent<Renderer>().material.shader = Shader.Find("Universal Render Pipeline/Lit");
			((Renderer)val.GetComponent<MeshRenderer>()).material.color = wallColor;
			PlayerManager instance = Singleton<PlayerManager>.instance;
			Transform transform = val.transform;
			Quaternion rotation = ((Component)((Component)instance.localPlayer.Controller).gameObject.transform.GetChild(1).GetChild(0).GetChild(0)).transform.rotation;
			transform.rotation = Quaternion.Euler(0f, ((Quaternion)(ref rotation)).eulerAngles.y, 0f);
			val.transform.position = ((Component)((Component)instance.localPlayer.Controller).gameObject.transform.GetChild(1).GetChild(0).GetChild(0)).transform.position;
			val.transform.localScale = new Vector3(0.01f, 1000f, 1000f);
			val.SetActive(true);
		}
		catch (Exception ex)
		{
			MelonLogger.Error((object)ex);
		}
	}

	private void CreatePlane()
	{
		//IL_003c: 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)
		//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			GameObject val = GameObject.CreatePrimitive((PrimitiveType)3);
			((Object)val).name = "ColorPlain";
			val.GetComponent<Renderer>().material.shader = Shader.Find("Universal Render Pipeline/Lit");
			((Renderer)val.GetComponent<MeshRenderer>()).material.color = floorColor;
			GameObject val2 = GameObject.Find("Health/Local");
			PlayerManager instance = Singleton<PlayerManager>.instance;
			val.transform.position = ((Component)((Component)instance.localPlayer.Controller).gameObject.transform.GetChild(5).GetChild(5).GetChild(0)).gameObject.transform.position;
			val.transform.position = new Vector3(val.transform.position.x, val.transform.position.y - 0.102f, val.transform.position.z);
			val.transform.localScale = new Vector3(1000f, 0.01f, 1000f);
			val.SetActive(true);
		}
		catch (Exception ex)
		{
			MelonLogger.Error((object)ex);
		}
	}

	public static void Log(string msg)
	{
		MelonLogger.Msg(msg);
	}
}