Decompiled source of RumbleTrees v2.2.0

Mods/RumbleTrees.dll

Decompiled a week ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
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 Il2CppRUMBLE.Combat.ShiftStones;
using Il2CppRUMBLE.Utilities;
using MelonLoader;
using Microsoft.CodeAnalysis;
using RumbleModUI;
using RumbleModdingAPI;
using RumbleTrees;
using UnityEngine;
using UnityEngine.VFX;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: MelonInfo(typeof(Core), "RumbleTrees", "2.2.0", "Orangenal", "https://thunderstore.io/c/rumble/p/Orangenal/RumbleTrees/")]
[assembly: MelonGame("Buckethead Entertainment", "RUMBLE")]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("RumbleTrees")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+d8477ebbd5dd8f5ed643aa6708b7e083385dab84")]
[assembly: AssemblyProduct("RumbleTrees")]
[assembly: AssemblyTitle("RumbleTrees")]
[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 RumbleTrees
{
	public static class BuildInfo
	{
		public const string Version = "2.2.0";

		public const string Name = "RumbleTrees";

		public const string Author = "Orangenal";

		public const string DownloadLink = "https://thunderstore.io/c/rumble/p/Orangenal/RumbleTrees/";
	}
	public class Validation : ValidationParameters
	{
		private string[] themes = new string[4] { "cherry", "orange", "yellow", "red" };

		public static string[] stones = new string[8] { "flow", "vigor", "volatile", "adamant", "charge", "guard", "stubborn", "surge" };

		public static string[] leafMats = new string[10] { "flow", "vigor", "volatile", "adamant", "charge", "guard", "stubborn", "surge", "vanilla", "roots" };

		public static string[] rootMats = new string[10] { "flow", "vigor", "volatile", "adamant", "charge", "guard", "stubborn", "surge", "vanilla", "leaves" };

		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 (Input.ToLower() == "random")
			{
				return true;
			}
			if (Input.ToLower() == "vanilla")
			{
				return true;
			}
			if (type == "rootMat")
			{
				return rootMats.Contains(Input.ToLower());
			}
			if (type == "leafMat")
			{
				return leafMats.Contains(Input.ToLower());
			}
			if (Regex.IsMatch(Input, pattern) || Regex.IsMatch(Input, pattern2))
			{
				return true;
			}
			Input = Input.ToLower();
			if (Input == "rainbow")
			{
				return true;
			}
			if (themes.Contains(Input) && type == "leaf")
			{
				return true;
			}
			return false;
		}
	}
	public class Core : MelonMod
	{
		[CompilerGenerated]
		private sealed class <RAINBOWLEAVES>d__62 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public Core <>4__this;

			private WaitForFixedUpdate <waitForFixedUpdate>5__2;

			private int <FrameCounter>5__3;

			private int <rainbowHue>5__4;

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

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

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

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

			private bool MoveNext()
			{
				//IL_0022: Unknown result type (might be due to invalid IL or missing references)
				//IL_002c: Expected O, but got Unknown
				//IL_006f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0074: Unknown result type (might be due to invalid IL or missing references)
				//IL_007b: Unknown result type (might be due to invalid IL or missing references)
				int num = <>1__state;
				Core core = <>4__this;
				if (num != 0)
				{
					if (num != 1)
					{
						return false;
					}
					<>1__state = -1;
				}
				else
				{
					<>1__state = -1;
					<waitForFixedUpdate>5__2 = new WaitForFixedUpdate();
					<FrameCounter>5__3 = 0;
					<rainbowHue>5__4 = 0;
				}
				if (<FrameCounter>5__3 >= 2)
				{
					if (<rainbowHue>5__4 >= 360)
					{
						<rainbowHue>5__4 = 0;
					}
					core.selectedLeafColour = Color.HSVToRGB((float)<rainbowHue>5__4 / 360f, 1f, 1f);
					core.UpdateLeafColour(core.selectedLeafColour);
					<rainbowHue>5__4 += (int)core.RumbleTrees.Settings[10].SavedValue;
					<FrameCounter>5__3 = 0;
				}
				<FrameCounter>5__3++;
				<>2__current = <waitForFixedUpdate>5__2;
				<>1__state = 1;
				return true;
			}

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

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

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

			private object <>2__current;

			public Core <>4__this;

			private WaitForFixedUpdate <waitForFixedUpdate>5__2;

			private int <FrameCounter>5__3;

			private int <rainbowHue>5__4;

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

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

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

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

			private bool MoveNext()
			{
				//IL_0022: Unknown result type (might be due to invalid IL or missing references)
				//IL_002c: Expected O, but got Unknown
				//IL_006f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0074: Unknown result type (might be due to invalid IL or missing references)
				//IL_007b: Unknown result type (might be due to invalid IL or missing references)
				int num = <>1__state;
				Core core = <>4__this;
				if (num != 0)
				{
					if (num != 1)
					{
						return false;
					}
					<>1__state = -1;
				}
				else
				{
					<>1__state = -1;
					<waitForFixedUpdate>5__2 = new WaitForFixedUpdate();
					<FrameCounter>5__3 = 0;
					<rainbowHue>5__4 = 0;
				}
				if (<FrameCounter>5__3 >= 2)
				{
					if (<rainbowHue>5__4 >= 360)
					{
						<rainbowHue>5__4 = 0;
					}
					core.selectedRootColour = Color.HSVToRGB((float)<rainbowHue>5__4 / 360f, 1f, 1f);
					core.UpdateRootColour(core.selectedRootColour);
					<rainbowHue>5__4 += (int)core.RumbleTrees.Settings[10].SavedValue;
					<FrameCounter>5__3 = 0;
				}
				<FrameCounter>5__3++;
				<>2__current = <waitForFixedUpdate>5__2;
				<>1__state = 1;
				return true;
			}

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

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

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

			private object <>2__current;

			public string sceneName;

			public bool original;

			public Core <>4__this;

			public MeshRenderer renderer;

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

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

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

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

			private bool MoveNext()
			{
				//IL_0033: Unknown result type (might be due to invalid IL or missing references)
				//IL_003d: Expected O, but got Unknown
				//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)
				//IL_011f: Expected O, but got Unknown
				//IL_015f: Unknown result type (might be due to invalid IL or missing references)
				int num = <>1__state;
				Core core = <>4__this;
				switch (num)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					if (sceneName == "Pit")
					{
						return false;
					}
					<>2__current = (object)new WaitForFixedUpdate();
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					if (!original && !core.wasLightmapChanged)
					{
						string assetName = sceneName.Trim() + "_Lightmap";
						Texture2D val = (Texture2D)core.LoadAsset<Texture2D>(assetName, core.assetBundle);
						if ((Object)(object)val == (Object)null)
						{
							MelonLogger.Error("Lightmap is null!");
							return false;
						}
						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 val2 = new LightmapData
						{
							lightmapColor = val
						};
						array2[array.Length] = val2;
						LightmapSettings.lightmaps = Il2CppReferenceArray<LightmapData>.op_Implicit(array2);
						((Renderer)renderer).lightmapIndex = array2.Length - 1;
						((Renderer)renderer).lightmapScaleOffset = new Vector4(1f, 1f, 0f, 0f);
						core.wasLightmapChanged = true;
					}
					else if (!original && core.wasLightmapChanged)
					{
						((Renderer)renderer).lightmapIndex = ((Il2CppArrayBase<LightmapData>)(object)LightmapSettings.lightmaps).Length - 1;
					}
					else if (sceneName != "Park")
					{
						((Renderer)renderer).lightmapIndex = 0;
					}
					else
					{
						((Renderer)renderer).lightmapIndex = 1;
					}
					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();
			}
		}

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

			private object <>2__current;

			public Core <>4__this;

			public string materialName;

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

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

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

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

			private bool MoveNext()
			{
				//IL_0184: Unknown result type (might be due to invalid IL or missing references)
				//IL_015e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0138: Unknown result type (might be due to invalid IL or missing references)
				int num = <>1__state;
				Core core = <>4__this;
				switch (num)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					if (core.currentScene == "Loader")
					{
						return false;
					}
					if (!core.enabled)
					{
						return false;
					}
					if (core.leafObjects.Count != 0)
					{
						if (materialName == "random" && core.enabled)
						{
							materialName = Validation.leafMats[core.rand.Next(Validation.leafMats.Length)];
						}
						<>2__current = null;
						<>1__state = 1;
						return true;
					}
					break;
				case 1:
					<>1__state = -1;
					foreach (GameObject leafObject in core.leafObjects)
					{
						MeshRenderer component = leafObject.GetComponent<MeshRenderer>();
						if ((Object)(object)core.originalLeafMaterial == (Object)null)
						{
							core.originalLeafMaterial = ((Renderer)component).material;
						}
						if (materialName == "roots")
						{
							if (core.currentScene == "Pit")
							{
								return false;
							}
							if ((Object)(object)core.originalRootMaterial == (Object)null)
							{
								core.originalRootMaterial = ((Renderer)core.rootObjects.First().GetComponent<MeshRenderer>()).material;
							}
							((Renderer)component).material = core.originalRootMaterial;
							core.UpdateLeafColour(core.selectedLeafColour);
						}
						else if (materialName == "vanilla")
						{
							core.ResetLeafMaterial();
							core.UpdateLeafColour(core.selectedLeafColour);
						}
						else
						{
							((Renderer)component).material = stringToStone(materialName);
							core.UpdateVFXs(((Renderer)component).material.color);
						}
					}
					break;
				}
				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();
			}
		}

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

			private object <>2__current;

			public Core <>4__this;

			public string materialName;

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

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

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

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

			private bool MoveNext()
			{
				//IL_013a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0114: Unknown result type (might be due to invalid IL or missing references)
				int num = <>1__state;
				Core core = <>4__this;
				switch (num)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					if (core.currentScene == "Loader")
					{
						return false;
					}
					if (!core.enabled)
					{
						return false;
					}
					if (core.rootObjects.Count != 0)
					{
						if (materialName == "random")
						{
							materialName = Validation.rootMats[core.rand.Next(Validation.rootMats.Length)];
						}
						<>2__current = null;
						<>1__state = 1;
						return true;
					}
					break;
				case 1:
					<>1__state = -1;
					foreach (GameObject rootObject in core.rootObjects)
					{
						MeshRenderer component = rootObject.GetComponent<MeshRenderer>();
						if ((Object)(object)core.originalRootMaterial == (Object)null)
						{
							core.originalRootMaterial = ((Renderer)component).material;
						}
						if (materialName == "leaves")
						{
							if ((Object)(object)core.originalLeafMaterial == (Object)null)
							{
								core.originalLeafMaterial = ((Renderer)core.leafObjects.First().GetComponent<MeshRenderer>()).material;
							}
							((Renderer)component).material = core.originalLeafMaterial;
							core.UpdateRootColour(core.selectedRootColour);
						}
						else if (materialName == "vanilla")
						{
							core.ResetRootMaterial();
							core.UpdateRootColour(core.selectedRootColour);
						}
						else
						{
							((Renderer)component).material = stringToStone(materialName);
						}
					}
					break;
				}
				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 int sceneID = -1;

		private bool enabled = true;

		private bool wasLightmapChanged;

		private AssetBundle assetBundle;

		private Mod RumbleTrees = new Mod();

		private Random rand = new Random();

		private int LCT1;

		private int LCB1;

		private int FLG;

		private int RC1;

		private int RC2;

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

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

		private GameObject VFXsObject;

		private Color[] originalLeafColours = (Color[])(object)new Color[2];

		private Color[] originalRootColours = (Color[])(object)new Color[2];

		private Material originalLeafMaterial;

		private Material originalRootMaterial;

		private Il2CppStructArray<GradientColorKey> originalVFXColours;

		private string selectedLeafMaterial = "vanilla";

		private string selectedRootMaterial = "vanilla";

		private Color selectedLeafColour;

		private string strSelectedLeafColour = "Cherry";

		private Color selectedRootColour = Color.white;

		private string strSelectedRootColour = "FFFFFF";

		private bool vanillaLightmaps;

		private object rainbowLeafCoroutine;

		private object rainbowRootCoroutine;

		private string[] GymTrees = new string[9] { "--------------SCENE--------------/Gym_Production/Main static group/Foliage/", "--------------SCENE--------------/Gym_Production/Main static group/Gymarena/Leave_sphere__23_", "--------------SCENE--------------/Gym_Production/Main static group/Gymarena/Leave_sphere__24_", "--------------SCENE--------------/Gym_Production/Sub static group/Scene_roots/Test_root_1_middetail", "--------------SCENE--------------/Gym_Production/Sub static group(buildings)/Rumble_station/Root", "--------------SCENE--------------/Gym_Production/Sub static group(buildings)/School/Cylinder_011", "--------------SCENE--------------/Gym_Production/Sub static group(buildings)/School/Cylinder_003", "--------------SCENE--------------/Gym_Production/Main static group/Gymarena/Cylinder_015__4_", "--------------SCENE--------------/Lighting and effects/Visual Effects/Falling Leaf VFXs" };

		private string[] RingTrees = new string[2] { "Map0_production/Main static group/leave", "Map0_production/Main static group/Root" };

		private string[] PitTrees = new string[2] { "Map1_production/Main static group/Leaves_Map2", "Lighting & Effects/Visual Effects/Falling Leaf VFXs" };

		private string[] ParkTrees = new string[3] { "________________SCENE_________________/Park/Main static group/Leaves/", "________________SCENE_________________/Park/Main static group/Root/", "Lighting and effects/Visual Effects/Falling Leaf VFXs" };

		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 dynamic LoadAsset<T>(string assetName, AssetBundle assetBundle)
		{
			if ((Object)(object)assetBundle == (Object)null)
			{
				MelonLogger.Error("AssetBundle cannot be null!");
				return null;
			}
			if (assetName == null || assetName == "")
			{
				MelonLogger.Error("No asset name provided!");
				return null;
			}
			if (typeof(T) == typeof(Texture2D))
			{
				Texture2D val;
				switch (assetName)
				{
				case "Gym_Lightmap":
					val = assetBundle.LoadAsset<Texture2D>("GYM0_final");
					break;
				case "Ring_Lightmap":
					val = assetBundle.LoadAsset<Texture2D>("MAP0_final");
					break;
				case "Park_Lightmap":
					val = assetBundle.LoadAsset<Texture2D>("park0_final");
					break;
				default:
					MelonLogger.Error("No texture found with the name: " + assetName);
					return null;
				}
				if ((Object)(object)val == (Object)null)
				{
					MelonLogger.Error("Failed to load texture from AssetBundle!");
				}
				else
				{
					val.Apply(true, false);
				}
				return val;
			}
			MelonLogger.Error("No valid type provided!");
			return null;
		}

		public static Material stringToStone(string stoneName)
		{
			if (!Validation.stones.Contains(stoneName))
			{
				MelonLogger.Error("\"" + stoneName + "\" is not the name of a valid shiftstone!");
				throw new Exception("Provided stone name is invalid");
			}
			string accurateStoneName = "";
			if (stoneName.EndsWith("Stone"))
			{
				accurateStoneName = stoneName;
			}
			else
			{
				switch (stoneName)
				{
				case "flow":
					accurateStoneName = "FlowStone";
					break;
				case "volatile":
					accurateStoneName = "VolatileStone";
					break;
				case "adamant":
					accurateStoneName = "AdamantStone";
					break;
				case "charge":
					accurateStoneName = "ChargeStone";
					break;
				case "stubborn":
					accurateStoneName = "StubbornStone";
					break;
				case "guard":
					accurateStoneName = "GuardStone";
					break;
				case "vigor":
					accurateStoneName = "VigorStone";
					break;
				case "surge":
					accurateStoneName = "SurgeStone";
					break;
				}
			}
			List<GameObject> list = new List<GameObject>();
			for (int j = 0; j < ((Il2CppArrayBase<ShiftStone>)(object)ScriptableObjectSingleton<ShiftstoneLookupTable>.instance.availableShiftstones).Count; j++)
			{
				list.Add(((Component)((Il2CppArrayBase<ShiftStone>)(object)ScriptableObjectSingleton<ShiftstoneLookupTable>.instance.availableShiftstones)[j]).gameObject);
			}
			return ((Renderer)((Component)list.Where((GameObject i) => ((Object)i).name == accurateStoneName).First().transform.GetChild(0)).GetComponent<MeshRenderer>()).material;
		}

		public override void OnInitializeMelon()
		{
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Expected O, but got Unknown
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Expected O, but got Unknown
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Expected O, but got Unknown
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Expected O, but got Unknown
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Expected O, but got Unknown
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Expected O, but got Unknown
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Expected O, but got Unknown
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Expected O, but got Unknown
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Expected O, but got Unknown
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: Expected O, but got Unknown
			//IL_0179: Unknown result type (might be due to invalid IL or missing references)
			//IL_0183: Expected O, but got Unknown
			RumbleTrees.ModName = "RumbleTrees";
			RumbleTrees.ModVersion = "2.2.0";
			RumbleTrees.SetFolder("RumbleTrees");
			RumbleTrees.AddDescription("Description", "", "Make them pretty!\n\nCurrent presets:\nCherry\nOrange\nYellow\nRed\nRainbow\nVanilla (literally does nothing)\nRandom", new Tags
			{
				IsSummary = true
			});
			RumbleTrees.AddToList("Enabled in Gym", true, 0, "Enables the mod in the gym", new Tags());
			RumbleTrees.AddToList("Enabled on Ring", true, 0, "Enables the mod on the ring map", new Tags());
			RumbleTrees.AddToList("Enabled on Pit", true, 0, "Enables the mod on the pit map", new Tags());
			RumbleTrees.AddToList("Enabled in Parks", true, 0, "Enables the mod in parks", new Tags());
			RumbleTrees.AddToList("Legacy shaders", false, 0, "Enables the vanilla lightmaps in Ring, the Gym, and Parks, which look different and may not 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,\" \"Random,\" or a custom colour in one of the supported formats: \n255 255 255\nFFFFFF", new Tags());
			RumbleTrees.AddToList("Leaf material", "vanilla", "Type in either \"vanilla,\" \"Random,\" a shiftstone, or \"roots\" to set the material of the leaves", new Tags());
			RumbleTrees.AddToList("Root material", "vanilla", "Type in either \"vanilla,\" \"Random,\" a shiftstone, or \"leaves\" to set the material of the roots", 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.AddValidation("Leaf material", (ValidationParameters)(object)new Validation("leafMat"));
			RumbleTrees.AddValidation("Root material", (ValidationParameters)(object)new Validation("rootMat"));
			RumbleTrees.GetFromFile();
			vanillaLightmaps = (bool)RumbleTrees.Settings[5].Value;
			strSelectedLeafColour = ((string)RumbleTrees.Settings[6].Value).ToLower();
			strSelectedRootColour = ((string)RumbleTrees.Settings[7].Value).ToLower();
			selectedLeafMaterial = ((string)RumbleTrees.Settings[8].Value).ToLower();
			selectedRootMaterial = ((string)RumbleTrees.Settings[9].Value).ToLower();
			if (strSelectedLeafColour != "vanilla" && strSelectedLeafColour != "rainbow")
			{
				setSelectedLeafColour(strSelectedLeafColour);
			}
			if (strSelectedRootColour != "vanilla" && strSelectedRootColour != "rainbow")
			{
				setSelectedRootColour(strSelectedRootColour);
			}
			RumbleTrees.ModSaved += OnSave;
			RumbleTrees.Settings[6].SavedValueChanged += OnLeafColourChange;
			RumbleTrees.Settings[7].SavedValueChanged += OnRootColourChange;
			RumbleTrees.Settings[8].SavedValueChanged += OnLeafMaterialChange;
			RumbleTrees.Settings[9].SavedValueChanged += OnRootMaterialChange;
			UI.instance.UI_Initialized += OnUIInit;
			assetBundle = Calls.LoadAssetBundleFromStream((MelonMod)(object)this, "RumbleTrees.Resources.rumbletrees");
			LCT1 = Shader.PropertyToID("Color_133d236fee76457eb89bac53e692f8a3");
			LCB1 = Shader.PropertyToID("Color_6f942b46fda341409751e4e7f292de58");
			FLG = Shader.PropertyToID("Leaf Color Gradient");
			RC1 = Shader.PropertyToID("Color_FA790384");
			RC2 = Shader.PropertyToID("Color_c7120f3b741f4dd48575e89d95f9641d");
			((MelonBase)this).LoggerInstance.Msg("Initialised.");
		}

		private void OnSave()
		{
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			if ((bool)RumbleTrees.Settings[sceneID].SavedValue != enabled)
			{
				enabled = !enabled;
				if (enabled)
				{
					if (strSelectedLeafColour != "vanilla")
					{
						UpdateLeafColour(selectedLeafColour);
					}
					if (strSelectedRootColour != "vanilla")
					{
						UpdateRootColour(selectedRootColour);
					}
					if (selectedLeafMaterial != "vanilla")
					{
						MelonCoroutines.Start(UpdateLeafMaterial(selectedLeafMaterial));
					}
					if (selectedRootMaterial != "vanilla")
					{
						MelonCoroutines.Start(UpdateRootMaterial(selectedRootMaterial));
					}
					if (strSelectedLeafColour == "rainbow")
					{
						rainbowLeafCoroutine = MelonCoroutines.Start(RAINBOWLEAVES());
					}
					if (strSelectedRootColour == "rainbow")
					{
						rainbowRootCoroutine = MelonCoroutines.Start(RAINBOWROOTS());
					}
					InitLightmaps();
				}
				else
				{
					ResetLeafColour();
					ResetRootColour();
					ResetLeafMaterial();
					ResetRootMaterial();
				}
			}
			if ((bool)RumbleTrees.Settings[5].Value == vanillaLightmaps)
			{
				return;
			}
			vanillaLightmaps = !vanillaLightmaps;
			if (leafObjects.Count == 0)
			{
				return;
			}
			foreach (GameObject leafObject in leafObjects)
			{
				MeshRenderer component = leafObject.GetComponent<MeshRenderer>();
				MelonCoroutines.Start(SwapLightmap(component, currentScene, vanillaLightmaps));
			}
		}

		private void OnLeafColourChange(object sender = null, EventArgs e = null)
		{
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			if (e == null)
			{
				return;
			}
			if (strSelectedLeafColour == "vanilla")
			{
				InitLightmaps();
			}
			ValueChange<string> val = (ValueChange<string>)(object)e;
			strSelectedLeafColour = val.Value.ToLower();
			if (rainbowLeafCoroutine != null)
			{
				MelonCoroutines.Stop(rainbowLeafCoroutine);
				rainbowLeafCoroutine = null;
			}
			if (strSelectedLeafColour == "vanilla")
			{
				ResetLeafColour();
			}
			else if (strSelectedLeafColour == "rainbow")
			{
				if (enabled)
				{
					rainbowLeafCoroutine = MelonCoroutines.Start(RAINBOWLEAVES());
				}
			}
			else
			{
				setSelectedLeafColour(strSelectedLeafColour);
				UpdateLeafColour(selectedLeafColour);
			}
		}

		private void OnLeafMaterialChange(object sender = null, EventArgs e = null)
		{
			if (e != null)
			{
				ValueChange<string> val = (ValueChange<string>)(object)e;
				selectedLeafMaterial = val.Value.ToLower();
				if (selectedLeafMaterial == "vanilla")
				{
					ResetLeafMaterial();
				}
				else
				{
					MelonCoroutines.Start(UpdateLeafMaterial(selectedLeafMaterial));
				}
			}
		}

		private void OnRootColourChange(object sender = null, EventArgs e = null)
		{
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			if (e != null)
			{
				ValueChange<string> val = (ValueChange<string>)(object)e;
				strSelectedRootColour = val.Value.ToLower();
				if (rainbowRootCoroutine != null)
				{
					MelonCoroutines.Stop(rainbowRootCoroutine);
					rainbowRootCoroutine = null;
				}
				if (strSelectedRootColour == "vanilla")
				{
					ResetRootColour();
					return;
				}
				if (strSelectedRootColour == "rainbow")
				{
					rainbowRootCoroutine = MelonCoroutines.Start(RAINBOWROOTS());
					return;
				}
				setSelectedRootColour(strSelectedRootColour);
				UpdateRootColour(selectedRootColour);
			}
		}

		private void OnRootMaterialChange(object sender = null, EventArgs e = null)
		{
			if (e != null)
			{
				ValueChange<string> val = (ValueChange<string>)(object)e;
				selectedRootMaterial = val.Value.ToLower();
				if (selectedRootMaterial == "vanilla")
				{
					ResetRootMaterial();
				}
				else
				{
					MelonCoroutines.Start(UpdateRootMaterial(selectedRootMaterial));
				}
			}
		}

		private void setSelectedLeafColour(string colour)
		{
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: 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_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: 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_008c: Unknown result type (might be due to invalid IL or missing references)
			switch (colour.ToLower())
			{
			case "cherry":
				selectedLeafColour = cherryColour;
				break;
			case "orange":
				selectedLeafColour = orangeColour;
				break;
			case "yellow":
				selectedLeafColour = yellowColour;
				break;
			case "red":
				selectedLeafColour = redColour;
				break;
			case "random":
				break;
			default:
				selectedLeafColour = stringToColour(colour.ToLower());
				break;
			}
		}

		private void setSelectedRootColour(string colour)
		{
			//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)
			if (colour != "random")
			{
				selectedRootColour = stringToColour(colour);
			}
		}

		public Color stringToColour(string colour)
		{
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			if (colour.Contains(" "))
			{
				string[] array = colour.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))
				{
					return new Color((float)(int)result / 255f, (float)(int)result2 / 255f, (float)(int)result3 / 255f);
				}
				MelonLogger.Error("Somehow not a valid colour");
				throw new Exception("Provided string is not in a valid format.");
			}
			if (colour.Length == 6 && int.TryParse(colour, NumberStyles.HexNumber, null, out var result4))
			{
				float num = (float)((result4 >> 16) & 0xFF) / 255f;
				float num2 = (float)((result4 >> 8) & 0xFF) / 255f;
				float num3 = (float)(result4 & 0xFF) / 255f;
				return new Color(num, num2, num3);
			}
			MelonLogger.Error("Somehow not a valid colour");
			throw new Exception("Provided string is not in a valid format.");
		}

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

		public override void OnSceneWasLoaded(int buildIndex, string sceneName)
		{
			//IL_03a4: 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)
			leafObjects = new List<GameObject>();
			rootObjects = new List<GameObject>();
			VFXsObject = null;
			wasLightmapChanged = false;
			originalLeafColours = (Color[])(object)new Color[2];
			originalRootColours = (Color[])(object)new Color[2];
			originalLeafMaterial = null;
			originalRootMaterial = null;
			originalVFXColours = null;
			if (rainbowLeafCoroutine != null)
			{
				MelonCoroutines.Stop(rainbowLeafCoroutine);
				rainbowLeafCoroutine = null;
			}
			if (rainbowRootCoroutine != null)
			{
				MelonCoroutines.Stop(rainbowRootCoroutine);
				rainbowRootCoroutine = null;
			}
			if (sceneName == "Gym")
			{
				sceneID = 1;
				currentScene = sceneName;
				GameObject val = GameObject.Find(GymTrees[0]);
				for (int i = 0; i < val.transform.childCount; i++)
				{
					GameObject gameObject = ((Component)val.transform.GetChild(i)).gameObject;
					if (gameObject.active)
					{
						leafObjects.Add(gameObject);
					}
				}
				leafObjects.Add(GameObject.Find(GymTrees[1]));
				leafObjects.Add(GameObject.Find(GymTrees[2]));
				VFXsObject = GameObject.Find(GymTrees[8]);
				GameObject val2 = GameObject.Find(GymTrees[3]);
				for (int j = 0; j < val2.transform.childCount; j++)
				{
					GameObject gameObject2 = ((Component)val2.transform.GetChild(j)).gameObject;
					if (((Object)gameObject2).name != "GymCompRoot")
					{
						rootObjects.Add(gameObject2);
					}
				}
				for (int k = 4; k < 8; k++)
				{
					GameObject item = GameObject.Find(GymTrees[k]);
					rootObjects.Add(item);
				}
			}
			if (sceneName == "Map0")
			{
				sceneID = 2;
				currentScene = "Ring";
				GameObject item2 = GameObject.Find(RingTrees[0]);
				leafObjects.Add(item2);
				GameObject item3 = GameObject.Find(RingTrees[1]);
				rootObjects.Add(item3);
			}
			if (sceneName == "Map1")
			{
				sceneID = 3;
				currentScene = "Pit";
				GameObject item4 = GameObject.Find(PitTrees[0]);
				leafObjects.Add(item4);
				VFXsObject = GameObject.Find(PitTrees[1]);
			}
			if (sceneName == "Park")
			{
				sceneID = 4;
				currentScene = "Park";
				GameObject val3 = GameObject.Find(ParkTrees[0]);
				for (int l = 0; l < val3.transform.childCount; l++)
				{
					GameObject gameObject3 = ((Component)val3.transform.GetChild(l)).gameObject;
					leafObjects.Add(gameObject3);
				}
				VFXsObject = GameObject.Find(ParkTrees[2]);
				GameObject val4 = GameObject.Find(ParkTrees[1]);
				for (int m = 0; m < val4.transform.childCount; m++)
				{
					GameObject gameObject4 = ((Component)val4.transform.GetChild(m)).gameObject;
					rootObjects.Add(gameObject4);
				}
			}
			if (sceneName == "Loader")
			{
				return;
			}
			enabled = (bool)RumbleTrees.Settings[sceneID].Value;
			selectedLeafMaterial = ((string)RumbleTrees.Settings[8].SavedValue).ToLower();
			if (enabled)
			{
				if (strSelectedLeafColour != "vanilla")
				{
					UpdateLeafColour(selectedLeafColour);
				}
				if (strSelectedRootColour != "vanilla")
				{
					UpdateRootColour(selectedRootColour);
				}
				if (selectedLeafMaterial != "vanilla")
				{
					MelonCoroutines.Start(UpdateLeafMaterial(selectedLeafMaterial));
				}
				if (selectedRootMaterial != "vanilla")
				{
					MelonCoroutines.Start(UpdateRootMaterial(selectedRootMaterial));
				}
				if (strSelectedLeafColour != "vanilla")
				{
					InitLightmaps();
				}
			}
			if (strSelectedLeafColour == "rainbow" && rainbowLeafCoroutine == null)
			{
				rainbowLeafCoroutine = MelonCoroutines.Start(RAINBOWLEAVES());
			}
			if (strSelectedRootColour == "rainbow" && rainbowRootCoroutine == null)
			{
				rainbowRootCoroutine = MelonCoroutines.Start(RAINBOWROOTS());
			}
		}

		private void InitLightmaps()
		{
			if (!(currentScene != "Loader") || !(currentScene != "Pit") || leafObjects.Count == 0)
			{
				return;
			}
			foreach (GameObject leafObject in leafObjects)
			{
				MeshRenderer component = leafObject.GetComponent<MeshRenderer>();
				if (!vanillaLightmaps)
				{
					MelonCoroutines.Start(SwapLightmap(component, currentScene));
				}
			}
		}

		private void UpdateLeafColour(Color colour)
		{
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: 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_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: 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_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: Unknown result type (might be due to invalid IL or missing references)
			//IL_0195: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: Unknown result type (might be due to invalid IL or missing references)
			if (!enabled)
			{
				return;
			}
			if (strSelectedLeafColour == "random")
			{
				((Color)(ref colour))..ctor((float)rand.NextDouble(), (float)rand.NextDouble(), (float)rand.NextDouble());
			}
			if (leafObjects.Count == 0)
			{
				return;
			}
			Color[] array = (Color[])(object)new Color[2];
			float num = default(float);
			float value = default(float);
			float value2 = default(float);
			Color.RGBToHSV(colour, ref num, ref value, ref value2);
			value = Math.Clamp(value, 0.1f, 0.9f);
			value2 = Math.Clamp(value2, 0.1f, 0.9f);
			array[0] = Color.HSVToRGB(num, value, value2 - 0.2f);
			array[1] = Color.HSVToRGB(num, value, value2 + 0.1f);
			foreach (GameObject leafObject in leafObjects)
			{
				Material material = ((Renderer)leafObject.GetComponent<MeshRenderer>()).material;
				if (originalLeafColours[0] == default(Color))
				{
					originalLeafColours[0] = material.GetColor(LCT1);
					originalLeafColours[1] = material.GetColor(LCB1);
				}
				if (selectedLeafMaterial == "roots" && currentScene != "Pit")
				{
					material.SetColor(RC1, array[1]);
					material.SetColor(RC2, array[0]);
				}
				else
				{
					material.SetColor(LCT1, array[1]);
					material.SetColor(LCB1, array[0]);
				}
			}
			if (selectedLeafMaterial == "vanilla" || selectedLeafMaterial == "roots")
			{
				UpdateVFXs(colour);
			}
		}

		private void UpdateVFXs(Color colour)
		{
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: 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)
			if (!enabled)
			{
				return;
			}
			if ((Object)(object)VFXsObject != (Object)null)
			{
				for (int i = 0; i < VFXsObject.transform.GetChildCount(); i++)
				{
					VisualEffect component = ((Component)VFXsObject.transform.GetChild(i)).gameObject.GetComponent<VisualEffect>();
					GradientColorKey[] array = (GradientColorKey[])(object)new GradientColorKey[2];
					Gradient gradient = component.GetGradient(FLG);
					if (originalVFXColours == null)
					{
						originalVFXColours = gradient.colorKeys;
					}
					array[0].color = colour;
					array[1].color = colour;
					gradient.colorKeys = Il2CppStructArray<GradientColorKey>.op_Implicit(array);
					component.SetGradient(FLG, gradient);
				}
			}
			else if (currentScene != "Ring")
			{
				MelonLogger.Warning("Leaf VFX object not found!");
			}
		}

		private void UpdateRootColour(Color colour)
		{
			//IL_007a: 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)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b4: 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_018a: Unknown result type (might be due to invalid IL or missing references)
			if (currentScene == "Loader" || currentScene == "Pit" || !enabled)
			{
				return;
			}
			if (strSelectedRootColour == "random")
			{
				((Color)(ref colour))..ctor((float)rand.NextDouble(), (float)rand.NextDouble(), (float)rand.NextDouble());
			}
			if (rootObjects.Count == 0)
			{
				return;
			}
			float num = default(float);
			float value = default(float);
			float value2 = default(float);
			Color.RGBToHSV(colour, ref num, ref value, ref value2);
			Color[] array = (Color[])(object)new Color[3];
			value = Math.Clamp(value, 0.1f, 0.9f);
			value2 = Math.Clamp(value2, 0.1f, 0.9f);
			array[0] = Color.HSVToRGB(num, value - 0.1f, value2 - 0.3f);
			array[1] = Color.HSVToRGB(num, value, value2);
			foreach (GameObject rootObject in rootObjects)
			{
				Material material = ((Renderer)rootObject.GetComponent<MeshRenderer>()).material;
				if ((Object)(object)material != (Object)null)
				{
					if (originalRootColours[0] == default(Color))
					{
						originalRootColours[0] = material.GetColor(RC1);
						originalRootColours[1] = material.GetColor(RC2);
					}
					if (selectedRootMaterial == "leaves")
					{
						material.SetColor(LCT1, array[0]);
						material.SetColor(LCB1, array[1]);
					}
					else
					{
						material.SetColor(RC1, array[0]);
						material.SetColor(RC2, array[1]);
					}
				}
			}
		}

		private void ResetLeafColour()
		{
			//IL_0021: 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_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			if (rainbowLeafCoroutine != null)
			{
				MelonCoroutines.Stop(rainbowLeafCoroutine);
				rainbowLeafCoroutine = null;
			}
			if (originalLeafColours[0] != default(Color) && leafObjects.Count != 0)
			{
				foreach (GameObject leafObject in leafObjects)
				{
					MeshRenderer component = leafObject.GetComponent<MeshRenderer>();
					Material material = ((Renderer)component).material;
					if (selectedLeafMaterial == "roots" && (bool)RumbleTrees.Settings[sceneID].Value)
					{
						material.SetColor(RC1, originalLeafColours[0]);
						material.SetColor(RC2, originalLeafColours[1]);
					}
					else
					{
						material.SetColor(LCT1, originalLeafColours[0]);
						material.SetColor(LCB1, originalLeafColours[1]);
					}
					MelonCoroutines.Start(SwapLightmap(component, currentScene, original: true));
				}
			}
			if (selectedLeafMaterial == "vanilla" || selectedLeafMaterial == "roots")
			{
				ResetVFXs();
			}
		}

		private void ResetVFXs()
		{
			if (originalVFXColours != null && (Object)(object)VFXsObject != (Object)null)
			{
				for (int i = 0; i < VFXsObject.transform.GetChildCount(); i++)
				{
					VisualEffect component = ((Component)VFXsObject.transform.GetChild(i)).gameObject.GetComponent<VisualEffect>();
					Gradient gradient = component.GetGradient(FLG);
					gradient.colorKeys = originalVFXColours;
					component.SetGradient(FLG, gradient);
				}
			}
		}

		private void ResetRootColour()
		{
			//IL_0021: 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_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: 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)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			if (rainbowRootCoroutine != null)
			{
				MelonCoroutines.Stop(rainbowRootCoroutine);
				rainbowRootCoroutine = null;
			}
			if (!(originalRootColours[0] != default(Color)) || rootObjects.Count == 0)
			{
				return;
			}
			foreach (GameObject rootObject in rootObjects)
			{
				Material material = ((Renderer)rootObject.GetComponent<MeshRenderer>()).material;
				if (selectedRootMaterial == "leaves" && (bool)RumbleTrees.Settings[sceneID].Value)
				{
					material.SetColor(LCT1, originalRootColours[0]);
					material.SetColor(LCB1, originalRootColours[1]);
				}
				else
				{
					material.SetColor(RC1, originalRootColours[0]);
					material.SetColor(RC2, originalRootColours[1]);
				}
			}
		}

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

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

		private void ResetLeafMaterial()
		{
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			if (currentScene == "Loader" || (Object)(object)originalLeafMaterial == (Object)null || leafObjects.Count == 0)
			{
				return;
			}
			foreach (GameObject leafObject in leafObjects)
			{
				((Renderer)leafObject.GetComponent<MeshRenderer>()).material = originalLeafMaterial;
			}
			if (enabled && strSelectedLeafColour != "vanilla")
			{
				UpdateLeafColour(selectedLeafColour);
			}
			else
			{
				ResetLeafColour();
			}
		}

		private void ResetRootMaterial()
		{
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			if (currentScene == "Loader" || (Object)(object)originalRootMaterial == (Object)null || rootObjects.Count == 0)
			{
				return;
			}
			foreach (GameObject rootObject in rootObjects)
			{
				((Renderer)rootObject.GetComponent<MeshRenderer>()).material = originalRootMaterial;
			}
			if (enabled && strSelectedRootColour != "vanilla")
			{
				UpdateRootColour(selectedRootColour);
			}
			else
			{
				ResetRootColour();
			}
		}

		[IteratorStateMachine(typeof(<SwapLightmap>d__61))]
		private IEnumerator SwapLightmap(MeshRenderer renderer, string sceneName, bool original = false)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <SwapLightmap>d__61(0)
			{
				<>4__this = this,
				renderer = renderer,
				sceneName = sceneName,
				original = original
			};
		}

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

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