Decompiled source of RareMagicPortal v2.7.2

plugins/RareMagicPortal.dll

Decompiled 6 months ago
using System;
using System.Collections;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Linq.Expressions;
using System.Numerics.Hashing;
using System.Reflection;
using System.Reflection.Emit;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Serialization;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using FxResources.System.ValueTuple;
using HarmonyLib;
using ItemManager;
using JetBrains.Annotations;
using LocalizationManager;
using Microsoft.CodeAnalysis;
using ServerSync;
using StatusEffectManager;
using TMPro;
using UnityEngine;
using YamlDotNet.Core;
using YamlDotNet.Core.Events;
using YamlDotNet.Core.Tokens;
using YamlDotNet.Helpers;
using YamlDotNet.Serialization;
using YamlDotNet.Serialization.Converters;
using YamlDotNet.Serialization.EventEmitters;
using YamlDotNet.Serialization.NamingConventions;
using YamlDotNet.Serialization.NodeDeserializers;
using YamlDotNet.Serialization.NodeTypeResolvers;
using YamlDotNet.Serialization.ObjectFactories;
using YamlDotNet.Serialization.ObjectGraphTraversalStrategies;
using YamlDotNet.Serialization.ObjectGraphVisitors;
using YamlDotNet.Serialization.Schemas;
using YamlDotNet.Serialization.TypeInspectors;
using YamlDotNet.Serialization.TypeResolvers;
using YamlDotNet.Serialization.Utilities;
using YamlDotNet.Serialization.ValueDeserializers;

