Decompiled source of RumbleTrees v2.4.1

Mods/RumbleTrees.dll

Decompiled 2 days 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.Managers;
using Il2CppRUMBLE.Pools;
using Il2CppRUMBLE.Utilities;
using Il2CppSystem.Collections.Generic;
using MelonLoader;
using Microsoft.CodeAnalysis;
using RumbleModUI;
using RumbleModdingAPI.RMAPI;
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.4.1", "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+013c12b587c2417255c17b7dac5743c29b8dde2a")]
[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.4.1";

		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[5] { "cherry", "orange", "yellow", "red", "rainbow" };

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

		public static string[] mats = new string[9] { "flow", "vigor", "volatile", "adamant", "charge", "guard", "stubborn", "surge", "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 (Input.ToLower() == "random")
			{
				return true;
			}
			if (Input.ToLower() == "vanilla")
			{
				return true;
			}
			if (type.EndsWith("Mat"))
			{
				return ((ReadOnlySpan<string>)mats).Contains(Input.ToLower());
			}
			if (Regex.IsMatch(Input, pattern) || Regex.IsMatch(Input, pattern2))
			{
				return true;
			}
			Input = Input.ToLower();
			if (((ReadOnlySpan<string>)themes).Contains(Input) && type == "leaf")
			{
				return true;
			}
			return false;
		}
	}
	public class Core : MelonMod
	{
		[CompilerGenerated]
		private sealed class <RAINBOWLEAVES>d__54 : 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__54(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[9].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 <UpdateFruitMaterial>d__51 : 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 <UpdateFruitMaterial>d__51(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

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

			private bool MoveNext()
			{
				//IL_0073: Unknown result type (might be due to invalid IL or missing references)
				//IL_007d: Expected O, but got Unknown
				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.fruitObjects.Count != 0)
					{
						if ((Object)(object)core.originalFruitMaterial == (Object)null)
						{
							core.originalFruitMaterial = new Material(((Renderer)core.fruitObjects.First().GetComponent<MeshRenderer>()).sharedMaterial);
							((Object)core.originalFruitMaterial).hideFlags = (HideFlags)32;
						}
						<>2__current = null;
						<>1__state = 1;
						return true;
					}
					break;
				case 1:
					<>1__state = -1;
					if (materialName == "random")
					{
						materialName = Validation.mats[core.rand.Next(Validation.mats.Length)];
					}
					foreach (GameObject fruitObject in core.fruitObjects)
					{
						MeshRenderer component = fruitObject.GetComponent<MeshRenderer>();
						if (materialName == "vanilla")
						{
							core.ResetFruitMaterial();
						}
						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();
			}
		}

		[CompilerGenerated]
		private sealed class <UpdateLeafMaterial>d__50 : 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__50(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

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

			private bool MoveNext()
			{
				//IL_015a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0136: 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 ((Object)(object)core.originalLeafMaterial == (Object)null)
						{
							core.originalLeafMaterial = ((Renderer)core.leafObjects.First().GetComponent<MeshRenderer>()).sharedMaterial;
						}
						<>2__current = null;
						<>1__state = 1;
						return true;
					}
					break;
				case 1:
					<>1__state = -1;
					<>2__current = null;
					<>1__state = 2;
					return true;
				case 2:
					<>1__state = -1;
					<>2__current = null;
					<>1__state = 3;
					return true;
				case 3:
					<>1__state = -1;
					if (materialName == "random" && core.enabled)
					{
						materialName = Validation.mats[core.rand.Next(Validation.mats.Length)];
					}
					foreach (GameObject leafObject in core.leafObjects)
					{
						MeshRenderer component = leafObject.GetComponent<MeshRenderer>();
						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();
			}
		}

		private string currentScene = "Loader";

		private int sceneID = -1;

		private bool enabled = true;

		private Mod RumbleTrees = new Mod();

		private Random rand = new Random();

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

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

		private GameObject VFXsObject;

		private Color originalLeafColour;

		private Texture originalFruitTexture;

		private Material originalLeafMaterial;

		private Material originalFruitMaterial;

		private Il2CppStructArray<GradientColorKey> originalVFXColours;

		private string selectedLeafMaterial = "vanilla";

		private string selectedFruitMaterial = "vanilla";

		private Color selectedLeafColour;

		private string strSelectedLeafColour = "Cherry";

		private Color selectedFruitColour = Color.white;

		private string strSelectedFruitColour = "FFFFFF";

		private object rainbowLeafCoroutine;

		private string[] GymTrees = new string[1] { "SCENE/GYMMoss" };

		private string[] RingTrees = new string[1] { "Scene/Map0Leaves" };

		private string[] ParkTrees = new string[2] { "SCENE/PARKMos", "INTERACTABLES/Fruit/Fruit" };

		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);

		public static Material stringToStone(string stoneName)
		{
			if (!((ReadOnlySpan<string>)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_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Expected O, but got Unknown
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Expected O, but got Unknown
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Expected O, but got Unknown
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Expected O, but got Unknown
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: Expected O, but got Unknown
			RumbleTrees.ModName = "RumbleTrees";
			RumbleTrees.ModVersion = "2.4.1";
			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 in Parks", true, 0, "Enables the mod in parks", new Tags());
			RumbleTrees.AddToList("Enable Falling leaf VFXs", false, 0, "Re-enables the old falling leaf VFXs (May slightly impact performance)", 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("Fruit colour", "vanilla", "Type in either \"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,\" or a shiftstone to set the material of the leaves", new Tags());
			RumbleTrees.AddToList("Fruit material", "vanilla", "Type in either \"Vanilla,\" \"Random,\" or a shiftstone to set the material of the fruits", 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("Fruit colour", (ValidationParameters)(object)new Validation("fruit"));
			RumbleTrees.AddValidation("Leaf material", (ValidationParameters)(object)new Validation("leafMat"));
			RumbleTrees.AddValidation("Fruit material", (ValidationParameters)(object)new Validation("fruitMat"));
			RumbleTrees.GetFromFile();
			strSelectedLeafColour = ((string)RumbleTrees.Settings[5].Value).ToLower();
			strSelectedFruitColour = ((string)RumbleTrees.Settings[6].Value).ToLower();
			selectedLeafMaterial = ((string)RumbleTrees.Settings[7].Value).ToLower();
			selectedFruitMaterial = ((string)RumbleTrees.Settings[8].Value).ToLower();
			if (strSelectedLeafColour != "vanilla" && strSelectedLeafColour != "rainbow")
			{
				setSelectedLeafColour(strSelectedLeafColour);
			}
			if (strSelectedFruitColour != "vanilla" && strSelectedFruitColour != "rainbow")
			{
				setSelectedFruitColour(strSelectedFruitColour);
			}
			RumbleTrees.ModSaved += OnSave;
			RumbleTrees.Settings[4].SavedValueChanged += OnToggleVFXs;
			RumbleTrees.Settings[5].SavedValueChanged += OnLeafColourChange;
			RumbleTrees.Settings[6].SavedValueChanged += OnFruitColourChange;
			RumbleTrees.Settings[7].SavedValueChanged += OnLeafMaterialChange;
			RumbleTrees.Settings[8].SavedValueChanged += OnFruitMaterialChange;
			UI.instance.UI_Initialized += OnUIInit;
			((MelonBase)this).LoggerInstance.Msg("Initialised.");
		}

		public override void OnLateInitializeMelon()
		{
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			Enumerator<PooledMonoBehaviour> enumerator = Singleton<PoolManager>.Instance.GetPool("Fruit").PooledObjects.GetEnumerator();
			while (enumerator.MoveNext())
			{
				PooledMonoBehaviour current = enumerator.Current;
				fruitObjects.Add(((Component)current).gameObject);
			}
			if (selectedFruitMaterial.ToLower() != "vanilla")
			{
				MelonCoroutines.Start(UpdateFruitMaterial(selectedFruitMaterial));
			}
			else if (strSelectedFruitColour != "vanilla")
			{
				UpdateFruitColour(selectedFruitColour);
			}
		}

		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)
			{
				return;
			}
			enabled = !enabled;
			if (enabled)
			{
				if (strSelectedLeafColour != "vanilla")
				{
					UpdateLeafColour(selectedLeafColour);
				}
				if (strSelectedFruitColour != "vanilla")
				{
					UpdateFruitColour(selectedFruitColour);
				}
				if (selectedLeafMaterial != "vanilla")
				{
					MelonCoroutines.Start(UpdateLeafMaterial(selectedLeafMaterial));
				}
				if (selectedFruitMaterial != "vanilla")
				{
					MelonCoroutines.Start(UpdateFruitMaterial(selectedFruitMaterial));
				}
				if (strSelectedLeafColour == "rainbow")
				{
					rainbowLeafCoroutine = MelonCoroutines.Start(RAINBOWLEAVES());
				}
			}
			else
			{
				ResetLeafColour();
				ResetFruitColour();
				ResetLeafMaterial();
				ResetFruitMaterial();
			}
		}

		private void OnLeafColourChange(object sender = null, EventArgs e = null)
		{
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			if (e == null)
			{
				return;
			}
			_ = strSelectedLeafColour == "vanilla";
			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 OnToggleVFXs(object sender = null, EventArgs e = null)
		{
			ToggleVFXs(((ValueChange<bool>)(object)e).Value);
		}

		private void ToggleVFXs(bool enable)
		{
			if ((Object)(object)VFXsObject != (Object)null)
			{
				Transform parent = VFXsObject.transform.parent;
				((Component)parent.GetChild(0)).gameObject.active = false;
				((Component)parent.GetChild(1)).gameObject.active = false;
				((Component)parent).gameObject.active = enable;
			}
		}

		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 OnFruitColourChange(object sender = null, EventArgs e = null)
		{
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			if (e != null)
			{
				ValueChange<string> val = (ValueChange<string>)(object)e;
				strSelectedFruitColour = val.Value.ToLower();
				if (strSelectedFruitColour == "vanilla")
				{
					ResetFruitColour();
					return;
				}
				setSelectedFruitColour(strSelectedFruitColour);
				UpdateFruitColour(selectedFruitColour);
			}
		}

		private void OnFruitMaterialChange(object sender = null, EventArgs e = null)
		{
			if (e != null)
			{
				ValueChange<string> val = (ValueChange<string>)(object)e;
				selectedFruitMaterial = val.Value.ToLower();
				if (selectedFruitMaterial == "vanilla")
				{
					ResetFruitMaterial();
				}
				else
				{
					MelonCoroutines.Start(UpdateFruitMaterial(selectedFruitMaterial));
				}
			}
		}

		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 setSelectedFruitColour(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")
			{
				selectedFruitColour = stringToColour(colour);
			}
		}

		public Color stringToColour(string colour)
		{
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			colour = colour.Replace("#", "");
			colour = colour.Replace("0x", "");
			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("\"" + colour + "\" is 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 OnSceneWasUnloaded(int buildIndex, string sceneName)
		{
			if (sceneName == "Park")
			{
				fruitObjects.RemoveAt(fruitObjects.Count - 1);
			}
		}

		public override void OnSceneWasLoaded(int buildIndex, string sceneName)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_019b: Unknown result type (might be due to invalid IL or missing references)
			leafObjects = new List<GameObject>();
			VFXsObject = null;
			originalLeafColour = default(Color);
			originalLeafMaterial = null;
			originalVFXColours = null;
			if (rainbowLeafCoroutine != null)
			{
				MelonCoroutines.Stop(rainbowLeafCoroutine);
				rainbowLeafCoroutine = null;
			}
			if (sceneName == "Gym")
			{
				sceneID = 1;
				currentScene = sceneName;
				leafObjects.Add(GameObject.Find(GymTrees[0]));
				VFXsObject = FallingLeafVFXs.GetGameObject();
			}
			if (sceneName == "Map0")
			{
				sceneID = 2;
				currentScene = "Ring";
				GameObject item = GameObject.Find(RingTrees[0]);
				leafObjects.Add(item);
			}
			if (sceneName == "Park")
			{
				sceneID = 3;
				currentScene = "Park";
				GameObject item2 = GameObject.Find(ParkTrees[0]);
				leafObjects.Add(item2);
				VFXsObject = FallingLeafVFXs.GetGameObject();
				fruitObjects.Add(GameObject.Find(ParkTrees[1]));
				UpdateFruitColour(selectedFruitColour);
			}
			if (sceneName == "Loader")
			{
				return;
			}
			enabled = (bool)RumbleTrees.Settings[sceneID].Value;
			selectedLeafMaterial = ((string)RumbleTrees.Settings[7].SavedValue).ToLower();
			if (enabled)
			{
				if (strSelectedLeafColour != "vanilla")
				{
					UpdateLeafColour(selectedLeafColour);
				}
				ToggleVFXs((bool)RumbleTrees.Settings[4].Value);
				if (selectedLeafMaterial != "vanilla")
				{
					MelonCoroutines.Start(UpdateLeafMaterial(selectedLeafMaterial));
				}
			}
			if (strSelectedLeafColour == "rainbow" && rainbowLeafCoroutine == null)
			{
				rainbowLeafCoroutine = MelonCoroutines.Start(RAINBOWLEAVES());
			}
		}

		private Texture2D ConvertToTexture2D(Texture texture)
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Expected O, but got Unknown
			RenderTexture temporary = RenderTexture.GetTemporary(texture.width, texture.height, 0, (RenderTextureFormat)0, (RenderTextureReadWrite)2);
			Graphics.Blit(texture, temporary);
			RenderTexture active = RenderTexture.active;
			RenderTexture.active = temporary;
			Texture2D val = new Texture2D(texture.width, texture.height, (TextureFormat)5, false);
			val.ReadPixels(new Rect(0f, 0f, (float)((Texture)temporary).width, (float)((Texture)temporary).height), 0, 0);
			val.Apply();
			RenderTexture.active = active;
			RenderTexture.ReleaseTemporary(temporary);
			((Texture)val).filterMode = texture.filterMode;
			((Texture)val).wrapMode = texture.wrapMode;
			return val;
		}

		private void UpdateLeafColour(Color colour)
		{
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: 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_010b: 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;
			}
			foreach (GameObject leafObject in leafObjects)
			{
				Material material = ((Renderer)leafObject.GetComponent<MeshRenderer>()).material;
				if (originalLeafColour == default(Color))
				{
					originalLeafColour = material.GetColor("_Main_color");
				}
				if (!(selectedLeafMaterial == "roots") || !(currentScene != "Pit"))
				{
					material.SetColor("_Main_color", colour);
				}
			}
			if (selectedLeafMaterial == "vanilla" || selectedLeafMaterial == "roots")
			{
				UpdateVFXs(colour);
			}
		}

		private void UpdateVFXs(Color colour)
		{
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: 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_0075: 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("Leaf Color Gradient");
					if (originalVFXColours == null)
					{
						originalVFXColours = gradient.colorKeys;
					}
					array[0].color = colour;
					array[1].color = colour;
					gradient.colorKeys = Il2CppStructArray<GradientColorKey>.op_Implicit(array);
					component.SetGradient("Leaf Color Gradient", gradient);
				}
			}
			else if (currentScene != "Ring")
			{
				MelonLogger.Warning("Leaf VFX object not found!");
			}
		}

		private void UpdateFruitColour(Color colour)
		{
			//IL_006c: 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_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			if (selectedFruitMaterial.ToLower() != "vanilla")
			{
				return;
			}
			MeshRenderer component = fruitObjects.First().GetComponent<MeshRenderer>();
			if ((Object)(object)originalFruitTexture == (Object)null)
			{
				originalFruitTexture = ((Renderer)component).material.GetTexture("_Albedo");
			}
			Texture2D val = ConvertToTexture2D(originalFruitTexture);
			Color32[] array = Il2CppArrayBase<Color32>.op_Implicit((Il2CppArrayBase<Color32>)(object)val.GetPixels32());
			for (int i = 0; i < array.Length; i++)
			{
				if (array[i].b > 128)
				{
					array[i] = Color32.op_Implicit(colour);
				}
			}
			val.SetPixels32(Il2CppStructArray<Color32>.op_Implicit(array));
			val.Apply();
			foreach (GameObject fruitObject in fruitObjects)
			{
				component = fruitObject.GetComponent<MeshRenderer>();
				if ((Object)(object)component != (Object)null)
				{
					((Renderer)component).material.SetTexture("_Albedo", (Texture)(object)val);
				}
			}
		}

		private void ResetLeafColour()
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: 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_009b: Unknown result type (might be due to invalid IL or missing references)
			if (rainbowLeafCoroutine != null)
			{
				MelonCoroutines.Stop(rainbowLeafCoroutine);
				rainbowLeafCoroutine = null;
			}
			if (originalLeafColour != default(Color) && leafObjects.Count != 0)
			{
				foreach (GameObject leafObject in leafObjects)
				{
					Material material = ((Renderer)leafObject.GetComponent<MeshRenderer>()).material;
					if (!(selectedLeafMaterial == "roots") || !(bool)RumbleTrees.Settings[sceneID].Value)
					{
						material.SetColor("_Main_color", originalLeafColour);
					}
				}
			}
			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("Leaf Color Gradient");
					gradient.colorKeys = originalVFXColours;
					component.SetGradient("Leaf Color Gradient", gradient);
				}
			}
		}

		private void ResetFruitColour()
		{
			if ((Object)(object)originalFruitTexture == (Object)null)
			{
				return;
			}
			foreach (GameObject fruitObject in fruitObjects)
			{
				MeshRenderer component = fruitObject.GetComponent<MeshRenderer>();
				if ((Object)(object)component != (Object)null)
				{
					((Renderer)component).material.SetTexture("_Albedo", originalFruitTexture);
				}
			}
		}

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

		[IteratorStateMachine(typeof(<UpdateFruitMaterial>d__51))]
		private IEnumerator UpdateFruitMaterial(string materialName)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <UpdateFruitMaterial>d__51(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 ResetFruitMaterial()
		{
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			if (currentScene == "Loader")
			{
				return;
			}
			if ((Object)(object)originalFruitMaterial == (Object)null)
			{
				MelonLogger.Msg("originalfruitmat is null");
			}
			else
			{
				if (fruitObjects.Count == 0)
				{
					return;
				}
				foreach (GameObject fruitObject in fruitObjects)
				{
					((Renderer)fruitObject.GetComponent<MeshRenderer>()).material = originalFruitMaterial;
				}
				if (enabled && strSelectedFruitColour != "vanilla")
				{
					UpdateFruitColour(selectedFruitColour);
				}
				else
				{
					ResetFruitColour();
				}
			}
		}

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