Decompiled source of RumbleTrees v1.4.1

Mods/RUMBLECherryBlossoms.dll

Decompiled 2 weeks 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.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text.RegularExpressions;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using MelonLoader;
using Microsoft.CodeAnalysis;
using RUMBLECherryBlossoms;
using RumbleModUI;
using UnityEngine;
using UnityEngine.VFX;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: MelonInfo(typeof(Core), "RumbleTrees", "1.4.1", "Orangenal", null)]
[assembly: MelonGame("Buckethead Entertainment", "RUMBLE")]
[assembly: MelonColor(255, 219, 138, 230)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("RUMBLECherryBlossoms")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+5d72e865690a438201ee1004fdfb6677b8b4d2eb")]
[assembly: AssemblyProduct("RUMBLECherryBlossoms")]
[assembly: AssemblyTitle("RUMBLECherryBlossoms")]
[assembly: NeutralResourcesLanguage("en-US")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.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 RUMBLECherryBlossoms
{
	public static class BuildInfo
	{
		public const string Version = "1.4.1";
	}
	public class Validation : ValidationParameters
	{
		private string[] themes = new string[6] { "cherry", "orange", "yellow", "red", "rainbow", "vanilla" };

		private string type;

		public Validation(string type)
		{
			this.type = type;
		}

		public override bool DoValidation(string Input)
		{
			string pattern = "^(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)\\s(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)\\s(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)$";
			string pattern2 = "^#?[0-9A-Fa-f]{6}$";
			if (Regex.IsMatch(Input, pattern))
			{
				return true;
			}
			if (Regex.IsMatch(Input, pattern2))
			{
				return true;
			}
			if (themes.Contains(Input.ToLower()) && type == "leaf")
			{
				return true;
			}
			if (Input.ToLower() == "rainbow" && type == "root")
			{
				return true;
			}
			if (Input.ToLower() == "vanilla" && type == "root")
			{
				return true;
			}
			return false;
		}
	}
	public class Core : MelonMod
	{
		internal static Color[] shades = (Color[])(object)new Color[3];

		internal static Color[] originalShades = (Color[])(object)new Color[5];

		private bool[] originalSaved = new bool[3];

		private Color selectedLeafColour;

		private Color selectedRootColour;

		private Color cherryColour = new Color(0.86f, 0.54f, 0.9f, 1f);

		private Color orangeColour = new Color(1f, 0.44f, 0f, 1f);

		private Color yellowColour = new Color(1f, 0.78f, 0f, 1f);

		private Color redColour = new Color(0.66f, 0f, 0f, 1f);

		private int LCT1 = 1475;

		private int LCB1 = 1476;

		private int LCT2 = 1477;

		private int LCB2 = 1479;

		private int FLG = 1110;

		private int RC1 = 1203;

		private int RC2 = 1303;

		private bool gotPropertyIDs;

		private Material leafMaterial;

		private Material rootMaterial;

		private List<MeshRenderer> renderers = new List<MeshRenderer>();

		private List<GameObject> leafObjects = new List<GameObject>();

		private List<GameObject> rootObjects = new List<GameObject>();

		private GameObject VFXsObject;

		private int sceneID = -1;

		private bool wasSceneChanged;

		private bool wasLightmapChanged;

		private Texture2D lightmap;

		private Il2CppAssetBundle assetBundle;

		private int rainbowHue;

		private object rainbowCoroutine;

		private object rainbowRootCoroutine;

		private bool isRainbow;

		private bool isRainbowRoot;

		private bool leavesEnabled = true;

		private bool rootsEnabled;

		private Mod RumbleTrees = new Mod();

		private Texture2D LoadAsset()
		{
			if (assetBundle == null)
			{
				using Stream stream = ((MelonBase)this).MelonAssembly.Assembly.GetManifestResourceStream("RUMBLECherryBlossoms.Resources.rumbletrees");
				if (stream == null)
				{
					MelonLogger.Error("Failed to find resource stream!");
					return null;
				}
				byte[] array = new byte[stream.Length];
				stream.Read(array, 0, array.Length);
				assetBundle = Il2CppAssetBundleManager.LoadFromMemory(Il2CppStructArray<byte>.op_Implicit(array));
			}
			if (assetBundle == null)
			{
				MelonLogger.Error("AssetBundle failed to load.");
				return null;
			}
			Texture2D val;
			if (sceneID == 2)
			{
				val = assetBundle.LoadAsset<Texture2D>("MAP0_final");
			}
			else
			{
				if (sceneID != 4)
				{
					MelonLogger.Error("Wrong scene!");
					return null;
				}
				val = assetBundle.LoadAsset<Texture2D>("park0_final");
			}
			if ((Object)(object)val == (Object)null)
			{
				MelonLogger.Error("Failed to load texture from AssetBundle!");
			}
			else
			{
				val.Apply(true, false);
			}
			return val;
		}

		public override void OnLateInitializeMelon()
		{
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: 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_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Expected O, but got Unknown
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Expected O, but got Unknown
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Expected O, but got Unknown
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Expected O, but got Unknown
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Expected O, but got Unknown
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Expected O, but got Unknown
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Expected O, but got Unknown
			((MelonBase)this).OnLateInitializeMelon();
			RumbleTrees.ModName = "RumbleTrees";
			RumbleTrees.ModVersion = "1.4.1";
			RumbleTrees.SetFolder("RumbleTrees");
			RumbleTrees.AddDescription("Description", "", "Make them pretty!\n\nCurrent presets:\nCherry\nOrange\nYellow\nRed\nRainbow\nVanilla (literally does nothing)", new Tags
			{
				IsSummary = true
			});
			RumbleTrees.AddToList("Enabled on Pit", true, 0, "Enables custom tree colours on the pit map", new Tags());
			RumbleTrees.AddToList("Enabled on Ring", true, 0, "Enables custom tree colours on the ring map", new Tags());
			RumbleTrees.AddToList("Enabled in Gym", true, 0, "Enables custom tree colours in the gym", new Tags());
			RumbleTrees.AddToList("Enabled in Parks", true, 0, "Enables custom tree colours in parks", new Tags());
			RumbleTrees.AddToList("Legacy shaders", false, 0, "Enables the vanilla lightmaps in Ring and Parks, which look different and don't work properly with all leaf colours", new Tags());
			RumbleTrees.AddToList("Leaf colour", "Cherry", "Type in either a preset name or a custom colour in one of the supported formats: \n255 255 255\nFFFFFF", new Tags());
			RumbleTrees.AddToList("Root colour", "FFFFFF", "Type in either \"Rainbow,\" \"Vanilla,\" or a custom colour in one of the supported formats: \n255 255 255\nFFFFFF", new Tags());
			RumbleTrees.AddToList("Rainbow speed", 1, "The speed of rainbow leaves (if selected)", new Tags());
			RumbleTrees.AddValidation("Leaf colour", (ValidationParameters)(object)new Validation("leaf"));
			RumbleTrees.AddValidation("Root colour", (ValidationParameters)(object)new Validation("root"));
			RumbleTrees.GetFromFile();
			RumbleTrees.ModSaved += OnSave;
			RumbleTrees.Settings[5].SavedValueChanged += OnLegacyChange;
			RumbleTrees.Settings[6].SavedValueChanged += OnColourChange;
			RumbleTrees.Settings[7].SavedValueChanged += OnRootChange;
			UI.instance.UI_Initialized += OnUIInit;
			string text = (string)RumbleTrees.Settings[6].SavedValue;
			if (checkCustom(text))
			{
				setCustom(text, "leaves");
			}
			else
			{
				setSelectedColour(text);
			}
			string input = (string)RumbleTrees.Settings[7].SavedValue;
			setCustom(input, "roots");
		}

		public void OnColourChange(object sender = null, EventArgs e = null)
		{
			string value = ((ValueChange<string>)(object)e).Value;
			if (checkCustom(value))
			{
				setCustom(value, "leaves");
			}
			else
			{
				setSelectedColour(value);
			}
			UpdateColours(reset: false, "leaves");
		}

		public void OnRootChange(object sender = null, EventArgs e = null)
		{
			string value = ((ValueChange<string>)(object)e).Value;
			setCustom(value, "roots");
			UpdateColours(reset: false, "roots");
		}

		public void OnLegacyChange(object sender = null, EventArgs e = null)
		{
			if (sceneID == 2 || (sceneID == 4 && leavesEnabled))
			{
				MelonCoroutines.Start(SwapLightmap(((ValueChange<bool>)(object)e).Value));
			}
		}

		public void OnSave()
		{
			if ((bool)RumbleTrees.Settings[sceneID].SavedValue != wasSceneChanged)
			{
				UpdateColours(wasSceneChanged);
				if (!wasSceneChanged && isRainbow)
				{
					rainbowCoroutine = MelonCoroutines.Start(RAINBOW());
				}
				if (!wasSceneChanged && isRainbowRoot)
				{
					rainbowRootCoroutine = MelonCoroutines.Start(RAINBOWROOT());
				}
				if ((sceneID == 2 || sceneID == 4) && leavesEnabled)
				{
					MelonCoroutines.Start(SwapLightmap(wasSceneChanged || (bool)RumbleTrees.Settings[5].Value));
				}
				wasSceneChanged = !wasSceneChanged;
			}
		}

		public void OnUIInit()
		{
			UI.instance.AddMod(RumbleTrees);
		}

		public override void OnSceneWasLoaded(int buildIndex, string sceneName)
		{
			if (!gotPropertyIDs)
			{
				LCT1 = Shader.PropertyToID("Color_133d236fee76457eb89bac53e692f8a3");
				LCB1 = Shader.PropertyToID("Color_6f942b46fda341409751e4e7f292de58");
				LCT2 = Shader.PropertyToID("Vector3_fa2c0c5c11884cdfbeb10e0460312f5c");
				LCB2 = Shader.PropertyToID("Color_d75e4f72dbfb4e7187f1c2d80558c414");
				FLG = Shader.PropertyToID("Leaf Color Gradient");
				RC1 = Shader.PropertyToID("Color_FA790384");
				RC2 = Shader.PropertyToID("Color_c7120f3b741f4dd48575e89d95f9641d");
				gotPropertyIDs = true;
			}
			leafObjects = new List<GameObject>();
			rootObjects = new List<GameObject>();
			renderers.Clear();
			VFXsObject = null;
			wasSceneChanged = false;
			wasLightmapChanged = false;
			switch (sceneName)
			{
			default:
				return;
			case "Map0":
				leafObjects.Add(GameObject.Find("Map0_production/Main static group/leave"));
				rootObjects.Add(GameObject.Find("Map0_production/Main static group/Root"));
				sceneID = 2;
				break;
			case "Map1":
				leafObjects.Add(GameObject.Find("Map1_production/Main static group/Leaves_Map2"));
				VFXsObject = GameObject.Find("Lighting & Effects/Visual Effects/Falling Leaf VFXs");
				sceneID = 1;
				break;
			case "Gym":
				leafObjects.Add(GameObject.Find("--------------SCENE--------------/Gym_Production/Main static group/Foliage/Root_leaves (1)"));
				leafObjects.Add(GameObject.Find("--------------SCENE--------------/Gym_Production/Main static group/Foliage/Root_leaves_001 (1)"));
				leafObjects.Add(GameObject.Find("--------------SCENE--------------/Gym_Production/Main static group/Foliage/Root_leaves_002 (1)"));
				leafObjects.Add(GameObject.Find("--------------SCENE--------------/Gym_Production/Main static group/Foliage/Root_leaves_003 (1)"));
				leafObjects.Add(GameObject.Find("--------------SCENE--------------/Gym_Production/Main static group/Gymarena/Leave_sphere__23_"));
				leafObjects.Add(GameObject.Find("--------------SCENE--------------/Gym_Production/Main static group/Gymarena/Leave_sphere__24_"));
				rootObjects.Add(GameObject.Find("--------------SCENE--------------/Gym_Production/Sub static group/Scene_roots/Test_root_1_middetail/Cylinder_014__6_"));
				rootObjects.Add(GameObject.Find("--------------SCENE--------------/Gym_Production/Sub static group/Scene_roots/Test_root_1_middetail/Cylinder_015__1_"));
				rootObjects.Add(GameObject.Find("--------------SCENE--------------/Gym_Production/Sub static group/Scene_roots/Test_root_1_middetail/Cylinder_015__4__1"));
				rootObjects.Add(GameObject.Find("--------------SCENE--------------/Gym_Production/Sub static group/Scene_roots/Test_root_1_middetail/Cylinder_018__2_"));
				rootObjects.Add(GameObject.Find("--------------SCENE--------------/Gym_Production/Sub static group(buildings)/Rumble_station/Root"));
				rootObjects.Add(GameObject.Find("--------------SCENE--------------/Gym_Production/Sub static group(buildings)/School/Cylinder_011"));
				rootObjects.Add(GameObject.Find("--------------SCENE--------------/Gym_Production/Main static group/Gymarena/Cylinder_015__4_"));
				VFXsObject = GameObject.Find("--------------SCENE--------------/Lighting and effects/Visual Effects/Falling Leaf VFXs");
				sceneID = 3;
				break;
			case "Park":
			{
				leafObjects.Add(GameObject.Find("________________SCENE_________________/Park/Main static group/Leaves/Leave_sphere_park"));
				leafObjects.Add(GameObject.Find("________________SCENE_________________/Park/Main static group/Leaves/Leave_sphere_park_001"));
				leafObjects.Add(GameObject.Find("________________SCENE_________________/Park/Main static group/Leaves/Leave_sphere_park_002"));
				leafObjects.Add(GameObject.Find("________________SCENE_________________/Park/Main static group/Leaves/Leave_sphere_park_003"));
				GameObject val = GameObject.Find("________________SCENE_________________/Park/Main static group/Root/");
				for (int i = 0; i < val.transform.childCount; i++)
				{
					rootObjects.Add(((Component)val.transform.GetChild(i)).gameObject);
				}
				VFXsObject = GameObject.Find("Lighting and effects/Visual Effects/Falling Leaf VFXs");
				sceneID = 4;
				break;
			}
			}
			if ((bool)RumbleTrees.Settings[sceneID].SavedValue)
			{
				UpdateColours();
				if (isRainbow)
				{
					rainbowCoroutine = MelonCoroutines.Start(RAINBOW());
				}
				if (isRainbowRoot)
				{
					rainbowRootCoroutine = MelonCoroutines.Start(RAINBOWROOT());
				}
				wasSceneChanged = true;
			}
		}

		public override void OnSceneWasUnloaded(int buildIndex, string sceneName)
		{
			if (rainbowCoroutine != null)
			{
				MelonCoroutines.Stop(rainbowCoroutine);
			}
			if (rainbowRootCoroutine != null)
			{
				MelonCoroutines.Stop(rainbowRootCoroutine);
			}
		}

		public bool checkCustom(string Input)
		{
			string pattern = "^(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)\\s(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)\\s(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)$";
			string pattern2 = "^#?[0-9A-Fa-f]{6}$";
			if (Regex.IsMatch(Input, pattern))
			{
				return true;
			}
			if (Regex.IsMatch(Input, pattern2))
			{
				return true;
			}
			return false;
		}

		public void setCustom(string input, string type)
		{
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_0171: Unknown result type (might be due to invalid IL or missing references)
			rootsEnabled = true;
			if (rainbowRootCoroutine != null)
			{
				MelonCoroutines.Stop(rainbowRootCoroutine);
			}
			isRainbowRoot = false;
			if (input.ToLower() == "rainbow" && type == "roots")
			{
				isRainbowRoot = true;
				if (sceneID != -1)
				{
					rainbowRootCoroutine = MelonCoroutines.Start(RAINBOWROOT());
				}
				return;
			}
			if (input.ToLower() == "vanilla" && type == "roots")
			{
				rootsEnabled = false;
				return;
			}
			Color val = default(Color);
			if (input.Contains(" "))
			{
				string[] array = input.Split(' ');
				if (array.Length != 3 || !byte.TryParse(array[0], out var result) || !byte.TryParse(array[1], out var result2) || !byte.TryParse(array[2], out var result3))
				{
					MelonLogger.Error("Somehow not a valid colour");
					return;
				}
				((Color)(ref val))..ctor((float)(int)result / 255f, (float)(int)result2 / 255f, (float)(int)result3 / 255f);
			}
			else
			{
				if (input.Length != 6 || !int.TryParse(input, NumberStyles.HexNumber, null, out var result4))
				{
					MelonLogger.Error("Somehow not a valid colour");
					return;
				}
				float num = (float)((result4 >> 16) & 0xFF) / 255f;
				float num2 = (float)((result4 >> 8) & 0xFF) / 255f;
				float num3 = (float)(result4 & 0xFF) / 255f;
				((Color)(ref val))..ctor(num, num2, num3);
			}
			if (type == "leaves")
			{
				selectedLeafColour = val;
			}
			else
			{
				selectedRootColour = val;
			}
		}

		public void setSelectedColour(string colour, bool custom = false)
		{
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: 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)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			if (rainbowCoroutine != null)
			{
				MelonCoroutines.Stop(rainbowCoroutine);
			}
			isRainbow = false;
			if (!leavesEnabled && (sceneID == 2 || sceneID == 4))
			{
				MelonCoroutines.Start(SwapLightmap());
			}
			leavesEnabled = true;
			switch (colour.ToLower())
			{
			case "cherry":
				selectedLeafColour = cherryColour;
				break;
			case "orange":
				selectedLeafColour = orangeColour;
				break;
			case "yellow":
				selectedLeafColour = yellowColour;
				break;
			case "red":
				selectedLeafColour = redColour;
				break;
			case "rainbow":
				isRainbow = true;
				if (sceneID != -1)
				{
					rainbowCoroutine = MelonCoroutines.Start(RAINBOW());
				}
				break;
			case "vanilla":
				leavesEnabled = false;
				if (isRainbow)
				{
					isRainbow = false;
				}
				if (rainbowCoroutine != null)
				{
					MelonCoroutines.Stop(rainbowCoroutine);
				}
				if (sceneID == 2 || sceneID == 4)
				{
					MelonCoroutines.Start(SwapLightmap(legacy: true));
				}
				break;
			}
		}

		private IEnumerator RAINBOW()
		{
			WaitForFixedUpdate waitForFixedUpdate = new WaitForFixedUpdate();
			int speed = (int)RumbleTrees.Settings[8].SavedValue;
			int FrameCounter = 10 / (speed * 10) - 1;
			while (true)
			{
				if (FrameCounter >= 2)
				{
					if (rainbowHue >= 360)
					{
						rainbowHue = 0;
					}
					selectedLeafColour = Color.HSVToRGB((float)rainbowHue / 360f, 1f, 1f);
					UpdateColours(reset: false, "leaves");
					if (speed > 10)
					{
						rainbowHue += speed / 10;
					}
					rainbowHue++;
					FrameCounter = 0;
				}
				FrameCounter++;
				yield return waitForFixedUpdate;
			}
		}

		private IEnumerator RAINBOWROOT()
		{
			WaitForFixedUpdate waitForFixedUpdate = new WaitForFixedUpdate();
			int speed = (int)RumbleTrees.Settings[8].SavedValue;
			int FrameCounter = 10 / (speed * 10) - 1;
			while (true)
			{
				if (FrameCounter >= 2)
				{
					if (rainbowHue >= 360)
					{
						rainbowHue = 0;
					}
					selectedRootColour = Color.HSVToRGB((float)rainbowHue / 360f, 1f, 1f);
					UpdateColours(reset: false, "roots");
					if (speed > 10)
					{
						rainbowHue += speed / 10;
					}
					rainbowHue++;
					FrameCounter = 0;
				}
				FrameCounter++;
				yield return waitForFixedUpdate;
			}
		}

		private IEnumerator SwapLightmap(bool legacy = false)
		{
			yield return (object)new WaitForSeconds(0.2f);
			if (!legacy && !wasLightmapChanged)
			{
				lightmap = LoadAsset();
				if ((Object)(object)lightmap == (Object)null)
				{
					MelonLogger.Error("Lightmap is null!");
					yield break;
				}
				LightmapData[] array = Il2CppArrayBase<LightmapData>.op_Implicit((Il2CppArrayBase<LightmapData>)(object)LightmapSettings.lightmaps);
				LightmapData[] array2 = (LightmapData[])(object)new LightmapData[array.Length + 1];
				for (int i = 0; i < array.Length; i++)
				{
					array2[i] = array[i];
				}
				LightmapData val = new LightmapData
				{
					lightmapColor = lightmap
				};
				array2[array.Length] = val;
				LightmapSettings.lightmaps = Il2CppReferenceArray<LightmapData>.op_Implicit(array2);
				foreach (MeshRenderer renderer in renderers)
				{
					((Renderer)renderer).lightmapIndex = array2.Length - 1;
					((Renderer)renderer).lightmapScaleOffset = new Vector4(1f, 1f, 0f, 0f);
				}
				wasLightmapChanged = true;
				yield break;
			}
			if (!legacy && wasLightmapChanged)
			{
				foreach (MeshRenderer renderer2 in renderers)
				{
					((Renderer)renderer2).lightmapIndex = 2;
				}
				yield break;
			}
			foreach (MeshRenderer renderer3 in renderers)
			{
				((Renderer)renderer3).lightmapIndex = 1;
			}
		}

		private void UpdateColours(bool reset = false, string type = "all")
		{
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0364: Unknown result type (might be due to invalid IL or missing references)
			//IL_0369: Unknown result type (might be due to invalid IL or missing references)
			//IL_037c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0381: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: 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)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e8: 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_0400: Unknown result type (might be due to invalid IL or missing references)
			//IL_03bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0171: Unknown result type (might be due to invalid IL or missing references)
			//IL_0176: Unknown result type (might be due to invalid IL or missing references)
			//IL_0185: Unknown result type (might be due to invalid IL or missing references)
			//IL_018a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0506: Unknown result type (might be due to invalid IL or missing references)
			//IL_0522: Unknown result type (might be due to invalid IL or missing references)
			//IL_058e: Unknown result type (might be due to invalid IL or missing references)
			//IL_055e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0563: Unknown result type (might be due to invalid IL or missing references)
			//IL_057a: Unknown result type (might be due to invalid IL or missing references)
			//IL_057f: Unknown result type (might be due to invalid IL or missing references)
			//IL_021d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0239: Unknown result type (might be due to invalid IL or missing references)
			//IL_0255: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_027a: Unknown result type (might be due to invalid IL or missing references)
			//IL_05f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_05fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_060c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0611: Unknown result type (might be due to invalid IL or missing references)
			//IL_0628: Unknown result type (might be due to invalid IL or missing references)
			//IL_0644: Unknown result type (might be due to invalid IL or missing references)
			if (type == "leaves" || type == "all")
			{
				if (leafObjects.Count != 0)
				{
					float num = default(float);
					float num2 = default(float);
					float num3 = default(float);
					foreach (GameObject leafObject in leafObjects)
					{
						MeshRenderer component = leafObject.GetComponent<MeshRenderer>();
						renderers.Add(component);
						leafMaterial = ((Renderer)component).material;
						if (reset || !leavesEnabled)
						{
							if (originalSaved[0])
							{
								if (isRainbow && rainbowCoroutine != null)
								{
									MelonCoroutines.Stop(rainbowCoroutine);
								}
								leafMaterial.SetColor(LCT1, originalShades[2]);
								leafMaterial.SetColor(LCB1, originalShades[0]);
								leafMaterial.SetColor(LCT2, originalShades[2]);
								leafMaterial.SetColor(LCB2, originalShades[0]);
							}
							continue;
						}
						Color.RGBToHSV(selectedLeafColour, ref num, ref num2, ref num3);
						if (num2 > 0.9f)
						{
							num2 = 0.9f;
						}
						if (num2 < 0.1f)
						{
							num2 = 0.1f;
						}
						if (num3 > 0.9f)
						{
							num3 = 0.9f;
						}
						if (num3 < 0.1f)
						{
							num3 = 0.1f;
						}
						shades[0] = Color.HSVToRGB(num, num2 - 0.1f, num3 - 0.1f);
						shades[1] = Color.HSVToRGB(num, num2, num3);
						shades[2] = Color.HSVToRGB(num, num2 + 0.1f, num3 + 0.1f);
						if ((Object)(object)leafMaterial != (Object)null)
						{
							if (!originalSaved[0])
							{
								originalShades[2] = leafMaterial.GetColor(LCT1);
								originalShades[0] = leafMaterial.GetColor(LCB1);
								originalSaved[0] = true;
							}
							leafMaterial.SetColor(LCT1, shades[2]);
							leafMaterial.SetColor(LCB1, shades[0]);
							leafMaterial.SetColor(LCT2, shades[2]);
							if (sceneID != 3)
							{
								leafMaterial.SetColor(LCB2, shades[0]);
							}
						}
					}
					if ((sceneID == 2 || sceneID == 4) && !(bool)RumbleTrees.Settings[5].SavedValue && leavesEnabled)
					{
						MelonCoroutines.Start(SwapLightmap());
					}
				}
				else
				{
					MelonLogger.Warning("Leaf object not found!");
				}
				if ((Object)(object)VFXsObject != (Object)null)
				{
					for (int i = 0; i < VFXsObject.transform.GetChildCount(); i++)
					{
						VisualEffect component2 = ((Component)VFXsObject.transform.GetChild(i)).gameObject.GetComponent<VisualEffect>();
						GradientColorKey[] array = (GradientColorKey[])(object)new GradientColorKey[2];
						Gradient gradient = component2.GetGradient(FLG);
						if (reset || !leavesEnabled)
						{
							if (originalSaved[1])
							{
								array[0].color = originalShades[1];
								array[1].color = originalShades[1];
								gradient.colorKeys = Il2CppStructArray<GradientColorKey>.op_Implicit(array);
								component2.SetGradient(FLG, gradient);
							}
							continue;
						}
						if (!originalSaved[1])
						{
							originalShades[1] = ((Il2CppArrayBase<GradientColorKey>)(object)gradient.colorKeys)[0].color;
							originalSaved[1] = true;
						}
						array[0].color = shades[1];
						array[1].color = shades[1];
						gradient.colorKeys = Il2CppStructArray<GradientColorKey>.op_Implicit(array);
						component2.SetGradient(FLG, gradient);
					}
				}
				else if (sceneID == 0 || sceneID == 3)
				{
					MelonLogger.Warning("Leaf VFX object not found!");
				}
			}
			if ((!(type == "roots") && !(type == "all")) || sceneID == 1 || rootObjects.Count == 0)
			{
				return;
			}
			float num4 = default(float);
			float num5 = default(float);
			float num6 = default(float);
			foreach (GameObject rootObject in rootObjects)
			{
				MeshRenderer component3 = rootObject.GetComponent<MeshRenderer>();
				rootMaterial = ((Renderer)component3).material;
				if (reset || !rootsEnabled)
				{
					if (originalSaved[2])
					{
						if (isRainbowRoot && rainbowRootCoroutine != null)
						{
							MelonCoroutines.Stop(rainbowRootCoroutine);
						}
						rootMaterial.SetColor(RC1, originalShades[3]);
						rootMaterial.SetColor(RC2, originalShades[4]);
					}
				}
				else if ((Object)(object)rootMaterial != (Object)null)
				{
					if (!originalSaved[2])
					{
						originalShades[3] = rootMaterial.GetColor(RC1);
						originalShades[4] = rootMaterial.GetColor(RC2);
						originalSaved[2] = true;
					}
					Color.RGBToHSV(selectedRootColour, ref num4, ref num5, ref num6);
					if (num5 > 0.9f)
					{
						num5 = 0.9f;
					}
					if (num5 < 0.1f)
					{
						num5 = 0.1f;
					}
					if (num6 > 0.9f)
					{
						num6 = 0.9f;
					}
					if (num6 < 0.1f)
					{
						num6 = 0.1f;
					}
					shades[0] = Color.HSVToRGB(num4, num5 - 0.1f, num6 - 0.3f);
					shades[1] = Color.HSVToRGB(num4, num5, num6);
					rootMaterial.SetColor(RC1, shades[0]);
					rootMaterial.SetColor(RC2, shades[1]);
				}
			}
		}
	}
}