Decompiled source of RumbleDarkMode v2.2.5

Mods/RumbleDarkMode.dll

Decompiled 5 days ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppPhoton.Pun;
using Il2CppRUMBLE.MoveSystem;
using MelonLoader;
using MelonLoader.Utils;
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.2.5", "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.2.5";

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

	public const string Author = "ERROR";
}
public class Main : MelonMod
{
	public struct TimePreset
	{
		public float hour;

		public float weight;

		public Color ambientColor;

		public Color fogColor;

		public Color directionalLightColor;

		public float sunAngleX;

		public Color grassColor;

		public Color SkyTint;

		public float Exposure;

		public float atmosphereThickness;

		public Color groundColor;

		public float sunSize;

		public float sunSizeConvergence;

		public Color sunColor;
	}

	[CompilerGenerated]
	private sealed class <UpdateTimeBasedLighting>d__24 : IEnumerator<object>, IEnumerator, IDisposable
	{
		private int <>1__state;

		private object <>2__current;

		public Main <>4__this;

		private float <hour>5__1;

		private float <localT>5__2;

		private TimePreset <before>5__3;

		private TimePreset <after>5__4;

		private Material <sky>5__5;

		private int <i>5__6;

		private int <j>5__7;

		private float <centerA>5__8;

		private float <centerB>5__9;

		private float <halfRangeA>5__10;

		private float <halfRangeB>5__11;

		private float <start>5__12;

		private float <end>5__13;

		private bool <inRange>5__14;

		private float <total>5__15;

		private float <into>5__16;

		private float <sunX>5__17;

