Decompiled source of RumbleDarkMode v2.1.3

Mods/RumbleDarkMode.dll

Decompiled a week ago
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppRUMBLE.MoveSystem;
using MelonLoader;
using RumbleDarkMode;
using RumbleModUI;
using RumbleModdingAPI;
using UnityEngine;
using UnityEngine.Rendering;

[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), "Rumble Dark Mode", "2.1.3", "ERROR", null)]
[assembly: MelonGame("Buckethead Entertainment", "RUMBLE")]
[assembly: MelonColor(255, 255, 0, 0)]
[assembly: MelonAuthorColor(255, 255, 0, 0)]
[assembly: AssemblyDescription("")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: VerifyLoaderVersion(0, 6, 2, true)]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("b10c94a1-8a40-4701-bc5b-98eabb44dfea")]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("RumbleDarkMode")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("RumbleDarkMode")]
[assembly: AssemblyTitle("RumbleDarkMode")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace RumbleDarkMode;

public static class BuildInfo
{
	public const string ModName = "Rumble Dark Mode";

	public const string Version = "2.1.3";

	public const string Description = "Adds a dark mode option to Gym, Park, and Ring!";

	public const string Author = "ERROR";
}
public class Main : MelonMod
{
	private string currentScene = "Loader";

	private Mod mod = new Mod();

	private ModSetting<bool> gymToggle;

	private ModSetting<bool> parkToggle;

	private ModSetting<bool> ringToggle;

	private ModSetting<bool> pitToggle;

	public override void OnLateInitializeMelon()
	{
		Calls.onMapInitialized += Initialize;
		UI.instance.UI_Initialized += OnUIInit;
	}

	public void OnUIInit()
	{
		//IL_0049: Unknown result type (might be due to invalid IL or missing references)
		//IL_004e: Unknown result type (might be due to invalid IL or missing references)
		//IL_005b: Expected O, but got Unknown
		//IL_006f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0079: Expected O, but got Unknown
		//IL_0091: Unknown result type (might be due to invalid IL or missing references)
		//IL_009b: Expected O, but got Unknown
		//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bd: Expected O, but got Unknown
		//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00df: Expected O, but got Unknown
		mod.ModName = "Rumble Dark Mode";
		mod.ModVersion = "2.1.3";
		mod.SetFolder("RumbleDarkMode");
		mod.AddDescription("Description", "", "Adds a dark mode option to Gym, Park, and Ring!", new Tags
		{
			IsSummary = true
		});
		gymToggle = mod.AddToList("Toggle In Gym", true, 0, "Toggles Dark Mode in Gym (On next scene load)", new Tags());
		parkToggle = mod.AddToList("Toggle In Parks", true, 0, "Toggles Dark Mode in Parks (On next scene load)", new Tags());
		ringToggle = mod.AddToList("Toggle In Ring", true, 0, "Toggles Dark Mode in Ring (On next scene load)", new Tags());
		pitToggle = mod.AddToList("Toggle In Pit", false, 0, "Toggles Dark Mode in Pit (On next scene load) (BUGGY AND DOESNT LOOK GOOD)", new Tags());
		mod.GetFromFile();
		UI.instance.AddMod(mod);
	}

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

	private Texture2D LoadTexture(string resourceName)
	{
		//IL_0045: Unknown result type (might be due to invalid IL or missing references)
		//IL_004b: Expected O, but got Unknown
		using Stream stream = ((MelonBase)this).MelonAssembly.Assembly.GetManifestResourceStream("RumbleDarkMode.Resources." + resourceName);
		if (stream == null)
		{
			return null;
		}
		byte[] array = new byte[stream.Length];
		stream.Read(array, 0, array.Length);
		Texture2D val = new Texture2D(2, 2);
		ImageConversion.LoadImage(val, Il2CppStructArray<byte>.op_Implicit(array));
		return val;
	}

	public void SetSkybox()
	{
		//IL_0057: Unknown result type (might be due to invalid IL or missing references)
		//IL_005e: Expected O, but got Unknown
		//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00df: Expected O, but got Unknown
		Texture2D val = LoadTexture("SkyEarlyDusk_Right.png");
		Texture2D val2 = LoadTexture("SkyEarlyDusk_Left.png");
		Texture2D val3 = LoadTexture("SkyEarlyDusk_Top.png");
		Texture2D val4 = LoadTexture("SkyEarlyDusk_Bottom.png");
		Texture2D val5 = LoadTexture("SkyEarlyDusk_Front.png");
		Texture2D val6 = LoadTexture("SkyEarlyDusk_Back.png");
		int width = ((Texture)val).width;
		Cubemap val7 = new Cubemap(width, (TextureFormat)4, false);
		Graphics.CopyTexture((Texture)(object)val, 0, 0, (Texture)(object)val7, 0, 0);
		Graphics.CopyTexture((Texture)(object)val2, 0, 0, (Texture)(object)val7, 1, 0);
		Graphics.CopyTexture((Texture)(object)val3, 0, 0, (Texture)(object)val7, 2, 0);
		Graphics.CopyTexture((Texture)(object)val4, 0, 0, (Texture)(object)val7, 3, 0);
		Graphics.CopyTexture((Texture)(object)val5, 0, 0, (Texture)(object)val7, 4, 0);
		Graphics.CopyTexture((Texture)(object)val6, 0, 0, (Texture)(object)val7, 5, 0);
		Shader val8 = Shader.Find("Skybox/Cubemap");
		if ((Object)(object)val8 == (Object)null)
		{
			MelonLogger.Error("Skybox/Cubemap shader not found!");
			return;
		}
		Material val9 = new Material(val8);
		val9.SetTexture("_Tex", (Texture)(object)val7);
		val9.SetFloat("_Exposure", 0.5f);
		RenderSettings.skybox = val9;
	}

	private void Initialize()
	{
		//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
		//IL_0271: Unknown result type (might be due to invalid IL or missing references)
		//IL_0277: Expected O, but got Unknown
		//IL_02a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c2: Unknown result type (might be due to invalid IL or missing references)
		//IL_0214: Unknown result type (might be due to invalid IL or missing references)
		if ((currentScene == "Gym" && !(bool)((ModSetting)gymToggle).SavedValue) || (currentScene == "Park" && !(bool)((ModSetting)parkToggle).SavedValue) || (currentScene == "Map0" && !(bool)((ModSetting)ringToggle).SavedValue) || (currentScene == "Map1" && !(bool)((ModSetting)pitToggle).SavedValue))
		{
			return;
		}
		SetSkybox();
		RenderSettings.ambientMode = (AmbientMode)1;
		RenderSettings.ambientIntensity = 1f;
		RenderSettings.defaultReflectionMode = (DefaultReflectionMode)0;
		RenderSettings.fogColor = Color.black;
		Light[] array = Il2CppArrayBase<Light>.op_Implicit(Object.FindObjectsOfType<Light>());
		Light[] array2 = array;
		foreach (Light val in array2)
		{
			val.cullingMask = -1;
		}
		Renderer[] array3 = Il2CppArrayBase<Renderer>.op_Implicit(Object.FindObjectsOfType<Renderer>());
		Renderer[] array4 = array3;
		foreach (Renderer val2 in array4)
		{
			Transform parent = ((Component)val2).transform.parent;
			if (((parent != null) ? ((Component)parent).GetComponent<Structure>() : null) != null || ((Component)((Component)val2).transform).GetComponent<Structure>() != null || ((Object)((Component)val2).gameObject).name == "FadeScreenRenderer")
			{
				continue;
			}
			val2.lightmapIndex = -1;
			val2.lightProbeUsage = (LightProbeUsage)0;
			if (currentScene == "Map1")
			{
				val2.lightmapIndex = 0;
				if (((Object)val2.material).name.Contains("MAT_Environment"))
				{
					val2.material.SetVector("Gradient_color", new Vector4(0f, 0f, 0f, 0f));
				}
			}
			if (((Object)val2.material).name.Contains("MAT_Mountain"))
			{
				val2.material.SetFloat("_GI_efect", 0.9f);
			}
		}
		LightmapSettings.lightmaps = null;
		GameObject val3 = new GameObject("Moonlight");
		Light val4 = val3.AddComponent<Light>();
		val4.type = (LightType)1;
		val4.intensity = 0.1f;
		val4.color = new Color(0.72f, 0.8084f, 0.9344f);
		val3.transform.rotation = Quaternion.Euler(42.8454f, 0f, 0f);
	}
}