[assembly: AssemblyFileVersion("2.7.2")]
[assembly: Guid("e3243d22-4307-4008-ba36-9f326008cde5")]
[assembly: ComVisible(false)]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyProduct("MagicPortalFluid")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyTitle("MagicPortalFluid")]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: CompilationRelaxations(8)]
[assembly: TargetFramework(".NETFramework,Version=v4.6.2", FrameworkDisplayName = ".NET Framework 4.6.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("2.7.2.0")]
[module: UnverifiableCode]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[<c157bb49-d1f3-4c92-9a86-26f3861068d4>Embedded]
	internal sealed class <c157bb49-d1f3-4c92-9a86-26f3861068d4>EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[<c157bb49-d1f3-4c92-9a86-26f3861068d4>Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	[CompilerGenerated]
	internal sealed class <f04ec549-5ca7-4107-a39d-53aadf15d38b>NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public <f04ec549-5ca7-4107-a39d-53aadf15d38b>NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public <f04ec549-5ca7-4107-a39d-53aadf15d38b>NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[<c157bb49-d1f3-4c92-9a86-26f3861068d4>Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class <e143a9e8-dc1e-4f36-83b6-d4ffdfe8fbda>NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public <e143a9e8-dc1e-4f36-83b6-d4ffdfe8fbda>NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
}
[<f04ec549-5ca7-4107-a39d-53aadf15d38b>Nullable(0)]
[<e143a9e8-dc1e-4f36-83b6-d4ffdfe8fbda>NullableContext(1)]
internal class RecipeData
{
	public string name;

	public string craftingStation;

	public int minStationLevel;

	public int amount;

	public bool disabled;

	public List<string> reqs = new List<string>();
}
namespace RareMagicPortal
{
	[<e143a9e8-dc1e-4f36-83b6-d4ffdfe8fbda>NullableContext(1)]
	[<f04ec549-5ca7-4107-a39d-53aadf15d38b>Nullable(0)]
	internal class functions
	{
		public static void GetAllMaterials()
		{
			Material[] array = Resources.FindObjectsOfTypeAll<Material>();
			MagicPortalFluid.originalMaterials = new Dictionary<string, Material>();
			Material[] array2 = array;
			foreach (Material val in array2)
			{
				MagicPortalFluid.originalMaterials[((Object)val).name] = val;
			}
		}

		internal static void ServerZDOymlUpdate(int Colorint, string Portalname)
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Expected O, but got Unknown
			if (!ZNet.instance.IsServer())
			{
				if (MagicPortalFluid.JustSent > 0)
				{
					MagicPortalFluid.JustSent++;
					return;
				}
				ZPackage val = new ZPackage();
				val.Write(Portalname + "," + Colorint);
				MagicPortalFluid.RareMagicPortal.LogInfo((object)$"Sending the Server a update for {Portalname} with Color {Colorint}");
				MagicPortalFluid.JustSent = 1;
				ZRoutedRpc.instance.InvokeRoutedRPC(ZRoutedRpc.instance.GetServerPeerID(), "RequestServerAnnouncementRMP", new object[1] { val });
			}
		}

		public static void RPC_RequestServerAnnouncementRMP(long sender, ZPackage pkg)
		{
			if (ZNet.instance.IsServer() && pkg != null && pkg.Size() > 0)
			{
				ZNetPeer peer = ZNet.instance.GetPeer(sender);
				if (peer != null)
				{
					string playerName = peer.m_playerName;
					string[] array = pkg.ReadString().Split(new char[1] { ',' });
					string text = array[0];
					int num = Convert.ToInt32(array[1]);
					MagicPortalFluid.RareMagicPortal.LogInfo((object)$"Server has recieved a YML update from {playerName} for {text} with Color {num}");
					PortalColorLogic.updateYmltoColorChange(text, num);
				}
			}
		}

		internal static string GetColorHtmlString(Color color)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			if (color.a != 1f)
			{
				return ColorUtility.ToHtmlStringRGBA(color);
			}
			return ColorUtility.ToHtmlStringRGB(color);
		}

		internal static string HandlePortalClick()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: 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_0054: Unknown result type (might be due to invalid IL or missing references)
			Minimap instance = Minimap.instance;
			List<PinData> pins = instance.m_pins;
			Vector3 val = instance.ScreenToWorldPoint(Input.mousePosition);
			float num = instance.m_removeRadius * (instance.m_largeZoom * 2f);
			MagicPortalFluid.checkiftagisPortal = "";
			PinData val2 = null;
			float num2 = 999999f;
			foreach (PinData item in pins)
			{
				float num3 = Utils.DistanceXZ(val, item.m_pos);
				if (num3 < num && (num3 < num2 || val2 == null))
				{
					val2 = item;
					num2 = num3;
				}
			}
			if (!string.IsNullOrEmpty(val2.m_name))
			{
				MagicPortalFluid.checkiftagisPortal = val2.m_name;
			}
			if (!(((Object)val2.m_icon).name == "") && !(((Object)val2.m_icon).name == "TargetPortalIcon"))
			{
				MagicPortalFluid.checkiftagisPortal = null;
			}
			if (MagicPortalFluid.checkiftagisPortal.Contains("$hud") || MagicPortalFluid.checkiftagisPortal.Contains("Day "))
			{
				MagicPortalFluid.checkiftagisPortal = null;
			}
			return MagicPortalFluid.checkiftagisPortal;
		}
	}
	[<f04ec549-5ca7-4107-a39d-53aadf15d38b>Nullable(0)]
	[<e143a9e8-dc1e-4f36-83b6-d4ffdfe8fbda>NullableContext(1)]
	internal class PortalColorLogic
	{
		[<e143a9e8-dc1e-4f36-83b6-d4ffdfe8fbda>NullableContext(0)]
		internal enum PortalColor
		{
			Yellow = 1,
			Red = 2,
			Green = 3,
			Blue = 4,
			Purple = 5,
			Tan = 6,
			Cyan = 7,
			Orange = 8,
			White = 20,
			Black = 21,
			Gold = 22
		}

		[<e143a9e8-dc1e-4f36-83b6-d4ffdfe8fbda>NullableContext(0)]
		[HarmonyPatch(typeof(ZNet), "Shutdown")]
		internal class PatchZNetDisconnect
		{
			internal static bool Prefix()
			{
				MagicPortalFluid.RareMagicPortal.LogInfo((object)"Logoff? Save text file, don't delete");
				((MonoBehaviour)MagicPortalFluid.context).StopCoroutine(MagicPortalFluid.RemovedDestroyedTeleportWorldsCoroutine());
				MagicPortalFluid.NoMoreLoading = true;
				MagicPortalFluid.JustWaitforInventory = true;
				if (ZNet.instance.IsServer() && ZNet.instance.IsDedicated() && MagicPortalFluid.RiskyYMLSave.Value)
				{
					<803dcee1-f5f3-4b7a-8321-94fbb55ef8d6>ISerializer <803dcee1-f5f3-4b7a-8321-94fbb55ef8d6>ISerializer = new <e7bba29c-a42b-46ec-ac53-439b82edf48e>SerializerBuilder().Build();
					string contents = MagicPortalFluid.WelcomeString + Environment.NewLine + <803dcee1-f5f3-4b7a-8321-94fbb55ef8d6>ISerializer.Serialize(PortalN);
					MagicPortalFluid.JustWrote = 1;
					File.WriteAllText(MagicPortalFluid.YMLCurrentFile, contents);
					string text = "";
					foreach (string item in File.ReadLines(MagicPortalFluid.YMLCurrentFile))
					{
						text = text + item + Environment.NewLine;
						if (item.Contains("Admin_only_Access"))
						{
							text += Environment.NewLine;
						}
					}
					File.WriteAllText(MagicPortalFluid.YMLCurrentFile, text);
					MagicPortalFluid.JustWrote = 2;
				}
				return true;
			}
		}

		[<f04ec549-5ca7-4107-a39d-53aadf15d38b>Nullable(0)]
		[HarmonyPatch(typeof(TeleportWorld))]
		private class TeleportWorldPatchRMP
		{
			[HarmonyPatch("Awake")]
			[HarmonyPostfix]
			private static void TeleportWorldAwakepRfixRMP(ref TeleportWorld __instance)
			{
				if (!Object.op_Implicit((Object)(object)__instance))
				{
					return;
				}
				if (!Object.op_Implicit((Object)(object)__instance.m_proximityRoot))
				{
					__instance.m_proximityRoot = ((Component)__instance).transform;
				}
				if (!Object.op_Implicit((Object)(object)__instance.m_target_found))
				{
					GameObject gameObject = ((Component)((Component)__instance).gameObject.transform.Find("_target_found")).gameObject;
					gameObject.SetActive(false);
					__instance.m_target_found = gameObject.AddComponent<EffectFade>();
					gameObject.SetActive(true);
				}
				MagicPortalFluid._teleportWorldDataCache.Add(__instance, new TeleportWorldDataRMP(__instance));
				try
				{
					if (__instance.m_nview.m_zdo.GetString(MagicPortalFluid._portalBiomeColorHashCode, "") == "skip")
					{
						RMP.LogDebug((object)"Portal BiomeColor skip Awake");
						MagicPortalFluid._teleportWorldDataCache.TryGetValue(__instance, out var value);
						value.BiomeColor = "skip";
					}
				}
				catch
				{
				}
			}

			[HarmonyPatch("UpdatePortal")]
			[HarmonyPriority(200)]
			[HarmonyPostfix]
			private static void TeleportWorldUpdatePortalPostfixRMP(ref TeleportWorld __instance)
			{
				//IL_0316: Unknown result type (might be due to invalid IL or missing references)
				//IL_0319: 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_006d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0335: Unknown result type (might be due to invalid IL or missing references)
				//IL_0337: Unknown result type (might be due to invalid IL or missing references)
				//IL_033d: Unknown result type (might be due to invalid IL or missing references)
				//IL_033f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0325: Unknown result type (might be due to invalid IL or missing references)
				//IL_0328: Unknown result type (might be due to invalid IL or missing references)
				//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
				//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
				//IL_00df: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
				//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
				//IL_02f5: Unknown result type (might be due to invalid IL or missing references)
				//IL_02f8: Unknown result type (might be due to invalid IL or missing references)
				//IL_0180: 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_0189: Unknown result type (might be due to invalid IL or missing references)
				//IL_018e: Unknown result type (might be due to invalid IL or missing references)
				//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
				//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
				//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
				//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
				//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
				//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
				//IL_0305: Unknown result type (might be due to invalid IL or missing references)
				//IL_0307: Unknown result type (might be due to invalid IL or missing references)
				if (!Object.op_Implicit((Object)(object)__instance) || !Object.op_Implicit((Object)(object)__instance.m_nview) || __instance.m_nview.m_zdo == null)
				{
					return;
				}
				try
				{
					MagicPortalFluid._teleportWorldDataCache.TryGetValue(__instance, out var value);
					if (((Character)Player.m_localPlayer).m_seman.HaveStatusEffect("yippeTele"))
					{
						if (MagicPortalFluid.PortalDrinkColor.Value == "Rainbow")
						{
							Color yellow = Color.yellow;
							Random random = new Random();
							PortalColor src = (PortalColor)Enum.Parse(typeof(PortalColor), currentRainbow);
							int num = random.Next(1, 12);
							PortalColor src2 = src.Next();
							for (int i = 1; i < num; i++)
							{
								src2.Next();
							}
							currentRainbow = src2.ToString();
							yellow = PortalColors[src2.ToString()].HexName;
							rainbowWait = 0;
							if (yellow != value.OldColor)
							{
								value.TargetColor = yellow;
								SetTeleportWorldColors(value, SetcolorTarget: true);
							}
						}
						else if (MagicPortalFluid.PortalDrinkColor.Value == "Rainbow2")
						{
							if ((Object)(object)CheatSwordColor == (Object)null)
							{
								RMP.LogInfo((object)"Set cheatsword");
								CheatSwordColor = ObjectDB.instance.GetItemPrefab("SwordCheat").GetComponentInChildren<ParticleSystem>(true);
							}
							if ((Object)(object)CheatSwordColor == (Object)null)
							{
								RMP.LogInfo((object)"Cheatsword is null");
							}
							MainModule main = CheatSwordColor.main;
							MinMaxGradient startColor = ((MainModule)(ref main)).startColor;
							RMP.LogInfo((object)"Set holdColor");
							ParticleSystem obj = value.BlueFlames[0];
							((Component)obj).GetComponent<MainModule>();
							ColorOverLifetimeModule component = ((Component)obj).GetComponent<ColorOverLifetimeModule>();
							((ColorOverLifetimeModule)(ref component)).color = startColor;
							((Renderer)((Component)obj).GetComponent<ParticleSystemRenderer>()).material = MagicPortalFluid.originalMaterials["flame"];
						}
						else
						{
							value.TargetColor = PortalColors[MagicPortalFluid.PortalDrinkColor.Value].HexName;
							SetTeleportWorldColors(value);
						}
						return;
					}
					string @string = __instance.m_nview.m_zdo.GetString("tag", "");
					CrystalandKeyLogicColor(out var currentColor, out var currentColorHex, out var _, @string, __instance);
					if (MagicPortalFluid.ConfigUseBiomeColors.Value)
					{
						if (Enumerable.Contains(@string, NameIdentifier) && @string.Count((char f) => f == NameIdentifier) > 1)
						{
							@string = @string[..@string.IndexOf(NameIdentifier)];
							string text = @string + NameIdentifier + PortalColors[currentColor].Pos;
							__instance.SetText(text);
						}
						if (value.BiomeColor != "skip" && value.BiomeColor != "")
						{
							if (currentColorHex != value.OldColor)
							{
								value.TargetColor = currentColorHex;
								SetTeleportWorldColors(value, SetcolorTarget: true);
							}
							return;
						}
					}
					if (currentColorHex != value.LinkColor || currentColorHex != value.OldColor)
					{
						value.TargetColor = currentColorHex;
						value.LinkColor = currentColorHex;
						SetTeleportWorldColors(value, SetcolorTarget: true);
					}
				}
				catch
				{
				}
			}
		}

		[<f04ec549-5ca7-4107-a39d-53aadf15d38b>Nullable(0)]
		[HarmonyPriority(600)]
		[HarmonyPatch(typeof(TeleportWorld), "Interact")]
		public static class PortalCheckOutside
		{
			internal static bool Prefix(TeleportWorld __instance, Humanoid human, bool hold)
			{
				//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
				//IL_0164: Unknown result type (might be due to invalid IL or missing references)
				//IL_0169: Unknown result type (might be due to invalid IL or missing references)
				//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
				//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
				//IL_017c: Unknown result type (might be due to invalid IL or missing references)
				//IL_017e: Unknown result type (might be due to invalid IL or missing references)
				//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
				//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
				if (hold)
				{
					return false;
				}
				if (Chainloader.PluginInfos.ContainsKey("com.sweetgiorni.anyportal"))
				{
					return true;
				}
				if (__instance.m_nview.IsValid())
				{
					Piece val = null;
					val = ((Component)__instance).GetComponent<Piece>();
					string text = __instance.m_nview.m_zdo.GetString("tag", "");
					BiomeStringTempHolder = "";
					if (Enumerable.Contains(text, NameIdentifier))
					{
						BiomeStringTempHolder = text;
						text = text[..text.IndexOf(NameIdentifier)];
						__instance.SetText(text);
					}
					if ((Object)(object)val != (Object)null && text != "" && text != "Empty tag")
					{
						Player localPlayer = Player.m_localPlayer;
						bool flag = false;
						if (val.m_creator == localPlayer.GetPlayerID())
						{
							flag = true;
						}
						KeyboardShortcut value = MagicPortalFluid.portalRMPKEY.Value;
						if (Input.GetKey(((KeyboardShortcut)(ref value)).MainKey))
						{
							value = MagicPortalFluid.portalRMPKEY.Value;
							if (((KeyboardShortcut)(ref value)).Modifiers.All((Func<KeyCode, bool>)Input.GetKey) && (MagicPortalFluid.isAdmin || (flag && !MagicPortalFluid.ConfigEnableCrystalsNKeys.Value)))
							{
								MagicPortalFluid.Globaliscreator = flag;
								int num = CrystalandKeyLogicColor(out var currentColor, out var _, out var nextcolor, text, __instance);
								num = PortalColors[nextcolor].Pos;
								Color item = PortalColors[nextcolor].HexName;
								if (MagicPortalFluid._teleportWorldDataCache.TryGetValue(__instance, out var value2))
								{
									value2.TargetColor = item;
									RMP.LogInfo((object)("setting color " + currentColor));
									value2.BiomeColor = "skip";
									if (Chainloader.PluginInfos.ContainsKey("org.bepinex.plugins.targetportal"))
									{
										BiomeStringTempHolder = "";
									}
									value2.LinkColor = item;
									SetTeleportWorldColors(value2, SetcolorTarget: true);
								}
								__instance.m_nview.m_zdo.Set(MagicPortalFluid._teleportWorldColorHashCode, Utils.ColorToVec3(item));
								ZDO zdo = __instance.m_nview.m_zdo;
								int portalLastColoredByHashCode = MagicPortalFluid._portalLastColoredByHashCode;
								Player localPlayer2 = Player.m_localPlayer;
								zdo.Set(portalLastColoredByHashCode, (localPlayer2 != null) ? localPlayer2.GetPlayerID() : 0);
								__instance.m_nview.m_zdo.Set(MagicPortalFluid._portalBiomeColorHashCode, "skip");
								updateYmltoColorChange(text, num, value2.BiomeColor);
								num = CrystalandKeyLogicColor(out var _, out var _, out var _, text, __instance);
								return false;
							}
						}
						if (flag || (!flag && !MagicPortalFluid.ConfigCreatorLock.Value) || localPlayer.m_noPlacementCost)
						{
							return true;
						}
						((Character)human).Message((MessageType)2, "$rmp_onlyownercanchange", 0, (Sprite)null);
						return false;
					}
					return true;
				}
				return true;
			}

			internal static void Postfix(TeleportWorld __instance, Humanoid human, bool hold)
			{
				if (!hold && __instance.m_nview.IsValid() && BiomeStringTempHolder != "")
				{
					__instance.SetText(BiomeStringTempHolder);
					RMP.LogDebug((object)"BiomeHolder CopiedBack name");
				}
			}
		}

		[HarmonyPatch(typeof(TeleportWorld), "TargetFound")]
		[HarmonyPriority(600)]
		[<f04ec549-5ca7-4107-a39d-53aadf15d38b>Nullable(0)]
		public static class TeleportHaveTargetFix
		{
			private static string HoldMeDaddy = "";

			private static int count3 = 0;

			private static void Prefix(ref TeleportWorld __instance)
			{
				string @string = __instance.m_nview.m_zdo.GetString("tag", "");
				HoldMeDaddy = "";
				if (Enumerable.Contains(@string, NameIdentifier))
				{
					HoldMeDaddy = @string;
					@string = @string[..@string.IndexOf(NameIdentifier)];
					__instance.SetText(@string);
				}
			}

			[HarmonyPriority(200)]
			private static void Postfix(ref TeleportWorld __instance, bool __result)
			{
				if (HoldMeDaddy != "" && MagicPortalFluid.TargetPortalLoaded)
				{
					__instance.SetText(HoldMeDaddy);
				}
			}
		}

		[HarmonyPatch(typeof(TeleportWorld), "GetHoverText")]
		[<e143a9e8-dc1e-4f36-83b6-d4ffdfe8fbda>NullableContext(0)]
		public static class TeleportWorldGetHoverTextPostfixRMP
		{
			[<e143a9e8-dc1e-4f36-83b6-d4ffdfe8fbda>NullableContext(1)]
			private static void Postfix(ref TeleportWorld __instance, ref string __result)
			{
				//IL_0219: Unknown result type (might be due to invalid IL or missing references)
				//IL_021e: Unknown result type (might be due to invalid IL or missing references)
				//IL_036f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0371: Unknown result type (might be due to invalid IL or missing references)
				//IL_0390: Unknown result type (might be due to invalid IL or missing references)
				//IL_0392: Unknown result type (might be due to invalid IL or missing references)
				//IL_080c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0823: Unknown result type (might be due to invalid IL or missing references)
				//IL_0166: Unknown result type (might be due to invalid IL or missing references)
				//IL_0168: Unknown result type (might be due to invalid IL or missing references)
				//IL_05af: Unknown result type (might be due to invalid IL or missing references)
				//IL_05b4: Unknown result type (might be due to invalid IL or missing references)
				//IL_05b8: Unknown result type (might be due to invalid IL or missing references)
				//IL_0696: Unknown result type (might be due to invalid IL or missing references)
				//IL_069b: Unknown result type (might be due to invalid IL or missing references)
				//IL_06cb: Unknown result type (might be due to invalid IL or missing references)
				//IL_06e2: Unknown result type (might be due to invalid IL or missing references)
				//IL_0702: Unknown result type (might be due to invalid IL or missing references)
				//IL_05ed: Unknown result type (might be due to invalid IL or missing references)
				//IL_05f2: Unknown result type (might be due to invalid IL or missing references)
				//IL_0622: Unknown result type (might be due to invalid IL or missing references)
				//IL_063e: Unknown result type (might be due to invalid IL or missing references)
				//IL_065e: Unknown result type (might be due to invalid IL or missing references)
				//IL_07ab: Unknown result type (might be due to invalid IL or missing references)
				//IL_07c2: Unknown result type (might be due to invalid IL or missing references)
				//IL_0750: Unknown result type (might be due to invalid IL or missing references)
				//IL_076c: Unknown result type (might be due to invalid IL or missing references)
				if (!Object.op_Implicit((Object)(object)__instance) || MagicPortalFluid.NoMoreLoading || MagicPortalFluid.WaitSomeMore)
				{
					return;
				}
				Piece component = ((Component)__instance).GetComponent<Piece>();
				Player localPlayer = Player.m_localPlayer;
				bool flag = false;
				if (component.m_creator == localPlayer.GetPlayerID())
				{
					flag = true;
				}
				string text = __instance.m_nview.m_zdo.GetString("tag", "");
				int num = 1;
				string currentColor = "Default";
				num = CrystalandKeyLogicColor(out currentColor, out var currentColorHex, out var nextcolor, text, __instance);
				string text2 = "";
				if (Enumerable.Contains(text, NameIdentifier))
				{
					text2 = text.Substring(text.IndexOf(NameIdentifier));
					int num2 = __result.IndexOf(text2);
					if (num2 >= 0)
					{
						__result = __result.Remove(num2, text2.Length);
					}
					text = text[..text.IndexOf(NameIdentifier)];
				}
				if (currentColor == MagicPortalFluid.FreePassageColor.Value && !MagicPortalFluid.ConfigUseBiomeColors.Value && !PortalN.Portals[text].Free_Passage && MagicPortalFluid.JustSent == 0)
				{
					updateYmltoColorChange(text, PortalColors[MagicPortalFluid.FreePassageColor.Value].Pos);
				}
				if (text == "" && reloaded)
				{
					RMP.LogInfo((object)"Updating Blank Portals");
					updateYmltoColorChange("", num);
					reloaded = false;
				}
				Color val = currentColorHex;
				string text3 = currentColor + " Crystal Portal";
				if (text == "" && currentColor != MagicPortalFluid.CrystalKeyDefaultColor.Value && MagicPortalFluid.JustSent == 0)
				{
					if (MagicPortalFluid.CrystalKeyDefaultColor.Value == "None" || MagicPortalFluid.CrystalKeyDefaultColor.Value == "none")
					{
						num = 1;
					}
					else
					{
						try
						{
							num = PortalColors[MagicPortalFluid.CrystalKeyDefaultColor.Value].Pos;
						}
						catch
						{
							RMP.LogWarning((object)("DefaultPortalColor " + MagicPortalFluid.CrystalKeyDefaultColor.Value + " is not an option,this will cause repeating network traffic on no name portals"));
						}
					}
				}
				Biome currentBiome = localPlayer.GetCurrentBiome();
				string Biome = ((object)(Biome)(ref currentBiome)).ToString();
				if (!Object.op_Implicit((Object)(object)__instance.m_nview) || __instance.m_nview.m_zdo == null || __instance.m_nview.m_zdo.GetString(MagicPortalFluid._portalBiomeHashCode, "") == "")
				{
					if (MagicPortalFluid._teleportWorldDataCache.TryGetValue(__instance, out var value))
					{
						value.Biome = Biome;
						if (MagicPortalFluid.ConfigUseBiomeColors.Value)
						{
							List<string> list = Array.FindAll(MagicPortalFluid.BiomeRepColors.Value.Split(new char[1] { ',' }), (string s) => s.Contains(Biome))[0].Split(new char[1] { ':' }).ToList();
							foreach (KeyValuePair<string, (Color, int, bool, string, string)> portalColor in PortalColors)
							{
								if (portalColor.Key == list[1])
								{
									value.BiomeColor = portalColor.Key;
									_ = portalColor.Value;
									text2 = NameIdentifier.ToString() + portalColor.Value.Item2;
								}
							}
						}
						value.TargetColor = val;
						SetTeleportWorldColors(value, SetcolorTarget: true);
						__instance.m_nview.m_zdo.Set(MagicPortalFluid._teleportWorldColorHashCode, Utils.ColorToVec3(val));
						ZDO zdo = __instance.m_nview.m_zdo;
						int portalLastColoredByHashCode = MagicPortalFluid._portalLastColoredByHashCode;
						Player localPlayer2 = Player.m_localPlayer;
						zdo.Set(portalLastColoredByHashCode, (localPlayer2 != null) ? localPlayer2.GetPlayerID() : 0);
						__instance.m_nview.m_zdo.Set(MagicPortalFluid._portalBiomeHashCode, Biome);
						RMP.LogInfo((object)"Setting ZDO Color For First Time");
					}
					if (text == "")
					{
						updateYmltoColorChange("", num);
					}
				}
				bool flag2 = false;
				if (MagicPortalFluid._teleportWorldDataCache.TryGetValue(__instance, out var value2) && MagicPortalFluid.ConfigUseBiomeColors.Value && (text2 == "" || reloaded) && !(value2.BiomeColor == "skip") && !(__instance.m_nview.m_zdo.GetString(MagicPortalFluid._portalBiomeColorHashCode, "") == "skip"))
				{
					List<string> list2 = Array.FindAll(MagicPortalFluid.BiomeRepColors.Value.Split(new char[1] { ',' }), (string s) => s.Contains(Biome))[0].Split(new char[1] { ':' }).ToList();
					foreach (KeyValuePair<string, (Color, int, bool, string, string)> portalColor2 in PortalColors)
					{
						if (portalColor2.Key == list2[1])
						{
							__instance.m_nview.m_zdo.Set(MagicPortalFluid._portalBiomeColorHashCode, portalColor2.Key);
							value2.BiomeColor = portalColor2.Key;
							if (MagicPortalFluid.TargetPortalLoaded)
							{
								text2 = NameIdentifier.ToString() + portalColor2.Value.Item2;
								flag2 = true;
							}
						}
					}
				}
				if (text != "" && text != "Empty tag")
				{
					if (MagicPortalFluid.isAdmin || (flag && !MagicPortalFluid.ConfigEnableCrystalsNKeys.Value))
					{
						KeyboardShortcut value3 = MagicPortalFluid.portalRMPKEY.Value;
						if ((int)((KeyboardShortcut)(ref value3)).MainKey == 0)
						{
							return;
						}
						if (MagicPortalFluid.ConfigEnableCrystalsNKeys.Value)
						{
							object[] obj2 = new object[9] { __result, currentColor, null, null, null, null, null, null, null };
							value3 = MagicPortalFluid.portalRMPKEY.Value;
							obj2[2] = ((object)(KeyboardShortcut)(ref value3)).ToString() + " + E";
							obj2[3] = nextcolor;
							obj2[4] = 15;
							obj2[5] = "#" + ColorUtility.ToHtmlStringRGB(Color.yellow);
							obj2[6] = text3;
							obj2[7] = "#" + ColorUtility.ToHtmlStringRGB(val);
							obj2[8] = "#" + ColorUtility.ToHtmlStringRGB(PortalColors[nextcolor].HexName);
							__result = string.Format("{0}\n<size={4}>[<color={5}>{2}</color>] Change <color={7}>Portal</color>[{1}] Crystal to: [<color={8}>{3}</color>]</size>\n<size={4}>{6}</size>", obj2);
						}
						else
						{
							object[] obj3 = new object[8] { __result, currentColor, null, null, null, null, null, null };
							value3 = MagicPortalFluid.portalRMPKEY.Value;
							obj3[2] = ((object)(KeyboardShortcut)(ref value3)).ToString() + " + E";
							obj3[3] = nextcolor;
							obj3[4] = 15;
							obj3[5] = "#" + ColorUtility.ToHtmlStringRGB(Color.yellow);
							obj3[6] = "#" + ColorUtility.ToHtmlStringRGB(val);
							obj3[7] = "#" + ColorUtility.ToHtmlStringRGB(PortalColors[nextcolor].HexName);
							__result = string.Format("{0}\n<size={4}>[<color={5}>{2}</color>] Change <color={6}>Portal</color>[{1}] Color to: [<color={7}>{3}</color>] </size>", obj3);
						}
					}
					else if (MagicPortalFluid.ConfigEnableCrystalsNKeys.Value)
					{
						__result = string.Format("{0}\n<size={2}><color={5}>{1} Portal</color></size>\n<size={2}>{4}</size>", __result, currentColor, 15, "#" + ColorUtility.ToHtmlStringRGB(Color.yellow), text3, "#" + ColorUtility.ToHtmlStringRGB(val));
					}
					else
					{
						__result = string.Format("{0}\n<size={2}><color={4}>{1} Portal</color></size>", __result, currentColor, 15, "#" + ColorUtility.ToHtmlStringRGB(Color.yellow), "#" + ColorUtility.ToHtmlStringRGB(val));
					}
				}
				else
				{
					string text4 = "Please name Portal, ";
					string text5 = " Color ";
					__result = string.Format("{0}\n<size={1}><color={3}>{2}{5}</color><color={3}>{6}</color></size>", __result, 15, text4, "#" + ColorUtility.ToHtmlStringRGB(Color.yellow), "#" + ColorUtility.ToHtmlStringRGB(val), text5, currentColor);
				}
				string text6 = text + text2;
				if (__instance.m_nview.m_zdo.GetString("tag", "") != text6 && flag2)
				{
					__instance.SetText(text6);
				}
			}
		}

		[HarmonyPatch(typeof(Player), "Update")]
		[<e143a9e8-dc1e-4f36-83b6-d4ffdfe8fbda>NullableContext(0)]
		public static class UpdateRemoveItem
		{
			[<e143a9e8-dc1e-4f36-83b6-d4ffdfe8fbda>NullableContext(1)]
			private static void Prefix(ref Player __instance)
			{
				if (inventoryRemove && ((Character)__instance).m_nview.IsValid() && ((Character)__instance).m_nview.IsOwner())
				{
					ItemData item = ((Humanoid)__instance).m_inventory.GetItem(removeItems.Last().Key, -1, false);
					if (item == null)
					{
						RMP.LogInfo((object)"item is null");
					}
					((Humanoid)__instance).m_inventory.RemoveItem(item, removeItems.Last().Value);
					removeItems.Remove(removeItems.Last().Key);
					inventoryRemove = false;
				}
			}
		}

		public static readonly ManualLogSource RMP = Logger.CreateLogSource("RareMagicPortal");

		private static Color m_colorTargetfound = new Color(0.7490196f, 0.5882353f, 0f, 25f);

		private static Color lightcolor = new Color(1f, 20f / 51f, 0f, 1f);

		public static Color flamesstart = new Color(1f, 0.7607843f, 2f / 15f, 1f);

		public static Color flamesend = new Color(1f, 0f, 0f, 1f);

		public static Color Gold = new Color(1f, 43f / 51f, 0f, 1f);

		public static Color Purple = new Color(0.41960785f, 21f / 85f, 32f / 51f, 1f);

		public static Color Tan = new Color(0.8235294f, 0.7058824f, 28f / 51f, 1f);

		public static Color Brown = new Color(0.75686276f, 23f / 85f, 0.07450981f, 1f);

		public static Color Orange = new Color(0.8f, 1f / 3f, 0f, 1f);

		public static Color Cornsilk = new Color(1f, 0.972549f, 44f / 51f, 1f);

		public static Color Yellow2 = new Color(0.54509807f, 0.5019608f, 0f, 1f);

		internal static PortalName PortalN;

		private static int waitloop = 5;

		private static int rainbowWait = 0;

		private static string currentRainbow = "Yellow";

		public static char NameIdentifier = '▲';

		private static string BiomeStringTempHolder = "";

		internal static bool reloaded = false;

		internal static Transform CheatswordColor;

		internal static bool inventoryRemove = false;

		internal static Dictionary<string, int> removeItems = new Dictionary<string, int>();

		public static ParticleSystem CheatSwordColor = null;

		[<f04ec549-5ca7-4107-a39d-53aadf15d38b>Nullable(new byte[] { 1, 1, 0, 1, 1 })]
		internal static Dictionary<string, (Color HexName, int Pos, bool Enabled, string NextColor, string MessageText)> PortalColors = new Dictionary<string, (Color, int, bool, string, string)>
		{
			{
				"Yellow",
				(Yellow2, 1, false, "Red", "Red Crystal Portal")
			},
			{
				"Red",
				(Color.red, 2, false, "Green", "Red Crystal Portal")
			},
			{
				"Green",
				(Color.green, 3, false, "Blue", "Red Crystal Portal")
			},
			{
				"Blue",
				(Color.blue, 4, false, "Purple", "Red Crystal Portal")
			},
			{
				"Purple",
				(Purple, 5, false, "Tan", "Red Crystal Portal")
			},
			{
				"Tan",
				(Cornsilk, 6, false, "Cyan", "Red Crystal Portal")
			},
			{
				"Cyan",
				(Color.cyan, 7, false, "Orange", "Red Crystal Portal")
			},
			{
				"Orange",
				(Orange, 8, false, "White", "Red Crystal Portal")
			},
			{
				"White",
				(Color.white, 20, false, "Black", "Red Crystal Portal")
			},
			{
				"Black",
				(Color.black, 21, false, "Gold", "Red Crystal Portal")
			},
			{
				"Gold",
				(Gold, 22, false, "Yellow", "Red Crystal Portal")
			}
		};

		internal static Dictionary<string, int> CrystalCount = new Dictionary<string, int>();

		internal static Dictionary<string, int> KeyCount = new Dictionary<string, int>();

		public static void reloadcolors()
		{
			CrystalCount.Clear();
			KeyCount.Clear();
			foreach (string item in PortalColors.Keys.ToList())
			{
				(Color, int, bool, string, string) value = PortalColors[item];
				value.Item3 = false;
				PortalColors[item] = value;
			}
			foreach (string item2 in MagicPortalFluid.EnabledColors.Value.Split(new char[1] { ',' }).ToList())
			{
				if (PortalColors.ContainsKey(item2))
				{
					(Color, int, bool, string, string) value2 = PortalColors[item2];
					value2.Item3 = true;
					PortalColors[item2] = value2;
				}
			}
			foreach (KeyValuePair<string, (Color, int, bool, string, string)> portalColor in PortalColors)
			{
				CrystalCount.Add(portalColor.Key, 0);
				KeyCount.Add(portalColor.Key, 0);
			}
			foreach (KeyValuePair<string, (Color, int, bool, string, string)> item3 in PortalColors.ToList())
			{
				if (!item3.Value.Item3)
				{
					continue;
				}
				string key = item3.Key;
				(Color, int, bool, string, string) value3 = item3.Value;
				string text = ((PortalColor)Enum.Parse(typeof(PortalColor), key)).Next().ToString();
				bool flag = false;
				int num = 0;
				while (!flag)
				{
					foreach (KeyValuePair<string, (Color, int, bool, string, string)> portalColor2 in PortalColors)
					{
						if (portalColor2.Key == text)
						{
							if (portalColor2.Value.Item3)
							{
								flag = true;
								value3.Item4 = text;
							}
							else
							{
								key = portalColor2.Key;
								text = ((PortalColor)Enum.Parse(typeof(PortalColor), key)).Next().ToString();
							}
							break;
						}
					}
					num++;
					if (num > 30)
					{
						RMP.LogWarning((object)"NextColor not found");
						break;
					}
				}
				PortalColors[item3.Key] = value3;
			}
		}

		internal static void BiomeLogicCheck(out string currentColor, out Color currentColorHex, out string nextcolor, out int Pos, string PortalName = "", bool skip = false)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: 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_00aa: Unknown result type (might be due to invalid IL or missing references)
			string text = "";
			currentColor = "skip";
			currentColorHex = Gold;
			nextcolor = "White";
			Pos = 0;
			if (Enumerable.Contains(PortalName, NameIdentifier))
			{
				text = PortalName.Substring(PortalName.IndexOf(NameIdentifier));
				PortalName = PortalName[..PortalName.IndexOf(NameIdentifier)];
			}
			if (text != "" && MagicPortalFluid.ConfigUseBiomeColors.Value && !skip)
			{
				text = text.Remove(0, 1);
				currentColor = ((PortalColor)int.Parse(text)).ToString();
				currentColorHex = PortalColors[currentColor].HexName;
				nextcolor = PortalColors[currentColor].NextColor;
				Pos = PortalColors[currentColor].Pos;
			}
		}

		internal static int CrystalandKeyLogicColor(out string currentColor, out Color currentColorHex, out string nextcolor, string PortalName = "", TeleportWorld __instance = null, int overrideInt = 0)
		{
			//IL_064f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0654: Unknown result type (might be due to invalid IL or missing references)
			//IL_0609: Unknown result type (might be due to invalid IL or missing references)
			//IL_060e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0580: Unknown result type (might be due to invalid IL or missing references)
			//IL_0585: Unknown result type (might be due to invalid IL or missing references)
			//IL_034c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0351: Unknown result type (might be due to invalid IL or missing references)
			//IL_018f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: Unknown result type (might be due to invalid IL or missing references)
			//IL_0468: Unknown result type (might be due to invalid IL or missing references)
			//IL_046d: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_04cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_02af: Unknown result type (might be due to invalid IL or missing references)
			//IL_03dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_021d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0222: Unknown result type (might be due to invalid IL or missing references)
			string text = "";
			string text2 = "";
			if (Enumerable.Contains(PortalName, NameIdentifier))
			{
				text = PortalName.Substring(PortalName.IndexOf(NameIdentifier));
				PortalName = PortalName[..PortalName.IndexOf(NameIdentifier)];
			}
			if ((Object)(object)__instance != (Object)null && text == "" && __instance.m_nview.m_zdo.GetString(MagicPortalFluid._portalBiomeColorHashCode, "") != "skip")
			{
				text2 = __instance.m_nview.m_zdo.GetString(MagicPortalFluid._portalBiomeColorHashCode, "");
			}
			_ = MagicPortalFluid.ConfigCrystalsConsumable.Value;
			bool flag = false;
			bool flag2 = false;
			if (!PortalN.Portals.ContainsKey(PortalName))
			{
				WritetoYML(PortalName);
			}
			flag = PortalN.Portals[PortalName].Admin_only_Access;
			flag2 = PortalN.Portals[PortalName].Free_Passage;
			Dictionary<string, int> portal_Crystal_Cost = PortalN.Portals[PortalName].Portal_Crystal_Cost;
			Dictionary<string, bool> portal_Key = PortalN.Portals[PortalName].Portal_Key;
			_ = PortalN.Portals[PortalName].BiomeColor;
			if (PortalName != "" && PortalName != "Empty tag")
			{
				if (flag && MagicPortalFluid.AdminColor.Value != "none")
				{
					currentColor = MagicPortalFluid.AdminColor.Value;
					currentColorHex = PortalColors[MagicPortalFluid.AdminColor.Value].HexName;
					nextcolor = PortalColors[MagicPortalFluid.AdminColor.Value].NextColor;
					return PortalColors[currentColor].Pos;
				}
				if (flag2 && MagicPortalFluid.FreePassageColor.Value != "none" && text != "" && text2 != "")
				{
					currentColor = MagicPortalFluid.FreePassageColor.Value;
					currentColorHex = PortalColors[MagicPortalFluid.FreePassageColor.Value].HexName;
					nextcolor = PortalColors[MagicPortalFluid.FreePassageColor.Value].NextColor;
					return PortalColors[MagicPortalFluid.FreePassageColor.Value].Pos;
				}
				if (PortalN.Portals[PortalName].TeleportAnything && MagicPortalFluid.TelePortAnythingColor.Value != "none")
				{
					currentColor = MagicPortalFluid.TelePortAnythingColor.Value;
					currentColorHex = PortalColors[MagicPortalFluid.TelePortAnythingColor.Value].HexName;
					nextcolor = PortalColors[MagicPortalFluid.TelePortAnythingColor.Value].NextColor;
					return PortalColors[MagicPortalFluid.TelePortAnythingColor.Value].Pos;
				}
			}
			if ((text != "" || text2 != "") && MagicPortalFluid.ConfigUseBiomeColors.Value)
			{
				if ((Object)(object)__instance == (Object)null)
				{
					text = text.Remove(0, 1);
					currentColor = ((PortalColor)int.Parse(text)).ToString();
					currentColorHex = PortalColors[currentColor].HexName;
					nextcolor = PortalColors[currentColor].NextColor;
					return PortalColors[currentColor].Pos;
				}
				MagicPortalFluid._teleportWorldDataCache.TryGetValue(__instance, out var value);
				if (value.BiomeColor != "skip")
				{
					if (text != "")
					{
						text = text.Remove(0, 1);
						currentColor = ((PortalColor)int.Parse(text)).ToString();
					}
					else
					{
						currentColor = text2;
					}
					currentColorHex = PortalColors[currentColor].HexName;
					nextcolor = PortalColors[currentColor].NextColor;
					return PortalColors[currentColor].Pos;
				}
			}
			if (PortalName == "")
			{
				if (MagicPortalFluid.CrystalKeyDefaultColor.Value == "None" || MagicPortalFluid.CrystalKeyDefaultColor.Value == "none")
				{
					currentColor = MagicPortalFluid.FreePassageColor.Value;
					currentColorHex = PortalColors[MagicPortalFluid.FreePassageColor.Value].HexName;
					nextcolor = PortalColors[MagicPortalFluid.FreePassageColor.Value].NextColor;
					return PortalColors[MagicPortalFluid.FreePassageColor.Value].Pos;
				}
				currentColor = MagicPortalFluid.CrystalKeyDefaultColor.Value;
				currentColorHex = PortalColors[MagicPortalFluid.CrystalKeyDefaultColor.Value].HexName;
				nextcolor = PortalColors[MagicPortalFluid.CrystalKeyDefaultColor.Value].NextColor;
				return PortalColors[MagicPortalFluid.CrystalKeyDefaultColor.Value].Pos;
			}
			foreach (KeyValuePair<string, (Color, int, bool, string, string)> portalColor in PortalColors)
			{
				string key = portalColor.Key;
				if (!portalColor.Value.Item3 || (MagicPortalFluid.ConfigEnableGoldAsMaster.Value && portalColor.Key == "Gold"))
				{
					continue;
				}
				try
				{
					if (portal_Crystal_Cost[key] > 0 || portal_Key[key])
					{
						currentColor = key;
						currentColorHex = PortalColors[currentColor].HexName;
						nextcolor = portalColor.Value.Item4;
						return portalColor.Value.Item2;
					}
				}
				catch
				{
				}
			}
			if (MagicPortalFluid.ConfigEnableGoldAsMaster.Value && (portal_Crystal_Cost["Gold"] > 0 || portal_Key["Gold"]))
			{
				currentColor = "Gold";
				currentColorHex = PortalColors[currentColor].HexName;
				nextcolor = PortalColors[currentColor].NextColor;
				return PortalColors[currentColor].Pos;
			}
			currentColor = "Yellow";
			currentColorHex = PortalColors["Yellow"].HexName;
			nextcolor = "Red";
			return 0;
		}

		internal static void updateYmltoColorChange(string PortalName, int colorint, string BiomeCol = null)
		{
			if (!PortalN.Portals.ContainsKey(PortalName))
			{
				WritetoYML(PortalName);
			}
			PortalColor portalColor = (PortalColor)colorint;
			string text = portalColor.ToString();
			PortalN.Portals[PortalName].TeleportAnything = false;
			PortalN.Portals[PortalName].Admin_only_Access = false;
			PortalN.Portals[PortalName].Free_Passage = false;
			foreach (KeyValuePair<string, (Color, int, bool, string, string)> portalColor2 in PortalColors)
			{
				PortalN.Portals[PortalName].Portal_Crystal_Cost[portalColor2.Key] = 0;
				PortalN.Portals[PortalName].Portal_Key[portalColor2.Key] = false;
			}
			PortalN.Portals[PortalName].Portal_Crystal_Cost[text] = MagicPortalFluid.ConfigCrystalsConsumable.Value;
			PortalN.Portals[PortalName].Portal_Key[text] = true;
			if (MagicPortalFluid.FreePassageColor.Value == text)
			{
				PortalN.Portals[PortalName].Free_Passage = true;
			}
			if (MagicPortalFluid.ConfigEnableCrystalsNKeys.Value)
			{
				if (MagicPortalFluid.AdminColor.Value == text)
				{
					PortalN.Portals[PortalName].Admin_only_Access = true;
					PortalN.Portals[PortalName].TeleportAnything = true;
				}
				if (MagicPortalFluid.ConfigEnableGoldAsMaster.Value)
				{
					PortalN.Portals[PortalName].Portal_Crystal_Cost["Gold"] = 1;
					PortalN.Portals[PortalName].Portal_Key["Gold"] = true;
				}
				if (MagicPortalFluid.FreePassageColor.Value == text)
				{
					PortalN.Portals[PortalName].Free_Passage = true;
				}
				if (MagicPortalFluid.TelePortAnythingColor.Value == text)
				{
					PortalN.Portals[PortalName].TeleportAnything = true;
				}
			}
			if (BiomeCol != null)
			{
				PortalN.Portals[PortalName].BiomeColor = BiomeCol;
			}
			if (PortalName == "" && MagicPortalFluid.ConfigAddRestricted.Value != "")
			{
				PortalN.Portals[PortalName].AdditionalProhibitItems = MagicPortalFluid.ConfigAddRestricted.Value.Split(new char[1] { ',' }).ToList();
			}
			ClientORServerYMLUpdate(PortalN.Portals[PortalName], PortalName, colorint);
		}

		internal static void ClientORServerYMLUpdate(PortalName.Portal wacky, string PortNam, int colorint)
		{
			<803dcee1-f5f3-4b7a-8321-94fbb55ef8d6>ISerializer <803dcee1-f5f3-4b7a-8321-94fbb55ef8d6>ISerializer = new <e7bba29c-a42b-46ec-ac53-439b82edf48e>SerializerBuilder().Build();
			string value = string.Concat(PortNam + MagicPortalFluid.StringSeparator, <803dcee1-f5f3-4b7a-8321-94fbb55ef8d6>ISerializer.Serialize(PortalN.Portals[PortNam]));
			if (ZNet.instance.IsServer() && ZNet.instance.IsDedicated())
			{
				string text = null;
				text = MagicPortalFluid.WelcomeString + Environment.NewLine + <803dcee1-f5f3-4b7a-8321-94fbb55ef8d6>ISerializer.Serialize(PortalN);
				if (!MagicPortalFluid.RiskyYMLSave.Value)
				{
					MagicPortalFluid.JustWrote = 1;
					File.WriteAllText(MagicPortalFluid.YMLCurrentFile, text);
					string text2 = "";
					foreach (string item in File.ReadLines(MagicPortalFluid.YMLCurrentFile))
					{
						text2 = text2 + item + Environment.NewLine;
						if (item.Contains("Admin_only_Access"))
						{
							text2 += Environment.NewLine;
						}
					}
					File.WriteAllText(MagicPortalFluid.YMLCurrentFile, text2);
					MagicPortalFluid.JustWrote = 2;
				}
				if (MagicPortalFluid.UseSmallUpdates.Value)
				{
					MagicPortalFluid.YMLPortalSmallData.Value = value;
				}
				else
				{
					MagicPortalFluid.YMLPortalData.Value = text;
				}
				return;
			}
			if (!ZNet.instance.IsServer())
			{
				functions.ServerZDOymlUpdate(colorint, PortNam);
				return;
			}
			MagicPortalFluid.RareMagicPortal.LogInfo((object)"Single client only or Server but not dedicated");
			string text3 = MagicPortalFluid.WelcomeString + Environment.NewLine + <803dcee1-f5f3-4b7a-8321-94fbb55ef8d6>ISerializer.Serialize(PortalN);
			if (!MagicPortalFluid.RiskyYMLSave.Value)
			{
				MagicPortalFluid.JustWrote = 1;
				File.WriteAllText(MagicPortalFluid.YMLCurrentFile, text3);
				string text4 = "";
				foreach (string item2 in File.ReadLines(MagicPortalFluid.YMLCurrentFile))
				{
					text4 = text4 + item2 + Environment.NewLine;
					if (item2.Contains("Admin_only_Access"))
					{
						text4 += Environment.NewLine;
					}
				}
				File.WriteAllText(MagicPortalFluid.YMLCurrentFile, text4);
				MagicPortalFluid.JustWrote = 2;
			}
			if (MagicPortalFluid.ConfigEnableYMLLogs.Value)
			{
				MagicPortalFluid.RareMagicPortal.LogInfo((object)text3);
			}
			if (ZNet.instance.IsServer())
			{
				MagicPortalFluid.YMLPortalData.Value = text3;
			}
		}

		internal static bool CrystalandKeyLogic(string PortalName, string BiomeColor = "")
		{
			//IL_07b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_07c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0bad: Unknown result type (might be due to invalid IL or missing references)
			//IL_0bd6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0bff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0939: Unknown result type (might be due to invalid IL or missing references)
			//IL_0952: Unknown result type (might be due to invalid IL or missing references)
			//IL_096b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0984: Unknown result type (might be due to invalid IL or missing references)
			//IL_099d: Unknown result type (might be due to invalid IL or missing references)
			//IL_09b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_09cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_09e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a01: Unknown result type (might be due to invalid IL or missing references)
			//IL_10e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a1a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a33: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a4c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a65: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a8e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ab7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ae0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b09: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b32: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b5b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b84: Unknown result type (might be due to invalid IL or missing references)
			_ = MagicPortalFluid.ConfigCrystalsConsumable.Value;
			bool flag = false;
			bool flag2 = false;
			string text = "";
			string text2 = "";
			bool flag3 = false;
			if (Enumerable.Contains(PortalName, NameIdentifier))
			{
				text = PortalName.Substring(PortalName.IndexOf(NameIdentifier) + 1);
				PortalName = PortalName[..PortalName.IndexOf(NameIdentifier)];
				if (MagicPortalFluid.ConfigUseBiomeColors.Value && BiomeColor != "skip")
				{
					flag3 = true;
					text2 = ((PortalColor)int.Parse(text)).ToString();
				}
			}
			if (BiomeColor != "" && MagicPortalFluid.ConfigUseBiomeColors.Value && !flag3 && BiomeColor != "skip")
			{
				text2 = BiomeColor;
				flag3 = true;
			}
			MagicPortalFluid.RareMagicPortal.LogInfo((object)("Portal name is " + PortalName));
			if (!PortalN.Portals.ContainsKey(PortalName))
			{
				WritetoYML(PortalName);
			}
			flag = PortalN.Portals[PortalName].Admin_only_Access;
			flag2 = PortalN.Portals[PortalName].Free_Passage;
			Dictionary<string, int> dictionary = PortalN.Portals[PortalName].Portal_Crystal_Cost;
			Dictionary<string, bool> dictionary2 = PortalN.Portals[PortalName].Portal_Key;
			bool teleportAnything = PortalN.Portals[PortalName].TeleportAnything;
			Player localPlayer = Player.m_localPlayer;
			if ((flag && MagicPortalFluid.isAdmin && !flag3) || text2 == MagicPortalFluid.AdminColor.Value)
			{
				((Character)localPlayer).Message((MessageType)1, "$rmp_kin_welcome", 0, (Sprite)null);
				return true;
			}
			if (flag && !MagicPortalFluid.isAdmin && MagicPortalFluid.ConfigEnableCrystalsNKeys.Value && !flag3)
			{
				((Character)localPlayer).Message((MessageType)2, "$rmp_kin_only", 0, (Sprite)null);
				return false;
			}
			if ((teleportAnything && !flag3) || text2 == MagicPortalFluid.TelePortAnythingColor.Value)
			{
				((Character)localPlayer).Message((MessageType)1, "$rmp_freepassage", 0, (Sprite)null);
				if (MagicPortalFluid.ConfigEnableCrystalsNKeys.Value)
				{
					((Character)localPlayer).Message((MessageType)2, "$rmp_allowsEverything", 0, (Sprite)null);
				}
				return true;
			}
			if (MagicPortalFluid.ConfigEnableCrystalsNKeys.Value)
			{
				if (!((Humanoid)localPlayer).IsTeleportable())
				{
					((Character)localPlayer).Message((MessageType)2, "$msg_noteleport", 0, (Sprite)null);
					return false;
				}
				if ((flag2 && !flag3) || text2 == MagicPortalFluid.FreePassageColor.Value)
				{
					((Character)localPlayer).Message((MessageType)1, "$rmp_freepassage", 0, (Sprite)null);
					return true;
				}
				CrystalCount["Gold"] = ((Humanoid)localPlayer).m_inventory.CountItems(MagicPortalFluid.GemColorGold.Value, -1, true);
				CrystalCount["Red"] = ((Humanoid)localPlayer).m_inventory.CountItems(MagicPortalFluid.GemColorRed.Value, -1, true);
				CrystalCount["Green"] = ((Humanoid)localPlayer).m_inventory.CountItems(MagicPortalFluid.GemColorGreen.Value, -1, true);
				CrystalCount["Blue"] = ((Humanoid)localPlayer).m_inventory.CountItems(MagicPortalFluid.GemColorBlue.Value, -1, true);
				CrystalCount["Purple"] = ((Humanoid)localPlayer).m_inventory.CountItems(MagicPortalFluid.GemColorPurple.Value, -1, true);
				CrystalCount["Tan"] = ((Humanoid)localPlayer).m_inventory.CountItems(MagicPortalFluid.GemColorTan.Value, -1, true);
				CrystalCount["Yellow"] = ((Humanoid)localPlayer).m_inventory.CountItems(MagicPortalFluid.GemColorYellow.Value, -1, true);
				CrystalCount["White"] = ((Humanoid)localPlayer).m_inventory.CountItems(MagicPortalFluid.GemColorWhite.Value, -1, true);
				CrystalCount["Black"] = ((Humanoid)localPlayer).m_inventory.CountItems(MagicPortalFluid.GemColorBlack.Value, -1, true);
				CrystalCount["Cyan"] = ((Humanoid)localPlayer).m_inventory.CountItems(MagicPortalFluid.GemColorCyan.Value, -1, true);
				CrystalCount["Orange"] = ((Humanoid)localPlayer).m_inventory.CountItems(MagicPortalFluid.GemColorOrange.Value, -1, true);
				KeyCount["Gold"] = ((Humanoid)localPlayer).m_inventory.CountItems(MagicPortalFluid.PortalKeyGold, -1, true);
				KeyCount["Red"] = ((Humanoid)localPlayer).m_inventory.CountItems(MagicPortalFluid.PortalKeyRed, -1, true);
				KeyCount["Green"] = ((Humanoid)localPlayer).m_inventory.CountItems(MagicPortalFluid.PortalKeyGreen, -1, true);
				KeyCount["Blue"] = ((Humanoid)localPlayer).m_inventory.CountItems(MagicPortalFluid.PortalKeyBlue, -1, true);
				KeyCount["Purple"] = ((Humanoid)localPlayer).m_inventory.CountItems(MagicPortalFluid.PortalKeyPurple, -1, true);
				KeyCount["Tan"] = ((Humanoid)localPlayer).m_inventory.CountItems(MagicPortalFluid.PortalKeyTan, -1, true);
				KeyCount["White"] = ((Humanoid)localPlayer).m_inventory.CountItems(MagicPortalFluid.PortalKeyWhite, -1, true);
				KeyCount["Yellow"] = ((Humanoid)localPlayer).m_inventory.CountItems(MagicPortalFluid.PortalKeyYellow, -1, true);
				KeyCount["Black"] = ((Humanoid)localPlayer).m_inventory.CountItems(MagicPortalFluid.PortalKeyBlack, -1, true);
				KeyCount["Cyan"] = ((Humanoid)localPlayer).m_inventory.CountItems(MagicPortalFluid.PortalKeyCyan, -1, true);
				KeyCount["Orange"] = ((Humanoid)localPlayer).m_inventory.CountItems(MagicPortalFluid.PortalKeyOrange, -1, true);
				if (flag3)
				{
					dictionary = new Dictionary<string, int>();
					dictionary2 = new Dictionary<string, bool>();
					dictionary.Add(text2, MagicPortalFluid.ConfigCrystalsConsumable.Value);
					dictionary2.Add(text2, value: true);
					if (MagicPortalFluid.ConfigEnableGoldAsMaster.Value)
					{
						dictionary.Add("Gold", MagicPortalFluid.ConfigCrystalsConsumable.Value);
						dictionary2.Add("Gold", value: true);
					}
				}
				int num = 0;
				int num2 = 0;
				bool flag4 = false;
				int num3 = 0;
				_ = PortalColors.Count;
				foreach (KeyValuePair<string, (Color, int, bool, string, string)> portalColor in PortalColors)
				{
					if (!dictionary.TryGetValue(portalColor.Key, out var _) || (dictionary[portalColor.Key] <= 0 && !dictionary2[portalColor.Key]) || flag4)
					{
						continue;
					}
					num = ((CrystalCount[portalColor.Key] == 0) ? portalColor.Value.Item2 : ((dictionary[portalColor.Key] <= CrystalCount[portalColor.Key]) ? (200 + portalColor.Value.Item2) : (100 + portalColor.Value.Item2)));
					if (dictionary2[portalColor.Key])
					{
						if (dictionary[portalColor.Key] == 0)
						{
							num2 = 1;
							num = ((KeyCount[portalColor.Key] <= 0) ? portalColor.Value.Item2 : (300 + portalColor.Value.Item2));
						}
						else if (KeyCount[portalColor.Key] > 0 && num < 200)
						{
							num = 300 + portalColor.Value.Item2;
						}
						else
						{
							num2 = 2;
						}
					}
					if (num > 200)
					{
						flag4 = true;
					}
					if (num < 200 && num3 == 0)
					{
						num3 = num;
					}
				}
				if (num < 22 && num3 == 0)
				{
					num3 = num;
				}
				if (num == 22 && num3 != 0)
				{
					num = num3;
				}
				string text3 = "$rmp_crystals";
				if (num2 == 1)
				{
					text3 = "$rmp_key";
				}
				if (num2 == 2)
				{
					text3 = "$rmp_crystalorkey";
				}
				MessageType val = (MessageType)2;
				if (MagicPortalFluid.ConfigMessageLeft.Value)
				{
					val = (MessageType)1;
				}
				switch (num)
				{
				case 0:
					((Character)localPlayer).Message(val, "$rmp_noaccess " + text3, 0, (Sprite)null);
					return false;
				case 1:
					((Character)localPlayer).Message(val, "$rmp_no_yellow_portal " + text3, 0, (Sprite)null);
					return false;
				case 2:
					((Character)localPlayer).Message(val, "$rmp_no_red_portal " + text3, 0, (Sprite)null);
					return false;
				case 3:
					((Character)localPlayer).Message(val, "$rmp_no_green_portal " + text3, 0, (Sprite)null);
					return false;
				case 4:
					((Character)localPlayer).Message(val, "$rmp_no_blue_portal " + text3, 0, (Sprite)null);
					return false;
				case 5:
					((Character)localPlayer).Message(val, "$rmp_no_purple_portal " + text3, 0, (Sprite)null);
					return false;
				case 6:
					((Character)localPlayer).Message(val, "$rmp_no_tan_portal " + text3, 0, (Sprite)null);
					return false;
				case 7:
					((Character)localPlayer).Message(val, "$rmp_no_cyan_portal " + text3, 0, (Sprite)null);
					return false;
				case 8:
					((Character)localPlayer).Message(val, "$rmp_no_orange_portal " + text3, 0, (Sprite)null);
					return false;
				case 20:
					((Character)localPlayer).Message(val, "$rmp_no_white_portal " + text3, 0, (Sprite)null);
					return false;
				case 21:
					((Character)localPlayer).Message(val, "$rmp_no_black_portal " + text3, 0, (Sprite)null);
					return false;
				case 22:
					((Character)localPlayer).Message(val, "$rmp_no_gold_portal " + text3, 0, (Sprite)null);
					return false;
				case 101:
					((Character)localPlayer).Message(val, string.Format("{0} $rmp_required_yellow {1}", dictionary["Yellow"], PortalName), 0, (Sprite)null);
					return false;
				case 102:
					((Character)localPlayer).Message(val, string.Format("{0} $rmp_required_red {1}", dictionary["Red"], PortalName), 0, (Sprite)null);
					return false;
				case 103:
					((Character)localPlayer).Message(val, string.Format("{0} $rmp_required_green {1}", dictionary["Green"], PortalName), 0, (Sprite)null);
					return false;
				case 104:
					((Character)localPlayer).Message(val, string.Format("{0} $rmp_required_blue {1}", dictionary["Blue"], PortalName), 0, (Sprite)null);
					return false;
				case 105:
					((Character)localPlayer).Message(val, string.Format("{0} $rmp_required_purple {1}", dictionary["Purple"], PortalName), 0, (Sprite)null);
					return false;
				case 106:
					((Character)localPlayer).Message(val, string.Format("{0} $rmp_required_tan {1}", dictionary["Tan"], PortalName), 0, (Sprite)null);
					return false;
				case 107:
					((Character)localPlayer).Message(val, string.Format("{0} $rmp_required_cyan {1}", dictionary["Cyan"], PortalName), 0, (Sprite)null);
					return false;
				case 108:
					((Character)localPlayer).Message(val, string.Format("{0} $rmp_required_orange {1}", dictionary["Orange"], PortalName), 0, (Sprite)null);
					return false;
				case 120:
					((Character)localPlayer).Message(val, string.Format("{0} $rmp_required_white {1}", dictionary["White"], PortalName), 0, (Sprite)null);
					return false;
				case 121:
					((Character)localPlayer).Message(val, string.Format("{0} $rmp_required_black {1}", dictionary["Black"], PortalName), 0, (Sprite)null);
					return false;
				case 122:
					((Character)localPlayer).Message(val, string.Format("{0} $rmp_required_gold {1}", dictionary["Gold"], PortalName), 0, (Sprite)null);
					return false;
				case 201:
					((Character)localPlayer).Message((MessageType)2, "$rmp_crystalgrants_access", 0, (Sprite)null);
					((Character)localPlayer).Message((MessageType)1, string.Format("$rmp_consumed {0} $rmp_consumed_yellow", dictionary["Yellow"]), 0, (Sprite)null);
					removeItems.Add(MagicPortalFluid.GemColorYellow.Value, dictionary["Yellow"]);
					inventoryRemove = true;
					return true;
				case 202:
					((Character)localPlayer).Message((MessageType)2, "$rmp_crystalgrants_access", 0, (Sprite)null);
					((Character)localPlayer).Message((MessageType)1, string.Format("$rmp_consumed {0} $rmp_consumed_red", dictionary["Red"]), 0, (Sprite)null);
					removeItems.Add(MagicPortalFluid.GemColorRed.Value, dictionary["Red"]);
					inventoryRemove = true;
					return true;
				case 203:
					((Character)localPlayer).Message((MessageType)2, "$rmp_crystalgrants_access", 0, (Sprite)null);
					((Character)localPlayer).Message((MessageType)1, string.Format("$rmp_consumed {0} $rmp_consumed_green", dictionary["Green"]), 0, (Sprite)null);
					removeItems.Add(MagicPortalFluid.GemColorGreen.Value, dictionary["Green"]);
					inventoryRemove = true;
					return true;
				case 204:
					((Character)localPlayer).Message((MessageType)2, "$rmp_crystalgrants_access", 0, (Sprite)null);
					((Character)localPlayer).Message((MessageType)1, string.Format("$rmp_consumed {0} $rmp_consumed_blue", dictionary["Blue"]), 0, (Sprite)null);
					removeItems.Add(MagicPortalFluid.GemColorBlue.Value, dictionary["Blue"]);
					inventoryRemove = true;
					return true;
				case 205:
					((Character)localPlayer).Message((MessageType)2, "$rmp_crystalgrants_access", 0, (Sprite)null);
					((Character)localPlayer).Message((MessageType)1, string.Format("$rmp_consumed {0} $rmp_consumed_purple", dictionary["Purple"]), 0, (Sprite)null);
					removeItems.Add(MagicPortalFluid.GemColorPurple.Value, dictionary["Purple"]);
					inventoryRemove = true;
					return true;
				case 206:
					((Character)localPlayer).Message((MessageType)2, "$rmp_crystalgrants_access", 0, (Sprite)null);
					((Character)localPlayer).Message((MessageType)1, string.Format("$rmp_consumed {0} $rmp_consumed_tan", dictionary["Tan"]), 0, (Sprite)null);
					removeItems.Add(MagicPortalFluid.GemColorTan.Value, dictionary["Tan"]);
					inventoryRemove = true;
					return true;
				case 207:
					((Character)localPlayer).Message((MessageType)2, "$rmp_crystalgrants_access", 0, (Sprite)null);
					((Character)localPlayer).Message((MessageType)1, string.Format("$rmp_consumed {0} $rmp_consumed_cyan", dictionary["Cyan"]), 0, (Sprite)null);
					removeItems.Add(MagicPortalFluid.GemColorCyan.Value, dictionary["Cyan"]);
					inventoryRemove = true;
					return true;
				case 208:
					((Character)localPlayer).Message((MessageType)2, "$rmp_crystalgrants_access", 0, (Sprite)null);
					((Character)localPlayer).Message((MessageType)1, string.Format("$rmp_consumed {0} $rmp_consumed_orange", dictionary["Orange"]), 0, (Sprite)null);
					removeItems.Add(MagicPortalFluid.GemColorOrange.Value, dictionary["Orange"]);
					inventoryRemove = true;
					return true;
				case 220:
					((Character)localPlayer).Message((MessageType)2, "$rmp_crystalgrants_access", 0, (Sprite)null);
					((Character)localPlayer).Message((MessageType)1, string.Format("$rmp_consumed {0} $rmp_consumed_white", dictionary["White"]), 0, (Sprite)null);
					removeItems.Add(MagicPortalFluid.GemColorWhite.Value, dictionary["White"]);
					inventoryRemove = true;
					return true;
				case 221:
					((Character)localPlayer).Message((MessageType)2, "$rmp_crystalgrants_access", 0, (Sprite)null);
					((Character)localPlayer).Message((MessageType)1, string.Format("$rmp_consumed {0} $rmp_consumed_black", dictionary["Black"]), 0, (Sprite)null);
					removeItems.Add(MagicPortalFluid.GemColorBlack.Value, dictionary["Black"]);
					inventoryRemove = true;
					return true;
				case 222:
					((Character)localPlayer).Message((MessageType)2, "$rmp_crystalgrants_access", 0, (Sprite)null);
					((Character)localPlayer).Message((MessageType)1, string.Format("$rmp_consumed {0} $rmp_consumed_gold", dictionary["Gold"]), 0, (Sprite)null);
					removeItems.Add(MagicPortalFluid.GemColorGold.Value, dictionary["Gold"]);
					inventoryRemove = true;
					return true;
				case 301:
					((Character)localPlayer).Message((MessageType)1, "$rmp_yellowKey_access", 0, (Sprite)null);
					return true;
				case 302:
					((Character)localPlayer).Message((MessageType)1, "$rmp_redKey_access", 0, (Sprite)null);
					return true;
				case 303:
					((Character)localPlayer).Message((MessageType)1, "$rmp_greenKey_access", 0, (Sprite)null);
					return true;
				case 304:
					((Character)localPlayer).Message((MessageType)1, "$rmp_blueKey_access", 0, (Sprite)null);
					return true;
				case 305:
					((Character)localPlayer).Message((MessageType)1, "$rmp_purpleKey_access", 0, (Sprite)null);
					return true;
				case 306:
					((Character)localPlayer).Message((MessageType)1, "$rmp_tanKey_access", 0, (Sprite)null);
					return true;
				case 307:
					((Character)localPlayer).Message((MessageType)1, "$rmp_cyanKey_access", 0, (Sprite)null);
					return true;
				case 308:
					((Character)localPlayer).Message((MessageType)1, "$rmp_orangeKey_access", 0, (Sprite)null);
					return true;
				case 320:
					((Character)localPlayer).Message((MessageType)1, "$rmp_whiteKey_access", 0, (Sprite)null);
					return true;
				case 321:
					((Character)localPlayer).Message((MessageType)1, "$rmp_blackKey_access", 0, (Sprite)null);
					return true;
				case 322:
					((Character)localPlayer).Message((MessageType)1, "$rmp_goldKey_access", 0, (Sprite)null);
					return true;
				case 999:
					((Character)localPlayer).Message((MessageType)1, "$rmp_noaccess", 0, (Sprite)null);
					return false;
				default:
					((Character)localPlayer).Message(val, "$rmp_noaccess", 0, (Sprite)null);
					return false;
				}
			}
			return true;
		}

		internal static void WritetoYML(string PortalName, string updateP = null)
		{
			RMP.LogInfo((object)"Writing New YML");
			int num = 1;
			if (updateP == null)
			{
				PortalName.Portal value = new PortalName.Portal();
				PortalN.Portals.Add(PortalName, value);
			}
			if (updateP != null)
			{
				PortalN.Portals[PortalName].Portal_Crystal_Cost[updateP] = 0;
				PortalN.Portals[PortalName].Portal_Key[updateP] = false;
				PortalN.Portals[PortalName].Free_Passage = false;
				PortalN.Portals[PortalName].TeleportAnything = false;
				PortalN.Portals[PortalName].Admin_only_Access = false;
			}
			if (MagicPortalFluid.CrystalKeyDefaultColor.Value == "None" || MagicPortalFluid.CrystalKeyDefaultColor.Value == "none")
			{
				PortalN.Portals[PortalName].Free_Passage = false;
				num = 1;
				PortalN.Portals[PortalName].Portal_Crystal_Cost["Yellow"] = MagicPortalFluid.ConfigCrystalsConsumable.Value;
				PortalN.Portals[PortalName].Portal_Key["Yellow"] = true;
			}
			else
			{
				PortalN.Portals[PortalName].Portal_Crystal_Cost[MagicPortalFluid.CrystalKeyDefaultColor.Value] = MagicPortalFluid.ConfigCrystalsConsumable.Value;
				PortalN.Portals[PortalName].Portal_Key[MagicPortalFluid.CrystalKeyDefaultColor.Value] = true;
				num = PortalColors[MagicPortalFluid.CrystalKeyDefaultColor.Value].Pos;
			}
			if (!(MagicPortalFluid.FreePassageColor.Value == "None") && !(MagicPortalFluid.FreePassageColor.Value == "none") && (MagicPortalFluid.CrystalKeyDefaultColor.Value == MagicPortalFluid.FreePassageColor.Value || (MagicPortalFluid.FreePassageColor.Value == "Yellow" && num == 1)))
			{
				PortalN.Portals[PortalName].Free_Passage = true;
				num = PortalColors[MagicPortalFluid.FreePassageColor.Value].Pos;
				PortalN.Portals[PortalName].Portal_Crystal_Cost[MagicPortalFluid.FreePassageColor.Value] = 0;
				PortalN.Portals[PortalName].Portal_Key[MagicPortalFluid.FreePassageColor.Value] = false;
			}
			if (!(MagicPortalFluid.TelePortAnythingColor.Value == "None") && !(MagicPortalFluid.TelePortAnythingColor.Value == "none") && (MagicPortalFluid.CrystalKeyDefaultColor.Value == MagicPortalFluid.TelePortAnythingColor.Value || (MagicPortalFluid.TelePortAnythingColor.Value == "Yellow" && num == 1)))
			{
				PortalN.Portals[PortalName].TeleportAnything = true;
				num = PortalColors[MagicPortalFluid.TelePortAnythingColor.Value].Pos;
			}
			if (!(MagicPortalFluid.AdminColor.Value == "None") && !(MagicPortalFluid.AdminColor.Value == "none") && (MagicPortalFluid.CrystalKeyDefaultColor.Value == MagicPortalFluid.AdminColor.Value || (MagicPortalFluid.AdminColor.Value == "Yellow" && num == 1)))
			{
				PortalN.Portals[PortalName].Admin_only_Access = true;
				num = PortalColors[MagicPortalFluid.AdminColor.Value].Pos;
			}
			if (MagicPortalFluid.ConfigAddRestricted.Value != "")
			{
				PortalN.Portals[PortalName].AdditionalProhibitItems = MagicPortalFluid.ConfigAddRestricted.Value.Split(new char[1] { ',' }).ToList();
			}
			ClientORServerYMLUpdate(PortalN.Portals[PortalName], PortalName, num);
		}

		private static void SetTeleportWorldColors(TeleportWorldDataRMP teleportWorldData, bool SetcolorTarget = false, bool SetMaterial = false)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: 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_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_015f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: Unknown result type (might be due to invalid IL or missing references)
			//IL_016c: Unknown result type (might be due to invalid IL or missing references)
			//IL_019c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0202: Unknown result type (might be due to invalid IL or missing references)
			//IL_0207: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0233: Unknown result type (might be due to invalid IL or missing references)
			//IL_0238: Unknown result type (might be due to invalid IL or missing references)
			//IL_0215: Unknown result type (might be due to invalid IL or missing references)
			//IL_021a: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02de: Unknown result type (might be due to invalid IL or missing references)
			//IL_0262: Unknown result type (might be due to invalid IL or missing references)
			//IL_0267: Unknown result type (might be due to invalid IL or missing references)
			//IL_0246: Unknown result type (might be due to invalid IL or missing references)
			//IL_024b: Unknown result type (might be due to invalid IL or missing references)
			//IL_031e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0323: Unknown result type (might be due to invalid IL or missing references)
			//IL_032e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0333: Unknown result type (might be due to invalid IL or missing references)
			//IL_0336: Unknown result type (might be due to invalid IL or missing references)
			//IL_033b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0383: Unknown result type (might be due to invalid IL or missing references)
			//IL_0388: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_04be: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_04cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_04dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_052f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0534: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_055c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0561: Unknown result type (might be due to invalid IL or missing references)
			//IL_0546: Unknown result type (might be due to invalid IL or missing references)
			//IL_0550: Unknown result type (might be due to invalid IL or missing references)
			//IL_0555: Unknown result type (might be due to invalid IL or missing references)
			//IL_0420: Unknown result type (might be due to invalid IL or missing references)
			//IL_0425: Unknown result type (might be due to invalid IL or missing references)
			//IL_0589: 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_0573: Unknown result type (might be due to invalid IL or missing references)
			//IL_057d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0582: Unknown result type (might be due to invalid IL or missing references)
			//IL_046a: Unknown result type (might be due to invalid IL or missing references)
			//IL_046f: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_05da: Unknown result type (might be due to invalid IL or missing references)
			//IL_05df: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_05d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0608: Unknown result type (might be due to invalid IL or missing references)
			//IL_060d: Unknown result type (might be due to invalid IL or missing references)
			//IL_05f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_05fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0601: Unknown result type (might be due to invalid IL or missing references)
			//IL_063c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0646: Unknown result type (might be due to invalid IL or missing references)
			//IL_064b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0620: Unknown result type (might be due to invalid IL or missing references)
			//IL_062a: Unknown result type (might be due to invalid IL or missing references)
			//IL_062f: Unknown result type (might be due to invalid IL or missing references)
			teleportWorldData.OldColor = teleportWorldData.TargetColor;
			if (teleportWorldData.TargetColor == Gold)
			{
				try
				{
					Material material = MagicPortalFluid.originalMaterials["shaman_prupleball"];
					foreach (Renderer item in teleportWorldData.MeshRend)
					{
						item.material = material;
					}
				}
				catch
				{
				}
			}
			else if (teleportWorldData.TargetColor == Color.black)
			{
				try
				{
					Material material2 = MagicPortalFluid.originalMaterials["silver_necklace"];
					foreach (Renderer item2 in teleportWorldData.MeshRend)
					{
						item2.material = material2;
					}
				}
				catch
				{
				}
			}
			else
			{
				Material material3 = MagicPortalFluid.originalMaterials["portal_small"];
				foreach (Renderer item3 in teleportWorldData.MeshRend)
				{
					item3.material = material3;
				}
			}
			foreach (Light light in teleportWorldData.Lights)
			{
				light.color = teleportWorldData.TargetColor;
			}
			foreach (ParticleSystem suck in teleportWorldData.Sucks)
			{
				MainModule main = suck.main;
				if (teleportWorldData.TargetColor == Color.white)
				{
					((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(teleportWorldData.TargetColor);
					((MainModule)(ref main)).maxParticles = 1000;
				}
				else if (teleportWorldData.TargetColor == Orange)
				{
					((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(teleportWorldData.TargetColor);
					((MainModule)(ref main)).maxParticles = 1000;
				}
				else if (teleportWorldData.TargetColor == Color.black)
				{
					((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(Color.white);
					((MainModule)(ref main)).maxParticles = 1000;
				}
				else if (teleportWorldData.TargetColor == Yellow2)
				{
					((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(Yellow2);
					((MainModule)(ref main)).maxParticles = 1000;
				}
				else if (teleportWorldData.TargetColor == Cornsilk)
				{
					((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(Brown);
					((MainModule)(ref main)).maxParticles = 30;
				}
				else
				{
					((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(Color.black);
					((MainModule)(ref main)).maxParticles = 1000;
				}
			}
			foreach (ParticleSystem system in teleportWorldData.Systems)
			{
				ColorOverLifetimeModule colorOverLifetime = system.colorOverLifetime;
				((ColorOverLifetimeModule)(ref colorOverLifetime)).color = new MinMaxGradient(teleportWorldData.TargetColor, teleportWorldData.TargetColor);
				MainModule main2 = system.main;
				((MainModule)(ref main2)).startColor = MinMaxGradient.op_Implicit(teleportWorldData.TargetColor);
			}
			foreach (ParticleSystem blueFlame in teleportWorldData.BlueFlames)
			{
				ShapeModule shape = blueFlame.shape;
				_ = ((ShapeModule)(ref shape)).radius;
				Color val = teleportWorldData.TargetColor;
				if (teleportWorldData.TargetColor == Purple)
				{
					((Color)(ref val))..ctor(0.14509805f, 0f, 0.22745098f, 1f);
					((Component)blueFlame).GetComponent<Renderer>().material = MagicPortalFluid.originalMaterials["dragon_death_trail"];
				}
				else if (teleportWorldData.TargetColor == Gold)
				{
					((Component)blueFlame).GetComponent<Renderer>().material = MagicPortalFluid.originalMaterials["dragon_death_trail"];
				}
				else if (teleportWorldData.TargetColor == Cornsilk)
				{
					val = Brown;
					((Component)blueFlame).GetComponent<Renderer>().material = MagicPortalFluid.originalMaterials["teleport_suck"];
				}
				else if (teleportWorldData.TargetColor == Color.blue)
				{
					((Component)blueFlame).GetComponent<Renderer>().material = MagicPortalFluid.originalMaterials["flame"];
				}
				else if (teleportWorldData.TargetColor == Color.cyan)
				{
					((Component)blueFlame).GetComponent<Renderer>().material = MagicPortalFluid.originalMaterials["crystal_Dvergrcase"];
					((Color)(ref val))..ctor(26f / 85f, 41f / 51f, 0.76862746f, 1f);
				}
				else if (teleportWorldData.TargetColor == Color.white)
				{
					((Component)blueFlame).GetComponent<Renderer>().material = MagicPortalFluid.originalMaterials["teleport_suck"];
				}
				else
				{
					((Component)blueFlame).GetComponent<Renderer>().material = MagicPortalFluid.originalMaterials["portal_flame"];
				}
				ColorOverLifetimeModule colorOverLifetime2 = blueFlame.colorOverLifetime;
				((ColorOverLifetimeModule)(ref colorOverLifetime2)).color = MinMaxGradient.op_Implicit(val);
				_ = teleportWorldData.TargetColor == Color.yellow;
				MainModule main3 = blueFlame.main;
				((MainModule)(ref main3)).startColor = MinMaxGradient.op_Implicit(val);
				blueFlame.Clear();
				blueFlame.Simulate(0f);
				blueFlame.Play();
			}
			if (SetcolorTarget)
			{
				if (teleportWorldData.TargetColor == Color.black)
				{
					teleportWorldData.TeleportW.m_colorTargetfound = Color.black * 10f;
				}
				else if (teleportWorldData.TargetColor == Color.yellow)
				{
					teleportWorldData.TeleportW.m_colorTargetfound = m_colorTargetfound * 7f;
				}
				else if (teleportWorldData.TargetColor == Gold)
				{
					teleportWorldData.TeleportW.m_colorTargetfound = teleportWorldData.TargetColor;
				}
				else if (teleportWorldData.TargetColor == Cornsilk)
				{
					teleportWorldData.TeleportW.m_colorTargetfound = Brown * 3f;
				}
				else if (teleportWorldData.TargetColor == Color.cyan)
				{
					teleportWorldData.TeleportW.m_colorTargetfound = teleportWorldData.TargetColor * 4f;
				}
				else if (teleportWorldData.TargetColor == Color.blue)
				{
					teleportWorldData.TeleportW.m_colorTargetfound = teleportWorldData.TargetColor * 7f;
				}
				else
				{
					teleportWorldData.TeleportW.m_colorTargetfound = teleportWorldData.TargetColor * 7f;
				}
			}
		}

		private static bool TryGetTeleportWorld(TeleportWorld key, out TeleportWorldDataRMP value)
		{
			if (Object.op_Implicit((Object)(object)key))
			{
				return MagicPortalFluid._teleportWorldDataCache.TryGetValue(key, out value);
			}
			value = null;
			return false;
		}
	}
	public static class Extensions
	{
		public static T Next<T>(this T src) where T : struct
		{
			if (!typeof(T).IsEnum)
			{
				throw new ArgumentException($"Argument {typeof(T).FullName} is not an Enum");
			}
			T[] array = (T[])Enum.GetValues(src.GetType());
			int num = Array.IndexOf(array, src) + 1;
			if (array.Length != num)
			{
				return array[num];
			}
			return array[0];
		}
	}
	[<e143a9e8-dc1e-4f36-83b6-d4ffdfe8fbda>NullableContext(1)]
	[<f04ec549-5ca7-4107-a39d-53aadf15d38b>Nullable(0)]
	public class PortalLights
	{
		public List<Light> Lights { get; } = new List<Light>();


		public List<ParticleSystem> Systems { get; } = new List<ParticleSystem>();


		public List<ParticleSystemRenderer> Renderers { get; } = new List<ParticleSystemRenderer>();


		public Color TargetColor { get; set; } = Color.clear;


		public PortalLights(Fireplace fireplace)
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			ExtractFireplaceData(fireplace.m_enabledObject);
			ExtractFireplaceData(fireplace.m_enabledObjectHigh);
			ExtractFireplaceData(fireplace.m_enabledObjectLow);
		}

		private void ExtractFireplaceData(GameObject targetObject)
		{
			if (Object.op_Implicit((Object)(object)targetObject))
			{
				Lights.AddRange(targetObject.GetComponentsInChildren<Light>(true));
				Systems.AddRange(targetObject.GetComponentsInChildren<ParticleSystem>(true));
				Renderers.AddRange(targetObject.GetComponentsInChildren<ParticleSystemRenderer>(true));
			}
		}
	}
	[<f04ec549-5ca7-4107-a39d-53aadf15d38b>Nullable(0)]
	[<e143a9e8-dc1e-4f36-83b6-d4ffdfe8fbda>NullableContext(1)]
	internal class TeleportWorldDataRMP
	{
		public Color TargetColor = Color.clear;

		public Color LinkColor = Color.clear;

		public Color OldColor = Color.clear;

		public List<Light> Lights { get; } = new List<Light>();


		public List<ParticleSystem> Systems { get; } = new List<ParticleSystem>();


		public List<ParticleSystem> Sucks { get; } = new List<ParticleSystem>();


		public List<ParticleSystem> BlueFlames { get; } = new List<ParticleSystem>();


		public List<Material> Materials { get; } = new List<Material>();


		public string Biome { get; set; }

		public string BiomeColor { get; set; }

		public List<Renderer> MeshRend { get; } = new List<Renderer>();


		public string MaterialPortName { get; set; }

		public TeleportWorld TeleportW { get; }

		public TeleportWorldDataRMP(TeleportWorld teleportWorld)
		{
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			Lights.AddRange(teleportWorld.GetComponentsInNamedChild<Light>("Point light"));
			Systems.AddRange(teleportWorld.GetComponentsInNamedChild<ParticleSystem>("suck particles"));
			Systems.AddRange(teleportWorld.GetComponentsInNamedChild<ParticleSystem>("Particle System"));
			Sucks.AddRange(teleportWorld.GetComponentsInNamedChild<ParticleSystem>("Black_suck"));
			BlueFlames.AddRange(teleportWorld.GetComponentsInNamedChild<ParticleSystem>("blue flames"));
			Materials.AddRange(from psr in teleportWorld.GetComponentsInNamedChild<ParticleSystemRenderer>("blue flames")
				where (Object)(object)((Renderer)psr).material != (Object)null
				select ((Renderer)psr).material);
			MeshRend.AddRange(teleportWorld.GetComponentsInNamedChild<Renderer>("small_portal"));
			TeleportW = teleportWorld;
		}
	}
	internal static class TeleportWorldExtensionRMP
	{
		[<e143a9e8-dc1e-4f36-83b6-d4ffdfe8fbda>NullableContext(1)]
		public static IEnumerable<T> GetComponentsInNamedChild<[<f04ec549-5ca7-4107-a39d-53aadf15d38b>Nullable(2)] T>(this TeleportWorld teleportWorld, string childName)
		{
			return from transform in ((Component)teleportWorld).GetComponentsInChildren<Transform>(true)
				where ((Object)transform).name == childName
				select ((Component)transform).GetComponent<T>() into component
				where component != null
				select component;
		}
	}
	[<e143a9e8-dc1e-4f36-83b6-d4ffdfe8fbda>NullableContext(1)]
	[<f04ec549-5ca7-4107-a39d-53aadf15d38b>Nullable(0)]
	[BepInPlugin("WackyMole.RareMagicPortal", "RareMagicPortal", "2.7.2")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInIncompatibility("randyknapp.mods.advancedportals")]
	internal class MagicPortalFluid : BaseUnityPlugin
	{
		[HarmonyPatch(typeof(Game), "SpawnPlayer")]
		[<e143a9e8-dc1e-4f36-83b6-d4ffdfe8fbda>NullableContext(0)]
		public static class PlayerspawnExtarWait
		{
			private static void Postfix()
			{
			}
		}

		[HarmonyPriority(0)]
		[HarmonyPatch(typeof(ZNetScene), "Awake")]
		[<e143a9e8-dc1e-4f36-83b6-d4ffdfe8fbda>NullableContext(0)]
		private static class ZNetScene_Awake_PatchWRare
		{
			private static void Postfix()
			{
				Worldname = ZNet.instance.GetWorldName();
				TargetPortalLoaded = Chainloader.PluginInfos.ContainsKey("org.bepinex.plugins.targetportal");
				RareMagicPortal.LogInfo((object)"Setting MagicPortal Fluid Afterdelay");
				if (ZNet.instance.IsDedicated() && ZNet.instance.IsServer())
				{
					LoadIN();
				}
				else
				{
					functions.GetAllMaterials();
				}
			}
		}

		[HarmonyPatch(typeof(Game), "SpawnPlayer")]
		[<e143a9e8-dc1e-4f36-83b6-d4ffdfe8fbda>NullableContext(0)]
		internal static class Game_SpawnPreRMP
		{
			[HarmonyPrefix]
			internal static void Prefix()
			{
				LoadAllRecipeData(reload: true);
				LoadIN();
			}
		}

		[<e143a9e8-dc1e-4f36-83b6-d4ffdfe8fbda>NullableContext(0)]
		[HarmonyPatch(typeof(Game), "SpawnPlayer")]
		internal static class Game_OnNewCharacterDone_Patch
		{
			[HarmonyPostfix]
			internal static void Postfix()
			{
				JustWaitforInventory = false;
				StartingitemPrefab();
			}
		}

		[<e143a9e8-dc1e-4f36-83b6-d4ffdfe8fbda>NullableContext(0)]
		[HarmonyPatch(typeof(FejdStartup), "OnNewCharacterDone")]
		internal static class FejdStartup_OnNewCharacterDone_Patch
		{
			internal static void Postfix()
			{
				StartingFirsttime();
			}
		}

		[HarmonyPatch(typeof(TeleportWorld), "TargetFound")]
		[<e143a9e8-dc1e-4f36-83b6-d4ffdfe8fbda>NullableContext(0)]
		public static class DisabldHaveTarget
		{
			internal static bool Prefix(ref bool __result)
			{
				if ((Object)(object)Player.m_localPlayer == (Object)null)
				{
					return true;
				}
				if (((Character)Player.m_localPlayer).m_seman.HaveStatusEffect("yippeTele"))
				{
					__result = true;
					return false;
				}
				if (TargetPortalLoaded && !ConfigTargetPortalAnimation.Value)
				{
					__result = false;
					return false;
				}
				if (TargetPortalLoaded && ConfigTargetPortalAnimation.Value)
				{
					__result = true;
					return false;
				}
				return true;
			}
		}

		[HarmonyPatch(typeof(Minimap), "SetMapMode")]
		[<e143a9e8-dc1e-4f36-83b6-d4ffdfe8fbda>NullableContext(0)]
		public class LeavePortalModeOnMapCloseMagicPortal
		{
			internal static void Postfix(MapMode mode)
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				//IL_0002: Invalid comparison between Unknown and I4
				if ((int)mode != 2)
				{
					Teleporting = false;
				}
			}
		}

		[<e143a9e8-dc1e-4f36-83b6-d4ffdfe8fbda>NullableContext(0)]
		[HarmonyPatch(typeof(Inventory), "IsTeleportable")]
		public static class InventoryIsTeleportablePatchRMP
		{
			[HarmonyPriority(300)]
			[<e143a9e8-dc1e-4f36-83b6-d4ffdfe8fbda>NullableContext(1)]
			internal static bool Prefix(ref bool __result, ref Inventory __instance)
			{
				//IL_0046: Unknown result type (might be due to invalid IL or missing references)
				if (__instance == null || (Object)(object)Player.m_localPlayer == (Object)null)
				{
					return true;
				}
				if (JustWaitforInventory)
				{
					return true;
				}
				bool flag = false;
				bool flag2 = false;
				if (((Character)Player.m_localPlayer).m_seman.HaveStatusEffect("yippeTele"))
				{
					flag = true;
					flag2 = true;
				}
				string text = null;
				Vector3 position = ((Component)Player.m_localPlayer).transform.position;
				List<Piece> list = new List<Piece>();
				GetAllTheDamnPiecesinRadius(position, 5f, list);
				TeleportWorld val = null;
				using (List<Piece>.Enumerator enumerator = list.GetEnumerator())
				{
					while (enumerator.MoveNext() && !((Component)enumerator.Current).TryGetComponent<TeleportWorld>(ref val))
					{
					}
				}
				if ((Object)(object)val != (Object)null)
				{
					text = val.GetText();
					if (text != null)
					{
						string text2 = text;
						bool flag3 = false;
						string text3 = "";
						bool flag4 = false;
						if (Enumerable.Contains(text2, PortalColorLogic.NameIdentifier))
						{
							text2.Substring(text2.IndexOf(PortalColorLogic.NameIdentifier));
							string s = text2.Substring(text2.IndexOf(PortalColorLogic.NameIdentifier) + 1);
							text2 = text2[..text2.IndexOf(PortalColorLogic.NameIdentifier)];
							flag4 = true;
							text3 = ((PortalColorLogic.PortalColor)int.Parse(s)).ToString();
						}
						if (!PortalColorLogic.PortalN.Portals.ContainsKey(text2))
						{
							PortalColorLogic.WritetoYML(text2);
						}
						_ = PortalColorLogic.PortalN.Portals[text2].Admin_only_Access;
						_ = PortalColorLogic.PortalN.Portals[text2].Free_Passage;
						flag3 = PortalColorLogic.PortalN.Portals[text2].TeleportAnything;
						List<string> additionalProhibitItems = PortalColorLogic.PortalN.Portals[text2].AdditionalProhibitItems;
						List<string> allowedUsers = PortalColorLogic.PortalN.Portals[text2].AllowedUsers;
						if (allowedUsers.Count > 0)
						{
							bool flag5 = false;
							foreach (string item in allowedUsers)
							{
								if (item == Player.m_localPlayer.GetPlayerName())
								{
									flag5 = true;
								}
							}
							if (!flag5)
							{
								RareMagicPortal.LogInfo((object)("Player is not in the Allowed List for " + text2));
								((Character)Player.m_localPlayer).Message((MessageType)2, "Odin Deems " + Player.m_localPlayer.GetPlayerName() + " Not Worthy!", 0, (Sprite)null);
								__result = false;
								return false;
							}
						}
						if ((flag3 && !flag4) || text3 == TelePortAnythingColor.Value)
						{
							flag = true;
						}
						if (!flag && additionalProhibitItems.Count > 0)
						{
							ObjectDB instance = ObjectDB.instance;
							foreach (ItemData allItem in __instance.GetAllItems())
							{
								foreach (string item2 in additionalProhibitItems)
								{
									GameObject itemPrefab = instance.GetItemPrefab(item2);
									if ((Object)(object)itemPrefab != (Object)null)
									{
										ItemData itemData = itemPrefab.GetComponent<ItemDrop>().m_itemData;
										if (itemData != null && itemData.m_shared.m_name == allItem.m_shared.m_name)
										{
											RareMagicPortal.LogInfo((object)("Found Prohibited item " + itemData.m_shared.m_name + " Teleport Not Allowed"));
											((Character)Player.m_localPlayer).Message((MessageType)1, "Prohibited item " + itemData.m_shared.m_name, 0, (Sprite)null);
											__result = false;
											return false;
										}
									}
								}
							}
						}
						if (!flag && ConfigMaxWeight.Value > 0 && (TeleportingforWeight > 0 || Teleporting))
						{
							if (__instance.GetTotalWeight() > (float)ConfigMaxWeight.Value)
							{
								RareMagicPortal.LogInfo((object)"Player Weight is greater than Max Portal Weight");
								((Character)Player.m_localPlayer).Message((MessageType)2, "You are carrying too much, max is " + ConfigMaxWeight.Value, 0, (Sprite)null);
								TeleportingforWeight++;
								if (TeleportingforWeight > 10)
								{
									TeleportingforWeight = 0;
								}
								__result = false;
								return false;
							}
							TeleportingforWeight = 0;
						}
					}
				}
				if (flag)
				{
					if (PortalDrinkDenyloc.Count == 0 || !flag2)
					{
						__result = true;
						return false;
					}
					ObjectDB instance2 = ObjectDB.instance;
					foreach (ItemData allItem2 in __instance.GetAllItems())
					{
						foreach (string item3 in PortalDrinkDenyloc)
						{
							GameObject itemPrefab2 = instance2.GetItemPrefab(item3);
							if ((Object)(object)itemPrefab2 != (Object)null)
							{
								ItemData itemData2 = itemPrefab2.GetComponent<ItemDrop>().m_itemData;
								if (itemData2 != null && itemData2.m_shared.m_name == allItem2.m_shared.m_name)
								{
									RareMagicPortal.LogInfo((object)("Odin does not allow " + itemData2.m_shared.m_name + " even with Portal Drink"));
									((Character)Player.m_localPlayer).Message((MessageType)1, "Odin still doesn't allow " + itemData2.m_shared.m_name, 0, (Sprite)null);
									__result = false;
									return false;
								}
							}
						}
					}
					__result = true;
					return false;
				}
				return true;
			}
		}

		[HarmonyPatch(typeof(Minimap), "OnMapLeftClick")]
		[<e143a9e8-dc1e-4f36-83b6-d4ffdfe8fbda>NullableContext(0)]
		internal class MapLeftClickForRareMagic
		{
			internal class SkipPortalException2 : Exception
			{
			}

			[HarmonyPriority(500)]
			internal static bool Prefix()
			{
				if (!Teleporting)
				{
					return true;
				}
				if (!Chainloader.PluginInfos.ContainsKey("org.bepinex.plugins.targetportal"))
				{
					return true;
				}
				HoldPins = Minimap.instance.m_pins;
				string text;
				try
				{
					text = functions.HandlePortalClick();
				}
				catch
				{
					text = null;
				}
				if (text == null)
				{
					throw new SkipPortalException2();
				}
				if (!((Humanoid)Player.m_localPlayer).IsTeleportable())
				{
					((Character)Player.m_localPlayer).Message((MessageType)2, "$msg_noteleport", 0, (Sprite)null);
					return false;
				}
				if (PortalColorLogic.CrystalandKeyLogic(text))
				{
					return true;
				}
				throw new SkipPortalException2();
			}

			[<e143a9e8-dc1e-4f36-83b6-d4ffdfe8fbda>NullableContext(1)]
			[return: <f04ec549-5ca7-4107-a39d-53aadf15d38b>Nullable(2)]
			internal static Exception Finalizer(Exception __exception)
			{
				if (!(__exception is SkipPortalException2))
				{
					return __exception;
				}
				return null;
			}
		}

		[HarmonyPriority(200)]
		[HarmonyPatch(typeof(Minimap), "Start")]
		[<e143a9e8-dc1e-4f36-83b6-d4ffdfe8fbda>NullableContext(0)]
		public class AddMinimapPortalIconRMP
		{
			[<e143a9e8-dc1e-4f36-83b6-d4ffdfe8fbda>NullableContext(1)]
			internal static void Postfix(Minimap _