		object IEnumerator<object>.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		object IEnumerator.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		[DebuggerHidden]
		public <UpdateTimeBasedLighting>d__24(int <>1__state)
		{
			this.<>1__state = <>1__state;
		}

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<sky>5__5 = null;
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			//IL_031a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0325: Unknown result type (might be due to invalid IL or missing references)
			//IL_0330: Unknown result type (might be due to invalid IL or missing references)
			//IL_0341: Unknown result type (might be due to invalid IL or missing references)
			//IL_034c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0357: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0437: Unknown result type (might be due to invalid IL or missing references)
			//IL_0442: Unknown result type (might be due to invalid IL or missing references)
			//IL_044d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0482: Unknown result type (might be due to invalid IL or missing references)
			//IL_048d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0498: Unknown result type (might be due to invalid IL or missing references)
			//IL_060d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0617: Expected O, but got Unknown
			//IL_04eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0501: Unknown result type (might be due to invalid IL or missing references)
			//IL_0581: Unknown result type (might be due to invalid IL or missing references)
			//IL_058c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0597: Unknown result type (might be due to invalid IL or missing references)
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				break;
			case 1:
				<>1__state = -1;
				break;
			case 2:
				<>1__state = -1;
				<sky>5__5 = null;
				break;
			}
			if ((bool)((ModSetting)<>4__this.UseTimeBasedLighting).SavedValue)
			{
				if (!<>4__this.initialized)
				{
					<>2__current = null;
					<>1__state = 1;
					return true;
				}
				<hour>5__1 = <>4__this.GetTimeWithRegion();
				<localT>5__2 = 0f;
				<before>5__3 = default(TimePreset);
				<after>5__4 = default(TimePreset);
				<i>5__6 = 0;
				while (<i>5__6 < <>4__this.presets.Length)
				{
					<j>5__7 = (<i>5__6 + 1) % <>4__this.presets.Length;
					<centerA>5__8 = <>4__this.presets[<i>5__6].hour;
					<centerB>5__9 = <>4__this.presets[<j>5__7].hour;
					<halfRangeA>5__10 = <>4__this.presets[<i>5__6].weight / 2f;
					<halfRangeB>5__11 = <>4__this.presets[<j>5__7].weight / 2f;
					<start>5__12 = (<centerA>5__8 + 24f - <halfRangeA>5__10) % 24f;
					<end>5__13 = (<centerB>5__9 + <halfRangeB>5__11) % 24f;
					<inRange>5__14 = ((!(<start>5__12 < <end>5__13)) ? (<hour>5__1 >= <start>5__12 || <hour>5__1 <= <end>5__13) : (<hour>5__1 >= <start>5__12 && <hour>5__1 <= <end>5__13));
					if (<inRange>5__14)
					{
						<before>5__3 = <>4__this.presets[<i>5__6];
						<after>5__4 = <>4__this.presets[<j>5__7];
						<total>5__15 = (<centerB>5__9 - <centerA>5__8 + 24f) % 24f;
						<into>5__16 = (<hour>5__1 - <centerA>5__8 + 24f) % 24f;
						<localT>5__2 = Mathf.InverseLerp(0f, <total>5__15, <into>5__16);
						break;
					}
					<i>5__6++;
				}
				if (<after>5__4.hour == 0f && <before>5__3.hour == 0f)
				{
					<before>5__3 = <>4__this.presets[^1];
					<after>5__4 = <>4__this.presets[0];
				}
				RenderSettings.ambientLight = Color.Lerp(<before>5__3.ambientColor, <after>5__4.ambientColor, <localT>5__2);
				RenderSettings.fogColor = Color.Lerp(<before>5__3.fogColor, <after>5__4.fogColor, <localT>5__2);
				if ((Object)(object)RenderSettings.sun != (Object)null)
				{
					<sunX>5__17 = Mathf.Lerp(<before>5__3.sunAngleX, <after>5__4.sunAngleX, <localT>5__2);
					((Component)RenderSettings.sun).transform.rotation = Quaternion.Euler(<sunX>5__17, 0f, 0f);
					RenderSettings.sun.color = Color.Lerp(<before>5__3.sunColor, <after>5__4.sunColor, <localT>5__2);
				}
				if ((Object)(object)<>4__this.sharedGrassMaterial == (Object)null)
				{
					<>4__this.CacheGrassMaterial();
					<>4__this.CacheLightingTargets();
				}
				else
				{
					<>4__this.sharedGrassMaterial.SetColor("Color_1", Color.Lerp(<before>5__3.grassColor, <after>5__4.grassColor, <localT>5__2));
				}
				if ((Object)(object)<>4__this.gymLight != (Object)null)
				{
					<>4__this.gymLight.color = Color.Lerp(<before>5__3.directionalLightColor, <after>5__4.directionalLightColor, <localT>5__2);
				}
				<sky>5__5 = RenderSettings.skybox;
				if ((Object)(object)<sky>5__5 != (Object)null && <sky>5__5.HasProperty("_SkyTint"))
				{
					<sky>5__5.SetColor("_SkyTint", Color.Lerp(<before>5__3.SkyTint, <after>5__4.SkyTint, <localT>5__2));
					<sky>5__5.SetFloat("_Exposure", Mathf.Lerp(<before>5__3.Exposure, <after>5__4.Exposure, <localT>5__2));
					<sky>5__5.SetFloat("_AtmosphereThickness", Mathf.Lerp(<before>5__3.atmosphereThickness, <after>5__4.atmosphereThickness, <localT>5__2));
					<sky>5__5.SetColor("_GroundColor", Color.Lerp(<before>5__3.groundColor, <after>5__4.groundColor, <localT>5__2));
					<sky>5__5.SetFloat("_SunSize", Mathf.Lerp(<before>5__3.sunSize, <after>5__4.sunSize, <localT>5__2));
					<sky>5__5.SetFloat("_SunSizeConvergence", Mathf.Lerp(<before>5__3.sunSizeConvergence, <after>5__4.sunSizeConvergence, <localT>5__2));
				}
				<>2__current = (object)new WaitForSecondsRealtime(0.5f);
				<>1__state = 2;
				return true;
			}
			return false;
		}

		bool IEnumerator.MoveNext()
		{
			//ILSpy generated this explicit interface implementation from .override directive in MoveNext
			return this.MoveNext();
		}

		[DebuggerHidden]
		void IEnumerator.Reset()
		{
			throw new NotSupportedException();
		}
	}

	private string currentScene = "Loader";

	private Mod mod = new Mod();

	private bool initialized;

	private Material sharedGrassMaterial;

	private ModSetting<bool> gymToggle;

	private ModSetting<bool> parkToggle;

	private ModSetting<bool> ringToggle;

	private ModSetting<bool> pitToggle;

	private ModSetting<string> skyboxName;

	private ModSetting<string> skyboxTint;

	private ModSetting<float> skyboxExposure;

	private ModSetting<string> environmentColor;

	private ModSetting<string> lightingColor;

	private ModSetting<string> grassColor;

	private ModSetting<bool> UseTimeBasedLighting;

	private ModSetting<float> timeOffset;

	private List<Renderer> grassRenderers;

	private Light gymLight;

	private object timeBasedLightingCoroutine;

	private static readonly Dictionary<string, float> RegionUTCOffsets = new Dictionary<string, float>
	{
		{ "asia", 8f },
		{ "au", 10f },
		{ "cae", -6f },
		{ "eu", 1f },
		{ "in", 5.5f },
		{ "jp", 9f },
		{ "ru", 3f },
		{ "rue", 8f },
		{ "za", 2f },
		{ "sa", -3f },
		{ "kr", 9f },
		{ "us", -5f },
		{ "usw", -8f }
	};

	public TimePreset[] presets = new TimePreset[4]
	{
		new TimePreset
		{
			hour = 0f,
			ambientColor = HexToColor("1b2e50"),
			fogColor = Color.black,
			directionalLightColor = HexToColor("87919c"),
			sunAngleX = 0f,
			grassColor = HexToColor("2d453c"),
			SkyTint = new Color(0.05f, 0.05f, 0.05f),
			Exposure = 0.3f,
			atmosphereThickness = 0.4f,
			groundColor = new Color(0.05f, 0.05f, 0.05f),
			sunSize = 0.03f,
			sunSizeConvergence = 10f,
			sunColor = new Color(0.5f, 0.5f, 0.5f)
		},
		new TimePreset
		{
			hour = 12f,
			ambientColor = HexToColor("ecf4ff"),
			fogColor = new Color(0.05f, 0.15f, 0.25f),
			directionalLightColor = Color.white,
			sunAngleX = 100f,
			grassColor = HexToColor("82c773"),
			SkyTint = new Color(0.15f, 0.65f, 0.8f),
			Exposure = 0.8f,
			atmosphereThickness = 1f,
			groundColor = new Color(0.05f, 0.25f, 0.4f),
			sunSize = 0.04f,
			sunSizeConvergence = 1f,
			sunColor = new Color(0.629f, 0.599f, 0.612f)
		},
		new TimePreset
		{
			hour = 18.5f,
			ambientColor = HexToColor("917363"),
			fogColor = new Color(0.35f, 0.24f, 0.17f),
			directionalLightColor = HexToColor("e6a570"),
			sunAngleX = 5f,
			grassColor = HexToColor("8f7746"),
			SkyTint = new Color(0.48f, 0.29f, 0.19f),
			Exposure = 0.32f,
			atmosphereThickness = 0.7f,
			groundColor = new Color(0.12f, 0.08f, 0.05f),
			sunSize = 0.07f,
			sunSizeConvergence = 5f,
			sunColor = new Color(0.629f, 0.599f, 0.612f)
		},
		new TimePreset
		{
			hour = 6.5f,
			ambientColor = HexToColor("917363"),
			fogColor = new Color(0.35f, 0.24f, 0.17f),
			directionalLightColor = HexToColor("e6a570"),
			sunAngleX = 5f,
			grassColor = HexToColor("8f7746"),
			SkyTint = new Color(0.48f, 0.29f, 0.19f),
			Exposure = 0.32f,
			atmosphereThickness = 0.7f,
			groundColor = new Color(0.12f, 0.08f, 0.05f),
			sunSize = 0.07f,
			sunSizeConvergence = 5f,
			sunColor = new Color(0.629f, 0.599f, 0.612f)
		}
	};

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

	public float GetTimeWithRegion()
	{
		string key = PhotonNetwork.CloudRegion.ToLower();
		float valueOrDefault = RegionUTCOffsets.GetValueOrDefault(key, 0f);
		return (float)DateTime.UtcNow.AddHours(valueOrDefault).TimeOfDay.TotalHours + (float)((ModSetting)timeOffset).SavedValue;
	}

	[IteratorStateMachine(typeof(<UpdateTimeBasedLighting>d__24))]
	private IEnumerator UpdateTimeBasedLighting()
	{
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <UpdateTimeBasedLighting>d__24(0)
		{
			<>4__this = this
		};
	}

	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_0087: Unknown result type (might be due to invalid IL or missing references)
		//IL_0091: Expected O, but got Unknown
		//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b6: Expected O, but got Unknown
		//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d8: Expected O, but got Unknown
		//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fa: Expected O, but got Unknown
		//IL_0112: Unknown result type (might be due to invalid IL or missing references)
		//IL_011c: Expected O, but got Unknown
		//IL_0134: Unknown result type (might be due to invalid IL or missing references)
		//IL_013e: Expected O, but got Unknown
		//IL_0159: Unknown result type (might be due to invalid IL or missing references)
		//IL_0163: Expected O, but got Unknown
		//IL_017e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0188: Expected O, but got Unknown
		//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ad: Expected O, but got Unknown
		//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d2: Expected O, but got Unknown
		//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f7: Expected O, but got Unknown
		//IL_0212: Unknown result type (might be due to invalid IL or missing references)
		//IL_021c: Expected O, but got Unknown
		mod.ModName = "Rumble Dark Mode";
		mod.ModVersion = "2.2.5";
		mod.SetFolder("RumbleDarkMode");
		mod.AddDescription("Description", "", "Adds a dark mode option to Gym, Park, and Ring!", new Tags
		{
			IsSummary = true
		});
		mod.ModSaved += Initialize;
		UseTimeBasedLighting = mod.AddToList("Use Time-based Lighting", false, 0, "Toggles whether or not it uses the current time in your selected region to set the colors of the environment.", new Tags());
		timeOffset = mod.AddToList("Time Offset (Hours)", 0f, "Offsets the lighting clock by this many hours.", new Tags());
		gymToggle = mod.AddToList("Toggle In Gym", true, 0, "Toggles Dark Mode in Gym", new Tags());
		parkToggle = mod.AddToList("Toggle In Parks", true, 0, "Toggles Dark Mode in Parks", new Tags());
		ringToggle = mod.AddToList("Toggle In Ring", true, 0, "Toggles Dark Mode in Ring", new Tags());
		pitToggle = mod.AddToList("Toggle In Pit", false, 0, "Toggles Dark Mode in Pit (DOESNT LOOK GOOD)", new Tags());
		skyboxName = mod.AddToList("Skybox Name", "NightTime", "Name prefix for the skybox texture set. Stored in UserData/RumbleDarkMode/Skybox/", new Tags());
		skyboxTint = mod.AddToList("Skybox Tint", "404052", "The hex value that represents the skybox tint.\nDefault: 404052 (slate blue)", new Tags());
		skyboxExposure = mod.AddToList("Skybox Exposure", 0.5f, "The value that represents the exposure of the skybox.\nDefault: 0.5", new Tags());
		environmentColor = mod.AddToList("Environment Color", "1b2e50", "The hex value that represents the environment color.\nDefault: 1b2e50 (dark sky)", new Tags());
		lightingColor = mod.AddToList("Lighting Color", "87919c", "The hex value that represents how things like logic components and structures get affected.\nDefault:87919c (dark sky)", new Tags());
		grassColor = mod.AddToList("Grass Color", "2d453c", "The hex value that represents the grass.\nDefault: 2d453c (dark forest green)", new Tags());
		mod.GetFromFile();
		UI.instance.AddMod(mod);
	}

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

	public static Color HexToColor(string hex)
	{
		//IL_0075: Unknown result type (might be due to invalid IL or missing references)
		//IL_007a: 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_002b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0030: Unknown result type (might be due to invalid IL or missing references)
		//IL_0083: Unknown result type (might be due to invalid IL or missing references)
		if (hex.StartsWith("#"))
		{
			hex = hex.Substring(1);
		}
		if (hex.Length != 6)
		{
			return Color.black;
		}
		byte b = byte.Parse(hex.Substring(0, 2), NumberStyles.HexNumber);
		byte b2 = byte.Parse(hex.Substring(2, 2), NumberStyles.HexNumber);
		byte b3 = byte.Parse(hex.Substring(4, 2), NumberStyles.HexNumber);
		return Color32.op_Implicit(new Color32(b, b2, b3, byte.MaxValue));
	}

	private Texture2D LoadSkyboxFace(string face)
	{
		//IL_0074: Unknown result type (might be due to invalid IL or missing references)
		//IL_007b: Expected O, but got Unknown
		string path = Path.Combine(MelonEnvironment.UserDataDirectory, "RumbleDarkMode", "Skybox");
		string path2 = (string)((ModSetting)skyboxName).SavedValue + "_" + face + ".png";
		string text = Path.Combine(path, path2);
		if (!File.Exists(text))
		{
			((MelonBase)this).LoggerInstance.Error("Skybox face missing: " + text);
			return null;
		}
		byte[] array = File.ReadAllBytes(text);
		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 = LoadSkyboxFace("Right");
		Texture2D val2 = LoadSkyboxFace("Left");
		Texture2D val3 = LoadSkyboxFace("Top");
		Texture2D val4 = LoadSkyboxFace("Bottom");
		Texture2D val5 = LoadSkyboxFace("Front");
		Texture2D val6 = LoadSkyboxFace("Back");
		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", (float)((ModSetting)skyboxExposure).SavedValue);
		RenderSettings.skybox = val9;
	}

	private void CacheGrassMaterial()
	{
		Renderer[] array = Il2CppArrayBase<Renderer>.op_Implicit(Object.FindObjectsOfType<Renderer>());
		Renderer[] array2 = array;
		foreach (Renderer val in array2)
		{
			Material sharedMaterial = val.sharedMaterial;
			if ((Object)(object)sharedMaterial != (Object)null && (Object)(object)sharedMaterial.shader != (Object)null && ((Object)sharedMaterial.shader).name.Contains("Grass"))
			{
				sharedGrassMaterial = sharedMaterial;
				break;
			}
		}
		if ((Object)(object)sharedGrassMaterial == (Object)null)
		{
			((MelonBase)this).LoggerInstance.Warning("Grass material not found. Time-based lighting will skip grass.");
		}
	}

	private void CacheLightingTargets()
	{
		grassRenderers = new List<Renderer>();
		foreach (Renderer item in Object.FindObjectsOfType<Renderer>())
		{
			if (((Object)item.material).name.Contains("grass"))
			{
				grassRenderers.Add(item);
				item.sharedMaterial = sharedGrassMaterial;
			}
		}
		if (currentScene == "Gym")
		{
			GameObject gameObject = DirectionalLight.GetGameObject();
			gymLight = ((gameObject != null) ? gameObject.GetComponent<Light>() : null);
		}
	}

	private void Initialize()
	{
		//IL_0194: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
		//IL_03fb: Unknown result type (might be due to invalid IL or missing references)
		//IL_032a: Unknown result type (might be due to invalid IL or missing references)
		//IL_03aa: 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;
		}
		presets = presets.OrderBy((TimePreset p) => p.hour).ToArray();
		CacheGrassMaterial();
		if (!(bool)((ModSetting)UseTimeBasedLighting).SavedValue)
		{
			SetSkybox();
		}
		else
		{
			if (timeBasedLightingCoroutine != null)
			{
				MelonCoroutines.Stop(timeBasedLightingCoroutine);
			}
			RenderSettings.skybox = Calls.LoadAssetFromStream<Material>((MelonMod)(object)this, "RumbleDarkMode.Resources.rumbledarkmode", "ProceduralSkybox");
			timeBasedLightingCoroutine = MelonCoroutines.Start(UpdateTimeBasedLighting());
		}
		CacheLightingTargets();
		RenderSettings.ambientMode = (AmbientMode)1;
		RenderSettings.ambientIntensity = 1f;
		RenderSettings.ambientLight = HexToColor((string)((ModSetting)environmentColor).SavedValue);
		RenderSettings.defaultReflectionMode = (DefaultReflectionMode)0;
		RenderSettings.fogColor = Color.black;
		RenderSettings.skybox.SetColor("_Tint", HexToColor((string)((ModSetting)skyboxTint).SavedValue));
		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 == "picture") && !(((Object)((Component)val2).gameObject).name == "FadeScreenRenderer") && !((Object)val2.material.shader).name.Contains("Player"))
			{
				val2.lightmapIndex = -1;
				val2.lightProbeUsage = (LightProbeUsage)0;
				if (currentScene == "Map1" && ((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);
				}
				if (((Object)val2.material).name.Contains("grass"))
				{
					val2.lightmapIndex = 0;
					sharedGrassMaterial.SetColor("Color_1", HexToColor((string)((ModSetting)grassColor).SavedValue));
				}
			}
		}
		LightmapSettings.lightmaps = null;
		if (currentScene == "Gym")
		{
			gymLight.color = HexToColor((string)((ModSetting)lightingColor).SavedValue);
		}
		initialized = true;
	}
}