Decompiled source of RainbowPotions v1.2.0

RainbowPotions.dll

Decompiled 14 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using ExitGames.Client.Photon;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using Photon.Realtime;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace RainbowPotions
{
	internal static class InputCompat
	{
		private static bool _legacyBroken;

		private static bool _newInitTried;

		private static PropertyInfo _keyboardCurrent;

		private static PropertyInfo _keyboardIndexer;

		private static Type _keyEnum;

		public static bool GetKeyDown(KeyCode key)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			if ((int)key == 0)
			{
				return false;
			}
			if (!_legacyBroken)
			{
				try
				{
					return Input.GetKeyDown(key);
				}
				catch (InvalidOperationException)
				{
					_legacyBroken = true;
				}
			}
			return NewInputGetKeyDown(key);
		}

		private unsafe static bool NewInputGetKeyDown(KeyCode key)
		{
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Invalid comparison between Unknown and I4
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Invalid comparison between Unknown and I4
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Invalid comparison between Unknown and I4
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Invalid comparison between Unknown and I4
			try
			{
				if (!_newInitTried)
				{
					_newInitTried = true;
					Type type = Type.GetType("UnityEngine.InputSystem.Keyboard, Unity.InputSystem");
					_keyEnum = Type.GetType("UnityEngine.InputSystem.Key, Unity.InputSystem");
					if (type == null || _keyEnum == null)
					{
						Plugin.Log.LogError((object)"New Input System not found - the menu key cannot be detected.");
						return false;
					}
					_keyboardCurrent = type.GetProperty("current", BindingFlags.Static | BindingFlags.Public);
					_keyboardIndexer = type.GetProperty("Item", new Type[1] { _keyEnum });
				}
				if (_keyboardCurrent == null || _keyboardIndexer == null)
				{
					return false;
				}
				object value = _keyboardCurrent.GetValue(null, null);
				if (value == null)
				{
					return false;
				}
				string text = ((object)(*(KeyCode*)(&key))/*cast due to .constrained prefix*/).ToString();
				string value2 = (((int)key == 13) ? "Enter" : (((int)key == 271) ? "NumpadEnter" : (((int)key == 306) ? "LeftCtrl" : (((int)key == 305) ? "RightCtrl" : (text.StartsWith("Alpha") ? ("Digit" + text.Substring(5)) : (text.StartsWith("Keypad") ? ("Numpad" + text.Substring(6)) : text))))));
				if (!Enum.IsDefined(_keyEnum, value2))
				{
					return false;
				}
				object value3 = _keyboardIndexer.GetValue(value, new object[1] { Enum.Parse(_keyEnum, value2) });
				if (value3 == null)
				{
					return false;
				}
				PropertyInfo property = value3.GetType().GetProperty("wasPressedThisFrame");
				return property != null && (bool)property.GetValue(value3, null);
			}
			catch
			{
				return false;
			}
		}
	}
	internal struct BreakRecord
	{
		public Vector3 Position;

		public Color Color;

		public float Time;
	}
	internal static class BreakRecords
	{
		public static readonly List<BreakRecord> All = new List<BreakRecord>();

		public static void Add(Vector3 pos, Color color)
		{
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			All.RemoveAll((BreakRecord r) => Time.time - r.Time > 15f);
			All.Add(new BreakRecord
			{
				Position = pos,
				Color = color,
				Time = Time.time
			});
		}

		public static bool FindNear(Vector3 pos, float maxDistance, float maxAge, out BreakRecord found)
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			found = default(BreakRecord);
			float num = float.MaxValue;
			bool result = false;
			foreach (BreakRecord item in All)
			{
				if (!(Time.time - item.Time > maxAge))
				{
					float num2 = Vector3.Distance(item.Position, pos);
					if (num2 <= maxDistance && num2 < num)
					{
						num = num2;
						found = item;
						result = true;
					}
				}
			}
			return result;
		}
	}
	[HarmonyPatch(typeof(ValuableDirector), "SetupHost")]
	internal static class SpawnSetupPatch
	{
		internal static PrefabRef PotionRef;

		internal static int PotionCount;

		internal static readonly List<PrefabRef> Fillers = new List<PrefabRef>();

		private static bool _searched;

		private static readonly Dictionary<LevelValuables, int> Added = new Dictionary<LevelValuables, int>();

		private static bool IsPotion(PrefabRef r)
		{
			if (r != null && PotionRef != null)
			{
				return ((PrefabRef<GameObject>)(object)r).ResourcePath == ((PrefabRef<GameObject>)(object)PotionRef).ResourcePath;
			}
			return false;
		}

		private static void Prefix()
		{
			PotionCount = 0;
			Fillers.Clear();
			try
			{
				Level val = (((Object)(object)LevelGenerator.Instance != (Object)null) ? LevelGenerator.Instance.Level : null);
				if ((Object)(object)val == (Object)null || val.ValuablePresets == null || val.ValuablePresets.Count == 0 || FindPotionRef() == null)
				{
					return;
				}
				if (!Plugin.SpawnEverywhere.Value)
				{
					foreach (KeyValuePair<LevelValuables, int> item in new List<KeyValuePair<LevelValuables, int>>(Added))
					{
						for (int i = 0; i < item.Value; i++)
						{
							int num = item.Key.tiny.FindLastIndex(IsPotion);
							if (num >= 0)
							{
								item.Key.tiny.RemoveAt(num);
							}
						}
						Added.Remove(item.Key);
					}
					return;
				}
				bool flag = false;
				foreach (LevelValuables valuablePreset in val.ValuablePresets)
				{
					if ((Object)(object)valuablePreset == (Object)null)
					{
						continue;
					}
					if ((valuablePreset.tiny != null && valuablePreset.tiny.Exists(IsPotion)) || (valuablePreset.small != null && valuablePreset.small.Exists(IsPotion)))
					{
						flag = true;
					}
					if (valuablePreset.tiny == null)
					{
						continue;
					}
					foreach (PrefabRef item2 in valuablePreset.tiny)
					{
						if (item2 != null && ((PrefabRef<GameObject>)(object)item2).IsValid() && !IsPotion(item2))
						{
							Fillers.Add(item2);
						}
					}
				}
				if (!flag)
				{
					LevelValuables val2 = val.ValuablePresets.Find((LevelValuables p) => (Object)(object)p != (Object)null && p.tiny != null);
					if ((Object)(object)val2 != (Object)null)
					{
						val2.tiny.Add(PotionRef);
						Added.TryGetValue(val2, out var value);
						Added[val2] = value + 1;
						Plugin.Log.LogInfo((object)("Added the potion to the spawn list of '" + ((Object)val).name + "'."));
					}
				}
			}
			catch (Exception ex)
			{
				Plugin.Log.LogWarning((object)("Could not prepare potions for this map: " + ex.Message));
			}
		}

		internal static bool Matches(PrefabRef r)
		{
			return IsPotion(r);
		}

		internal static PrefabRef FindPotionRef()
		{
			if (PotionRef != null)
			{
				return PotionRef;
			}
			if (_searched || (Object)(object)RunManager.instance == (Object)null)
			{
				return null;
			}
			_searched = true;
			foreach (Level level in RunManager.instance.levels)
			{
				if ((Object)(object)level == (Object)null || level.ValuablePresets == null)
				{
					continue;
				}
				foreach (LevelValuables valuablePreset in level.ValuablePresets)
				{
					if ((Object)(object)valuablePreset == (Object)null)
					{
						continue;
					}
					List<PrefabRef> list = new List<PrefabRef>();
					List<PrefabRef>[] array = new List<PrefabRef>[7] { valuablePreset.tiny, valuablePreset.small, valuablePreset.medium, valuablePreset.big, valuablePreset.wide, valuablePreset.tall, valuablePreset.veryTall };
					foreach (List<PrefabRef> list2 in array)
					{
						if (list2 != null)
						{
							list.AddRange(list2);
						}
					}
					foreach (PrefabRef item in list)
					{
						if (item != null && ((PrefabRef<GameObject>)(object)item).IsValid() && ((PrefabRef<GameObject>)(object)item).PrefabName != null && ((PrefabRef<GameObject>)(object)item).PrefabName.IndexOf("potion", StringComparison.OrdinalIgnoreCase) >= 0)
						{
							GameObject prefab = ((PrefabRef<GameObject>)(object)item).Prefab;
							if ((Object)(object)prefab != (Object)null && (Object)(object)prefab.GetComponent<ValuableSmallPotion>() != (Object)null)
							{
								PotionRef = item;
								Plugin.Log.LogInfo((object)("Found the small potion prefab: " + ((PrefabRef<GameObject>)(object)item).ResourcePath));
								return PotionRef;
							}
						}
					}
				}
			}
			Plugin.Log.LogWarning((object)"Could not find the small potion prefab; potions will only spawn on maps that already have them.");
			return null;
		}
	}
	[HarmonyPatch(typeof(ValuableDirector), "SpawnValuable")]
	internal static class SpawnPotionPatch
	{
		private static void Postfix(ValuableObject __result, bool __state)
		{
			if (__state && (Object)(object)__result != (Object)null && (Object)(object)((Component)__result).GetComponent<OurPotion>() == (Object)null)
			{
				((Component)__result).gameObject.AddComponent<OurPotion>();
			}
		}

		private static void Prefix(ref PrefabRef _valuable, ValuableVolume _volume, out bool __state)
		{
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Invalid comparison between Unknown and I4
			__state = false;
			try
			{
				if (!Plugin.SpawnEverywhere.Value || SpawnSetupPatch.PotionRef == null || _valuable == null || (Object)(object)_volume == (Object)null)
				{
					return;
				}
				int value = Plugin.PotionsPerMap.Value;
				if (SpawnSetupPatch.Matches(_valuable))
				{
					if (SpawnSetupPatch.PotionCount < value)
					{
						SpawnSetupPatch.PotionCount++;
					}
					else if (SpawnSetupPatch.Fillers.Count > 0)
					{
						_valuable = SpawnSetupPatch.Fillers[Random.Range(0, SpawnSetupPatch.Fillers.Count)];
					}
					return;
				}
				Type volumeType = _volume.VolumeType;
				if (SpawnSetupPatch.PotionCount < value && ((int)volumeType == 0 || (int)volumeType == 1))
				{
					_valuable = SpawnSetupPatch.PotionRef;
					SpawnSetupPatch.PotionCount++;
					__state = true;
				}
			}
			catch (Exception ex)
			{
				Plugin.Log.LogDebug((object)("Potion spawn check failed: " + ex.Message));
			}
		}
	}
	[HarmonyPatch(typeof(ValuableObject), "Start")]
	internal static class PotionStartPatch
	{
		private static void Postfix(ValuableObject __instance)
		{
			if (!((Object)(object)__instance == (Object)null) && !((Object)(object)((Component)__instance).GetComponent<ValuableSmallPotion>() == (Object)null) && (Object)(object)((Component)__instance).GetComponent<PotionVisual>() == (Object)null)
			{
				((Component)__instance).gameObject.AddComponent<PotionVisual>();
			}
		}
	}
	[HarmonyPatch(typeof(ValuableSmallPotion), "PotionBreak")]
	internal static class PotionBreakPatch
	{
		private static readonly FieldInfo IsDisabled = AccessTools.Field(typeof(PlayerAvatar), "isDisabled");

		private static readonly FieldInfo MaxHealthField = AccessTools.Field(typeof(PlayerHealth), "maxHealth");

		private static int MaxHealth(PlayerAvatar p)
		{
			try
			{
				return (int)MaxHealthField.GetValue(p.playerHealth);
			}
			catch
			{
				return 100;
			}
		}

		private static bool Disabled(PlayerAvatar p)
		{
			try
			{
				return IsDisabled != null && (bool)IsDisabled.GetValue(p);
			}
			catch
			{
				return false;
			}
		}

		private static void Prefix(ValuableSmallPotion __instance)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)__instance == (Object)null)
			{
				return;
			}
			int num = Plugin.TypeIndexOf(((Component)__instance).gameObject);
			Vector3 position = ((Component)__instance).transform.position;
			if (Plugin.FeatureActive)
			{
				BreakRecords.Add(position, PotionTypes.ColorOf(num));
			}
			if (!SemiFunc.IsMasterClientOrSingleplayer())
			{
				return;
			}
			PlayerAvatar val = null;
			float num2 = Plugin.AffectRadius.Value;
			foreach (PlayerAvatar item in SemiFunc.PlayerGetAll())
			{
				if (!((Object)(object)item == (Object)null) && !Disabled(item))
				{
					float num3 = Vector3.Distance(((Component)item).transform.position, position);
					if (num3 <= num2)
					{
						num2 = num3;
						val = item;
					}
				}
			}
			if (Plugin.HealEnabled.Value)
			{
				float num4 = (float)Plugin.HealPercent.Value / 100f;
				__instance.healthPool = Mathf.CeilToInt((float)(((Object)(object)val != (Object)null) ? MaxHealth(val) : 100) * num4);
			}
			else
			{
				__instance.healthPool = 0;
			}
			if ((Object)(object)val != (Object)null)
			{
				Plugin.GiveUpgrade(val, num, Plugin.UpgradeAmount.Value);
				Plugin.Log.LogInfo((object)$"Potion '{PotionTypes.All[num].Name}' broke on {SemiFunc.PlayerGetSteamID(val)}: +{Plugin.UpgradeAmount.Value}, heal pool {__instance.healthPool}.");
			}
			else
			{
				Plugin.Log.LogInfo((object)("Potion '" + PotionTypes.All[num].Name + "' broke, nobody close enough for the upgrade."));
			}
		}
	}
	[HarmonyPatch(typeof(EnemyTickHealAura), "Awake")]
	internal static class AuraAwakePatch
	{
		private static void Postfix(EnemyTickHealAura __instance)
		{
			if ((Object)(object)__instance != (Object)null && Plugin.FeatureActive)
			{
				AuraTinter.Register(__instance);
			}
		}
	}
	internal static class AuraTinter
	{
		private struct Pending
		{
			public EnemyTickHealAura Aura;

			public float Since;
		}

		private static readonly List<Pending> Waiting = new List<Pending>();

		public static void Register(EnemyTickHealAura aura)
		{
			Waiting.Add(new Pending
			{
				Aura = aura,
				Since = Time.time
			});
		}

		public static void Tick()
		{
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			for (int num = Waiting.Count - 1; num >= 0; num--)
			{
				Pending pending = Waiting[num];
				BreakRecord found;
				if ((Object)(object)pending.Aura == (Object)null || Time.time - pending.Since > 4f)
				{
					Waiting.RemoveAt(num);
				}
				else if (BreakRecords.FindNear(((Component)pending.Aura).transform.position, 2.5f, 10f, out found))
				{
					Retint.Hierarchy(((Component)pending.Aura).gameObject, found.Color);
					Waiting.RemoveAt(num);
				}
			}
		}
	}
	[HarmonyPatch]
	internal static class HealGlitchPatch
	{
		[HarmonyPatch(typeof(CameraGlitch), "PlayShortHeal")]
		[HarmonyPostfix]
		private static void Short()
		{
			Apply();
		}

		[HarmonyPatch(typeof(CameraGlitch), "PlayLongHeal")]
		[HarmonyPostfix]
		private static void Long()
		{
			Apply();
		}

		private static void Apply()
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			if (!Plugin.FeatureActive || (Object)(object)CameraGlitch.Instance == (Object)null)
			{
				return;
			}
			PlayerAvatar val = SemiFunc.PlayerAvatarLocal();
			if (!((Object)(object)val == (Object)null) && BreakRecords.FindNear(((Component)val).transform.position, Plugin.AffectRadius.Value + 6f, 8f, out var found))
			{
				HealOverlayTint healOverlayTint = ((Component)CameraGlitch.Instance).GetComponent<HealOverlayTint>();
				if ((Object)(object)healOverlayTint == (Object)null)
				{
					healOverlayTint = ((Component)CameraGlitch.Instance).gameObject.AddComponent<HealOverlayTint>();
				}
				healOverlayTint.Begin(found.Color, 2.5f);
			}
		}
	}
	internal class HealOverlayTint : MonoBehaviour
	{
		private Color _target;

		private float _until;

		public void Begin(Color target, float seconds)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			_target = target;
			_until = Time.time + seconds;
		}

		private void LateUpdate()
		{
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			if (!(Time.time > _until) && !((Object)(object)CameraGlitch.Instance == (Object)null))
			{
				Retint.ShiftLive(((Object)(object)CameraGlitch.Instance.ActiveParent != (Object)null) ? CameraGlitch.Instance.ActiveParent : ((Component)CameraGlitch.Instance).gameObject, _target);
			}
		}
	}
	[BepInPlugin("Rehaan.RainbowPotions", "RainbowPotions", "1.2.0")]
	public class Plugin : BaseUnityPlugin
	{
		public const string PluginGuid = "Rehaan.RainbowPotions";

		public const string PluginName = "RainbowPotions";

		public const string PluginVersion = "1.2.0";

		internal const string RoomKey = "RainbowPotions.Host";

		internal static ManualLogSource Log;

		internal static Plugin Instance;

		internal static ConfigEntry<bool> HealEnabled;

		internal static ConfigEntry<int> HealPercent;

		internal static ConfigEntry<int> UpgradeAmount;

		internal static ConfigEntry<float> AffectRadius;

		internal static ConfigEntry<bool> SpawnEverywhere;

		internal static ConfigEntry<int> PotionsPerMap;

		internal static ConfigEntry<bool> NoDamage;

		internal static ConfigEntry<KeyCode> MenuKey;

		internal static ConfigEntry<bool> UseShopColors;

		internal static ConfigEntry<bool> HintsEnabled;

		internal static ConfigEntry<float> HintInterval;

		internal static ConfigEntry<bool> LogMaterials;

		private float _roomTimer;

		private static float _saveAt = -1f;

		private static readonly string[] RpcNames = new string[13]
		{
			"Health", "Stamina", "ExtraJump", "MapPlayerCount", "Launch", "TumbleClimb", "DeathHeadBattery", "TumbleWings", "Speed", "CrouchRest",
			"Strength", "Throw", "Range"
		};

		internal static bool FeatureActive
		{
			get
			{
				try
				{
					if ((Object)(object)GameManager.instance == (Object)null || !SemiFunc.IsMultiplayer())
					{
						return true;
					}
					if (!PhotonNetwork.InRoom || PhotonNetwork.CurrentRoom == null || PhotonNetwork.MasterClient == null)
					{
						return false;
					}
					object value;
					return ((Dictionary<object, object>)(object)((RoomInfo)PhotonNetwork.CurrentRoom).CustomProperties).TryGetValue((object)"RainbowPotions.Host", out value) && value is int num && num == PhotonNetwork.MasterClient.ActorNumber;
				}
				catch
				{
					return false;
				}
			}
		}

		private void Awake()
		{
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Expected O, but got Unknown
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Expected O, but got Unknown
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Expected O, but got Unknown
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Expected O, but got Unknown
			//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e0: Expected O, but got Unknown
			//IL_0222: Unknown result type (might be due to invalid IL or missing references)
			Log = ((BaseUnityPlugin)this).Logger;
			Instance = this;
			HealEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Host", "Heal Enabled", true, "When a potion breaks it still heals players nearby (on top of the upgrade).");
			HealPercent = ((BaseUnityPlugin)this).Config.Bind<int>("Host", "Heal Percent", 50, new ConfigDescription("How much of a player's max HP a broken potion heals (in percent).", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>()));
			UpgradeAmount = ((BaseUnityPlugin)this).Config.Bind<int>("Host", "Upgrade Amount", 1, new ConfigDescription("How many upgrade levels a broken potion gives.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 5), Array.Empty<object>()));
			AffectRadius = ((BaseUnityPlugin)this).Config.Bind<float>("Host", "Affect Radius", 3f, new ConfigDescription("Players within this many meters of the breaking potion get the upgrade and heal.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 10f), Array.Empty<object>()));
			SpawnEverywhere = ((BaseUnityPlugin)this).Config.Bind<bool>("Host", "Potions On Every Map", true, "Potions normally only spawn on the Wizard map. Turn this on to let them spawn on every map.");
			PotionsPerMap = ((BaseUnityPlugin)this).Config.Bind<int>("Host", "Potions Per Map", 5, new ConfigDescription("How many potions lie on a map (up to this number, depending on the free spots). Max 20.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 20), Array.Empty<object>()));
			NoDamage = ((BaseUnityPlugin)this).Config.Bind<bool>("Host", "No Damage From Potions", true, "A potion that breaks on a player does no damage.");
			MenuKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("General", "Menu Key", (KeyCode)292, "Key that opens the Rainbow Potions settings menu.");
			UseShopColors = ((BaseUnityPlugin)this).Config.Bind<bool>("Visuals", "Use Shop Upgrade Colors", true, "Use the exact colors of the upgrades in the shop. If off (or unusable) a built-in palette is used.");
			HintsEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Visuals", "Hints Enabled", true, "Your character mumbles hints about the potion you are holding.");
			HintInterval = ((BaseUnityPlugin)this).Config.Bind<float>("Visuals", "Hint Interval", 8f, new ConfigDescription("Seconds between hints while holding a potion.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(3f, 30f), Array.Empty<object>()));
			LogMaterials = ((BaseUnityPlugin)this).Config.Bind<bool>("Debug", "Log Potion Materials", false, "Writes the potion's materials to the BepInEx log (helps with troubleshooting colors).");
			((BaseUnityPlugin)this).Config.SaveOnConfigSet = false;
			((Component)this).gameObject.AddComponent<SettingsMenu>();
			new Harmony("Rehaan.RainbowPotions").PatchAll(typeof(Plugin).Assembly);
			Log.LogInfo((object)"RainbowPotions 1.2.0 loaded.");
		}

		private void Update()
		{
			HostMarkerTick();
			AuraTinter.Tick();
			PotionRuntime.Tick();
			if (_saveAt > 0f && Time.unscaledTime - _saveAt > 1f)
			{
				SaveConfig();
			}
		}

		internal static void SaveSoon()
		{
			_saveAt = Time.unscaledTime;
		}

		internal static void SaveConfig()
		{
			_saveAt = -1f;
			try
			{
				((BaseUnityPlugin)Instance).Config.Save();
			}
			catch (Exception ex)
			{
				Log.LogDebug((object)("Config save failed: " + ex.Message));
			}
		}

		internal static void ResetAll()
		{
			foreach (ConfigDefinition key in ((BaseUnityPlugin)Instance).Config.Keys)
			{
				if (!(key.Key == ((ConfigEntryBase)MenuKey).Definition.Key))
				{
					ConfigEntryBase obj = ((BaseUnityPlugin)Instance).Config[key];
					obj.BoxedValue = obj.DefaultValue;
				}
			}
		}

		private void HostMarkerTick()
		{
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Expected O, but got Unknown
			//IL_009c: Expected O, but got Unknown
			_roomTimer -= Time.unscaledDeltaTime;
			if (_roomTimer > 0f)
			{
				return;
			}
			_roomTimer = 2f;
			try
			{
				if (PhotonNetwork.InRoom && PhotonNetwork.IsMasterClient && PhotonNetwork.CurrentRoom != null)
				{
					int actorNumber = PhotonNetwork.LocalPlayer.ActorNumber;
					if (!((Dictionary<object, object>)(object)((RoomInfo)PhotonNetwork.CurrentRoom).CustomProperties).TryGetValue((object)"RainbowPotions.Host", out object value) || !(value is int num) || num != actorNumber)
					{
						Room currentRoom = PhotonNetwork.CurrentRoom;
						Hashtable val = new Hashtable();
						((Dictionary<object, object>)val).Add((object)"RainbowPotions.Host", (object)actorNumber);
						currentRoom.SetCustomProperties(val, (Hashtable)null, (WebFlags)null);
					}
				}
			}
			catch (Exception ex)
			{
				Log.LogDebug((object)("Room marker failed: " + ex.Message));
			}
		}

		internal static int TypeIndexOf(GameObject potion)
		{
			int num = 0;
			PhotonView component = potion.GetComponent<PhotonView>();
			if ((Object)(object)component != (Object)null)
			{
				num = component.ViewID;
			}
			if (num <= 0)
			{
				num = ((Object)potion).GetInstanceID();
			}
			return PotionTypes.IndexFor(num);
		}

		internal static void GiveUpgrade(PlayerAvatar player, int typeIndex, int amount)
		{
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)player == (Object)null || (Object)(object)PunManager.instance == (Object)null)
			{
				return;
			}
			string text = SemiFunc.PlayerGetSteamID(player);
			string text2 = RpcNames[typeIndex];
			if (SemiFunc.IsMultiplayer())
			{
				PhotonView component = ((Component)PunManager.instance).GetComponent<PhotonView>();
				if ((Object)(object)component == (Object)null)
				{
					Log.LogWarning((object)"PunManager has no PhotonView, cannot send upgrade.");
					return;
				}
				component.RPC("TesterUpgradeCommandRPC", (RpcTarget)0, new object[3] { text, text2, amount });
			}
			else
			{
				PunManager.instance.TesterUpgradeCommandRPC(text, text2, amount, default(PhotonMessageInfo));
			}
			try
			{
				player.playerHealth.MaterialEffectOverride((Effect)0);
			}
			catch
			{
			}
		}
	}
	internal class OurPotion : MonoBehaviour
	{
	}
	internal static class PotionRuntime
	{
		private static bool _baselineSet;

		private static bool _lastEverywhere;

		private static int _lastCount;

		private static float _changedAt = -1f;

		private static bool InLevel()
		{
			if (SemiFunc.RunIsLevel() && (Object)(object)LevelGenerator.Instance != (Object)null)
			{
				return LevelGenerator.Instance.Generated;
			}
			return false;
		}

		internal static void Tick()
		{
			if (!SemiFunc.IsMasterClientOrSingleplayer() || !InLevel())
			{
				_baselineSet = false;
				return;
			}
			bool value = Plugin.SpawnEverywhere.Value;
			int value2 = Plugin.PotionsPerMap.Value;
			if (!_baselineSet)
			{
				_baselineSet = true;
				_lastEverywhere = value;
				_lastCount = value2;
				_changedAt = -1f;
				return;
			}
			if (value != _lastEverywhere || value2 != _lastCount)
			{
				_lastEverywhere = value;
				_lastCount = value2;
				_changedAt = Time.unscaledTime;
			}
			if (!(_changedAt > 0f) || !(Time.unscaledTime - _changedAt > 0.5f))
			{
				return;
			}
			_changedAt = -1f;
			try
			{
				Reconcile();
			}
			catch (Exception ex)
			{
				Plugin.Log.LogWarning((object)("Could not update potions: " + ex.Message));
			}
		}

		private static List<ValuableSmallPotion> CurrentPotions()
		{
			List<ValuableSmallPotion> list = new List<ValuableSmallPotion>();
			ValuableSmallPotion[] array = Object.FindObjectsByType<ValuableSmallPotion>((FindObjectsSortMode)0);
			foreach (ValuableSmallPotion val in array)
			{
				if ((Object)(object)val != (Object)null && ((Component)val).gameObject.activeInHierarchy)
				{
					list.Add(val);
				}
			}
			return list;
		}

		private static void Reconcile()
		{
			List<ValuableSmallPotion> list = CurrentPotions();
			if (!Plugin.SpawnEverywhere.Value)
			{
				int num = 0;
				foreach (ValuableSmallPotion item in list)
				{
					if ((Object)(object)((Component)item).GetComponent<OurPotion>() != (Object)null && Remove(item))
					{
						num++;
					}
				}
				Plugin.Log.LogInfo((object)$"Potions on every map turned off: removed {num} added potion(s).");
				return;
			}
			int value = Plugin.PotionsPerMap.Value;
			int count = list.Count;
			if (count > value)
			{
				list.Sort((ValuableSmallPotion a, ValuableSmallPotion b) => (((Object)(object)((Component)b).GetComponent<OurPotion>() != (Object)null) ? 1 : 0).CompareTo(((Object)(object)((Component)a).GetComponent<OurPotion>() != (Object)null) ? 1 : 0));
				int num2 = 0;
				foreach (ValuableSmallPotion item2 in list)
				{
					if (count - num2 <= value)
					{
						break;
					}
					if (Remove(item2))
					{
						num2++;
					}
				}
				Plugin.Log.LogInfo((object)$"Potions per map set to {value}: removed {num2}.");
			}
			else if (count < value)
			{
				int num3 = SpawnMore(value - count);
				Plugin.Log.LogInfo((object)$"Potions per map set to {value}: spawned {num3} (wanted {value - count}).");
			}
		}

		private static bool IsHeld(ValuableSmallPotion p)
		{
			PhysGrabObject component = ((Component)p).GetComponent<PhysGrabObject>();
			if ((Object)(object)component != (Object)null)
			{
				return component.grabbed;
			}
			return false;
		}

		private static bool Remove(ValuableSmallPotion p)
		{
			if ((Object)(object)p == (Object)null || IsHeld(p))
			{
				return false;
			}
			if (SemiFunc.IsMultiplayer())
			{
				PhotonNetwork.Destroy(((Component)p).gameObject);
			}
			else
			{
				Object.Destroy((Object)(object)((Component)p).gameObject);
			}
			return true;
		}

		private static int SpawnMore(int wanted)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Invalid comparison between Unknown and I4
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			PrefabRef val = SpawnSetupPatch.FindPotionRef();
			if (val == null)
			{
				return 0;
			}
			List<ValuableVolume> list = new List<ValuableVolume>();
			int num = LayerMask.op_Implicit(SemiFunc.LayerMaskGetPhysGrabObject());
			ValuableVolume[] array = Object.FindObjectsByType<ValuableVolume>((FindObjectsSortMode)0);
			foreach (ValuableVolume val2 in array)
			{
				if (!((Object)(object)val2 == (Object)null) && ((Behaviour)val2).isActiveAndEnabled && ((int)val2.VolumeType == 0 || (int)val2.VolumeType == 1) && val2.OverlapBoxCheck(LayerMask.op_Implicit(num)).Length == 0)
				{
					list.Add(val2);
				}
			}
			for (int num2 = list.Count - 1; num2 > 0; num2--)
			{
				int index = Random.Range(0, num2 + 1);
				ValuableVolume value = list[num2];
				list[num2] = list[index];
				list[index] = value;
			}
			int num3 = 0;
			foreach (ValuableVolume item in list)
			{
				if (num3 >= wanted)
				{
					break;
				}
				GameObject val3 = (SemiFunc.IsMultiplayer() ? PhotonNetwork.InstantiateRoomObject(((PrefabRef<GameObject>)(object)val).ResourcePath, ((Component)item).transform.position, ((Component)item).transform.rotation, (byte)0, (object[])null) : Object.Instantiate<GameObject>(((PrefabRef<GameObject>)(object)val).Prefab, ((Component)item).transform.position, ((Component)item).transform.rotation));
				if (!((Object)(object)val3 == (Object)null))
				{
					ValuableObject component = val3.GetComponent<ValuableObject>();
					if ((Object)(object)component != (Object)null)
					{
						component.DollarValueSetLogic();
					}
					val3.AddComponent<OurPotion>();
					num3++;
				}
			}
			return num3;
		}
	}
	internal enum UpgradeKind
	{
		Health,
		Stamina,
		ExtraJump,
		MapPlayerCount,
		TumbleLaunch,
		TumbleClimb,
		DeathHeadBattery,
		TumbleWings,
		SprintSpeed,
		CrouchRest,
		GrabStrength,
		ThrowStrength,
		GrabRange
	}
	internal sealed class PotionType
	{
		public UpgradeKind Kind;

		public string Name;

		public string[] ItemTokens;

		public Color Fallback;

		public string[] Hints;
	}
	internal static class PotionTypes
	{
		public static readonly PotionType[] All = Build();

		private static Color[] _colors;

		private static int _colorsBuiltForItemCount = -1;

		private static bool _builtWithShop;

		public static int Count => All.Length;

		private static Color C(int r, int g, int b)
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			return new Color((float)r / 255f, (float)g / 255f, (float)b / 255f, 1f);
		}

		private static PotionType[] Build()
		{
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: 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_01ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_0230: Unknown result type (might be due to invalid IL or missing references)
			//IL_0235: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ad: 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_0328: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0421: Unknown result type (might be due to invalid IL or missing references)
			//IL_0426: Unknown result type (might be due to invalid IL or missing references)
			//IL_049e: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_051b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0520: Unknown result type (might be due to invalid IL or missing references)
			//IL_0598: Unknown result type (might be due to invalid IL or missing references)
			//IL_059d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0618: Unknown result type (might be due to invalid IL or missing references)
			//IL_061d: Unknown result type (might be due to invalid IL or missing references)
			return new PotionType[13]
			{
				new PotionType
				{
					Kind = UpgradeKind.Health,
					Name = "Health",
					ItemTokens = new string[1] { "health" },
					Fallback = C(70, 220, 90),
					Hints = new string[4] { "It smells like warm soup and fresh band-aids.", "My heart feels... extra roomy in here?", "Holding this feels like a big hug from the inside.", "I feel strangely hard to break." }
				},
				new PotionType
				{
					Kind = UpgradeKind.Stamina,
					Name = "Stamina",
					ItemTokens = new string[2] { "energy", "stamina" },
					Fallback = C(255, 215, 40),
					Hints = new string[4] { "It fizzes like an ice cold energy drink.", "My lungs feel tingly. Like they want more air.", "I could run a marathon just by looking at this.", "Why do I not feel tired anymore? I have not even drunk it!" }
				},
				new PotionType
				{
					Kind = UpgradeKind.ExtraJump,
					Name = "Extra Jump",
					ItemTokens = new string[2] { "extrajump", "jump" },
					Fallback = C(40, 230, 230),
					Hints = new string[4] { "It keeps bouncing... even when it sits still.", "My shoes feel springy. Boing boing.", "The ground suddenly feels very optional.", "I want to jump again. In the air. Twice." }
				},
				new PotionType
				{
					Kind = UpgradeKind.MapPlayerCount,
					Name = "Map Player Count",
					ItemTokens = new string[3] { "mapplayercount", "mapplayer", "playercount" },
					Fallback = C(70, 120, 255),
					Hints = new string[4] { "It whispers the names of my friends.", "I feel like I am counting heads in my sleep.", "Everyone feels a little closer. Even the ones far away.", "My brain is drawing tiny dots on an imaginary paper." }
				},
				new PotionType
				{
					Kind = UpgradeKind.TumbleLaunch,
					Name = "Tumble Launch",
					ItemTokens = new string[2] { "tumblelaunch", "launch" },
					Fallback = C(255, 140, 40),
					Hints = new string[4] { "It wants to send me into orbit. Politely.", "I feel like a bowling ball with big dreams.", "Something here makes me want to roll... fast. Very fast.", "Tumbling sounds like a great idea right now." }
				},
				new PotionType
				{
					Kind = UpgradeKind.TumbleClimb,
					Name = "Tumble Climb",
					ItemTokens = new string[2] { "tumbleclimb", "climb" },
					Fallback = C(175, 120, 55),
					Hints = new string[4] { "It is sticky. Like it grips on to things.", "I get a sudden urge to climb the ceiling.", "My fingers feel like tiny suction cups.", "Walls look more like ladders now." }
				},
				new PotionType
				{
					Kind = UpgradeKind.DeathHeadBattery,
					Name = "Death Head Battery",
					ItemTokens = new string[2] { "deathhead", "headbattery" },
					Fallback = C(160, 80, 235),
					Hints = new string[4] { "It smells like a spooky battery. Bzzzt.", "I hear a skull giggling somewhere.", "Even the dead would love a sip of this.", "It hums a tune only ghosts can hear." }
				},
				new PotionType
				{
					Kind = UpgradeKind.TumbleWings,
					Name = "Tumble Wings",
					ItemTokens = new string[2] { "tumblewings", "wings" },
					Fallback = C(255, 175, 225),
					Hints = new string[4] { "I feel feathers. Why do I feel feathers?", "Flappy. It feels very, very flappy.", "My back itches in two exact places.", "Gravity feels like more of a suggestion." }
				},
				new PotionType
				{
					Kind = UpgradeKind.SprintSpeed,
					Name = "Sprint Speed",
					ItemTokens = new string[3] { "sprintspeed", "speed", "sprint" },
					Fallback = C(240, 55, 55),
					Hints = new string[4] { "It smells like fresh sneakers on a wet floor.", "Gotta go fast. I do not know why.", "My legs are shaking. They want to run.", "Everything looks like a finish line." }
				},
				new PotionType
				{
					Kind = UpgradeKind.CrouchRest,
					Name = "Crouch Rest",
					ItemTokens = new string[2] { "crouchrest", "crouch" },
					Fallback = C(50, 190, 150),
					Hints = new string[4] { "Cozy. It feels like a nap on the floor.", "Why do I want to curl up in a tiny ball?", "This potion would make a great pillow.", "My knees say: sit down and relax a little." }
				},
				new PotionType
				{
					Kind = UpgradeKind.GrabStrength,
					Name = "Grab Strength",
					ItemTokens = new string[2] { "grabstrength", "strength" },
					Fallback = C(230, 55, 200),
					Hints = new string[4] { "Squeezing this makes my fists tingle.", "It feels like lifting a mountain with two fingers.", "My grip feels like a crab with a grudge.", "Heavy things look a lot lighter now." }
				},
				new PotionType
				{
					Kind = UpgradeKind.ThrowStrength,
					Name = "Throw Strength",
					ItemTokens = new string[2] { "grabthrow", "throw" },
					Fallback = C(205, 255, 55),
					Hints = new string[4] { "My arm itches. It really wants to throw something.", "I want to yeet things. Far. Very far.", "Everything around me looks throwable.", "I feel like a pitcher in the final inning." }
				},
				new PotionType
				{
					Kind = UpgradeKind.GrabRange,
					Name = "Grab Range",
					ItemTokens = new string[2] { "grabrange", "range" },
					Fallback = C(150, 160, 255),
					Hints = new string[4] { "My arms feel... longer?", "I can almost touch stuff from way over there.", "Things look so close now, even the far ones.", "My hands have started stretching on their own." }
				}
			};
		}

		public static int IndexFor(int stableId)
		{
			int num = stableId * -1640531535;
			return (int)((uint)(num ^ (num >>> 15)) % (uint)Count);
		}

		public static Color ColorOf(int index)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			EnsureColors();
			return _colors[index];
		}

		private static void EnsureColors()
		{
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_025b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0260: Unknown result type (might be due to invalid IL or missing references)
			//IL_0242: Unknown result type (might be due to invalid IL or missing references)
			//IL_0247: 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_0196: Unknown result type (might be due to invalid IL or missing references)
			int num = -1;
			try
			{
				num = (((Object)(object)StatsManager.instance != (Object)null) ? StatsManager.instance.itemDictionary.Count : 0);
			}
			catch
			{
			}
			if (_colors != null && _colorsBuiltForItemCount == num && _builtWithShop == Plugin.UseShopColors.Value)
			{
				return;
			}
			_builtWithShop = Plugin.UseShopColors.Value;
			Color[] array = (Color[])(object)new Color[Count];
			for (int i = 0; i < Count; i++)
			{
				array[i] = All[i].Fallback;
			}
			bool flag = false;
			if (Plugin.UseShopColors.Value && num > 0)
			{
				Color?[] array2 = new Color?[Count];
				try
				{
					foreach (KeyValuePair<string, Item> item in StatsManager.instance.itemDictionary)
					{
						Item value = item.Value;
						if ((Object)(object)value == (Object)null || (Object)(object)value.colorPreset == (Object)null)
						{
							continue;
						}
						string text = (item.Key ?? ((Object)value).name ?? "").ToLowerInvariant().Replace(" ", "").Replace("_", "")
							.Replace("-", "");
						if (!text.Contains("upgrade"))
						{
							continue;
						}
						for (int j = 0; j < Count; j++)
						{
							if (array2[j].HasValue)
							{
								continue;
							}
							string[] itemTokens = All[j].ItemTokens;
							foreach (string value2 in itemTokens)
							{
								if (text.Contains(value2))
								{
									array2[j] = value.colorPreset.GetColorMain();
									break;
								}
							}
							if (array2[j].HasValue)
							{
								break;
							}
						}
					}
				}
				catch (Exception ex)
				{
					Plugin.Log.LogWarning((object)("Could not read shop upgrade colors: " + ex.Message));
				}
				Color[] array3 = (Color[])(object)new Color[Count];
				int num2 = 0;
				for (int l = 0; l < Count; l++)
				{
					if (array2[l].HasValue)
					{
						array3[l] = array2[l].Value;
						num2++;
					}
					else
					{
						array3[l] = array[l];
					}
				}
				if (num2 > 0 && AreDistinct(array3))
				{
					array = array3;
					flag = true;
					Plugin.Log.LogInfo((object)$"Using shop upgrade colors ({num2}/{Count} matched).");
				}
				else
				{
					Plugin.Log.LogInfo((object)$"Shop upgrade colors not usable (matched {num2}/{Count}, distinct={AreDistinct(array3)}). Using built-in palette.");
				}
			}
			if (!flag && num <= 0)
			{
				_colors = array;
				_colorsBuiltForItemCount = num;
				return;
			}
			_colors = array;
			_colorsBuiltForItemCount = num;
			for (int m = 0; m < Count; m++)
			{
				Plugin.Log.LogInfo((object)("  potion color " + All[m].Name + ": " + ColorUtility.ToHtmlStringRGB(array[m])));
			}
		}

		private static bool AreDistinct(Color[] c)
		{
			for (int i = 0; i < c.Length; i++)
			{
				for (int j = i + 1; j < c.Length; j++)
				{
					float num = c[i].r - c[j].r;
					float num2 = c[i].g - c[j].g;
					float num3 = c[i].b - c[j].b;
					if (Mathf.Sqrt(num * num + num2 * num2 + num3 * num3) < 0.12f)
					{
						return false;
					}
				}
			}
			return true;
		}
	}
	internal class PotionVisual : MonoBehaviour
	{
		private static readonly string[] Intros = new string[4] { "Oooooh, what does this potion do?", "Hmm... what does this potion do?", "Ooooh, shiny. What does this one do?", "Wait, what does this potion do?" };

		private PhysGrabObject _grab;

		private int _type;

		private Color _color;

		private bool _tinted;

		private bool _wasHeld;

		private bool _introDone;

		private float _hintTimer;

		private int _lastHint = -1;

		private Action _undo;

		private PhysGrabObjectImpactDetector _impact;

		private bool _origHurtDisable;

		private static readonly FieldInfo GrabbedObject = AccessTools.Field(typeof(PhysGrabber), "grabbedPhysGrabObject");

		private void Start()
		{
			//IL_004f: 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)
			_grab = ((Component)this).GetComponent<PhysGrabObject>();
			_impact = ((Component)this).GetComponent<PhysGrabObjectImpactDetector>();
			if ((Object)(object)_impact != (Object)null)
			{
				_origHurtDisable = _impact.playerHurtDisable;
			}
			_type = Plugin.TypeIndexOf(((Component)this).gameObject);
			_color = PotionTypes.ColorOf(_type);
		}

		private void Update()
		{
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: 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_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			bool featureActive = Plugin.FeatureActive;
			if ((Object)(object)_impact != (Object)null)
			{
				_impact.playerHurtDisable = (featureActive && Plugin.NoDamage.Value) || _origHurtDisable;
			}
			if (featureActive)
			{
				Color val = PotionTypes.ColorOf(_type);
				if (!_tinted || val != _color)
				{
					_undo?.Invoke();
					_color = val;
					_undo = Retint.Hierarchy(((Component)this).gameObject, _color, Plugin.LogMaterials.Value && !_tinted);
					_tinted = true;
				}
				HandleHints();
			}
		}

		private bool HeldByMe()
		{
			if ((Object)(object)_grab != (Object)null && _grab.grabbed && (Object)(object)PhysGrabber.instance != (Object)null && PhysGrabber.instance.grabbed)
			{
				object? value = GrabbedObject.GetValue(PhysGrabber.instance);
				return (Object)((value is PhysGrabObject) ? value : null) == (Object)(object)_grab;
			}
			return false;
		}

		private void HandleHints()
		{
			if (!Plugin.HintsEnabled.Value || (Object)(object)ChatManager.instance == (Object)null)
			{
				return;
			}
			if (!HeldByMe())
			{
				_wasHeld = false;
				return;
			}
			if (!_wasHeld)
			{
				_wasHeld = true;
				_hintTimer = 0.4f;
			}
			if (ChatManager.instance.StateIsPossessed())
			{
				return;
			}
			_hintTimer -= Time.deltaTime;
			if (_hintTimer > 0f)
			{
				return;
			}
			string[] hints = PotionTypes.All[_type].Hints;
			string text;
			if (!_introDone)
			{
				text = Intros[Random.Range(0, Intros.Length)];
				_introDone = true;
				_hintTimer = 3.5f;
			}
			else
			{
				int num;
				do
				{
					num = Random.Range(0, hints.Length);
				}
				while (hints.Length > 1 && num == _lastHint);
				_lastHint = num;
				text = hints[num];
				_hintTimer = Plugin.HintInterval.Value + Random.Range(0f, 4f);
			}
			Speak(text);
		}

		private void Speak(string text)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			ChatManager.instance.PossessChatScheduleStart(10);
			ChatManager.instance.PossessChat((PossessChatID)0, text, 1f, _color, 0f, false, 0, (UnityEvent)null, "en-US");
			ChatManager.instance.PossessChatScheduleEnd();
		}
	}
	internal static class Retint
	{
		private static readonly string[] ColorProps = new string[9] { "_Color", "_BaseColor", "_TintColor", "_EmissionColor", "_Tint", "_MainColor", "_Albedo", "_FresnelColor", "_RimColor" };

		private const float HueMin = 0.19f;

		private const float HueMax = 0.48f;

		private const float MinSat = 0.18f;

		public static bool IsGreen(Color c)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			float num = Mathf.Max(1f, ((Color)(ref c)).maxColorComponent);
			float num2 = default(float);
			float num3 = default(float);
			float num4 = default(float);
			Color.RGBToHSV(new Color(c.r / num, c.g / num, c.b / num, c.a), ref num2, ref num3, ref num4);
			if (num3 >= 0.18f && num4 > 0.05f && num2 >= 0.19f)
			{
				return num2 <= 0.48f;
			}
			return false;
		}

		public static Color Shift(Color c, Color target)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			float num = Mathf.Max(1f, ((Color)(ref c)).maxColorComponent);
			float num2 = default(float);
			float num3 = default(float);
			float num4 = default(float);
			Color.RGBToHSV(new Color(c.r / num, c.g / num, c.b / num, c.a), ref num2, ref num3, ref num4);
			float num5 = default(float);
			float num6 = default(float);
			float num7 = default(float);
			Color.RGBToHSV(target, ref num5, ref num6, ref num7);
			float num8 = Mathf.Clamp01(num3 * (num6 / 0.8f));
			float num9 = Mathf.Clamp01(num4 * Mathf.Max(num7, 0.55f));
			Color result = Color.HSVToRGB(num5, num8, num9);
			result.r *= num;
			result.g *= num;
			result.b *= num;
			result.a = c.a;
			return result;
		}

		private static Color ShiftIfGreen(Color c, Color target)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			if (!IsGreen(c))
			{
				return c;
			}
			return Shift(c, target);
		}

		public static Action Hierarchy(GameObject root, Color target, bool logMaterials = false)
		{
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			List<Action> undo = new List<Action>();
			if ((Object)(object)root == (Object)null)
			{
				return delegate
				{
				};
			}
			Renderer[] componentsInChildren = root.GetComponentsInChildren<Renderer>(true);
			for (int num = 0; num < componentsInChildren.Length; num++)
			{
				RetintRenderer(componentsInChildren[num], target, logMaterials, undo);
			}
			ParticleSystem[] componentsInChildren2 = root.GetComponentsInChildren<ParticleSystem>(true);
			for (int num = 0; num < componentsInChildren2.Length; num++)
			{
				RetintParticles(componentsInChildren2[num], target, undo);
			}
			Light[] componentsInChildren3 = root.GetComponentsInChildren<Light>(true);
			foreach (Light val in componentsInChildren3)
			{
				Light light = val;
				Color original = light.color;
				undo.Add(delegate
				{
					//IL_0015: Unknown result type (might be due to invalid IL or missing references)
					if ((Object)(object)light != (Object)null)
					{
						light.color = original;
					}
				});
				light.color = ShiftIfGreen(original, target);
			}
			return delegate
			{
				foreach (Action item in undo)
				{
					try
					{
						item();
					}
					catch
					{
					}
				}
			};
		}

		private static void RetintRenderer(Renderer r, Color target, bool log, List<Action> undo)
		{
			//IL_0063: 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_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: 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)
			if ((Object)(object)r == (Object)null)
			{
				return;
			}
			Material[] materials;
			try
			{
				materials = r.materials;
			}
			catch
			{
				return;
			}
			Material[] array = materials;
			foreach (Material val in array)
			{
				if ((Object)(object)val == (Object)null)
				{
					continue;
				}
				List<string> list = new List<string>();
				string[] colorProps = ColorProps;
				foreach (string text in colorProps)
				{
					if (!val.HasProperty(text))
					{
						continue;
					}
					Color c = val.GetColor(text);
					if (!IsGreen(c))
					{
						continue;
					}
					Material mat = val;
					string p = text;
					undo.Add(delegate
					{
						//IL_001b: Unknown result type (might be due to invalid IL or missing references)
						if ((Object)(object)mat != (Object)null)
						{
							mat.SetColor(p, c);
						}
					});
					val.SetColor(text, Shift(c, target));
					list.Add(text);
				}
				if (log)
				{
					Plugin.Log.LogInfo((object)("[potion material] renderer=" + ((Object)r).name + " material=" + ((Object)val).name + " shader=" + (Object.op_Implicit((Object)(object)val.shader) ? ((Object)val.shader).name : "?") + " tex=" + (Object.op_Implicit((Object)(object)val.mainTexture) ? ((Object)val.mainTexture).name : "none") + " retinted=[" + string.Join(",", list) + "]"));
				}
			}
		}

		private static MinMaxGradient ShiftGradient(MinMaxGradient g, Color target)
		{
			//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_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected I4, but got Unknown
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			ParticleSystemGradientMode mode = ((MinMaxGradient)(ref g)).mode;
			switch ((int)mode)
			{
			case 0:
				return new MinMaxGradient(ShiftIfGreen(((MinMaxGradient)(ref g)).color, target));
			case 2:
				return new MinMaxGradient(ShiftIfGreen(((MinMaxGradient)(ref g)).colorMin, target), ShiftIfGreen(((MinMaxGradient)(ref g)).colorMax, target));
			case 1:
				return new MinMaxGradient(ShiftGradient(((MinMaxGradient)(ref g)).gradient, target));
			case 3:
				return new MinMaxGradient(ShiftGradient(((MinMaxGradient)(ref g)).gradientMin, target), ShiftGradient(((MinMaxGradient)(ref g)).gradientMax, target));
			case 4:
			{
				MinMaxGradient result = default(MinMaxGradient);
				((MinMaxGradient)(ref result))..ctor(ShiftGradient(((MinMaxGradient)(ref g)).gradient, target));
				((MinMaxGradient)(ref result)).mode = (ParticleSystemGradientMode)4;
				return result;
			}
			default:
				return g;
			}
		}

		private static Gradient ShiftGradient(Gradient src, Color target)
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//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_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Expected O, but got Unknown
			if (src == null)
			{
				return null;
			}
			GradientColorKey[] colorKeys = src.colorKeys;
			for (int i = 0; i < colorKeys.Length; i++)
			{
				colorKeys[i].color = ShiftIfGreen(colorKeys[i].color, target);
			}
			Gradient val = new Gradient();
			val.SetKeys(colorKeys, src.alphaKeys);
			val.mode = src.mode;
			return val;
		}

		private static void RetintParticles(ParticleSystem ps, Color target, List<Action> undo)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: 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_0056: 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)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: 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_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: 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_016e: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: Unknown result type (might be due to invalid IL or missing references)
			MainModule main = ps.main;
			MinMaxGradient startOrig = ((MainModule)(ref main)).startColor;
			undo.Add(delegate
			{
				//IL_0014: Unknown result type (might be due to invalid IL or missing references)
				//IL_0019: Unknown result type (might be due to invalid IL or missing references)
				//IL_001d: Unknown result type (might be due to invalid IL or missing references)
				if ((Object)(object)ps != (Object)null)
				{
					MainModule main2 = ps.main;
					((MainModule)(ref main2)).startColor = startOrig;
				}
			});
			((MainModule)(ref main)).startColor = ShiftGradient(startOrig, target);
			ColorOverLifetimeModule colorOverLifetime = ps.colorOverLifetime;
			if (((ColorOverLifetimeModule)(ref colorOverLifetime)).enabled)
			{
				MinMaxGradient orig = ((ColorOverLifetimeModule)(ref colorOverLifetime)).color;
				undo.Add(delegate
				{
					//IL_001e: Unknown result type (might be due to invalid IL or missing references)
					//IL_0023: 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)
					if ((Object)(object)ps != (Object)null)
					{
						ColorOverLifetimeModule colorOverLifetime2 = ps.colorOverLifetime;
						((ColorOverLifetimeModule)(ref colorOverLifetime2)).color = orig;
					}
				});
				((ColorOverLifetimeModule)(ref colorOverLifetime)).color = ShiftGradient(orig, target);
			}
			ColorBySpeedModule colorBySpeed = ps.colorBySpeed;
			if (((ColorBySpeedModule)(ref colorBySpeed)).enabled)
			{
				MinMaxGradient orig2 = ((ColorBySpeedModule)(ref colorBySpeed)).color;
				undo.Add(delegate
				{
					//IL_001e: Unknown result type (might be due to invalid IL or missing references)
					//IL_0023: 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)
					if ((Object)(object)ps != (Object)null)
					{
						ColorBySpeedModule colorBySpeed2 = ps.colorBySpeed;
						((ColorBySpeedModule)(ref colorBySpeed2)).color = orig2;
					}
				});
				((ColorBySpeedModule)(ref colorBySpeed)).color = ShiftGradient(orig2, target);
			}
			TrailModule trails = ps.trails;
			if (!((TrailModule)(ref trails)).enabled)
			{
				return;
			}
			MinMaxGradient o1 = ((TrailModule)(ref trails)).colorOverLifetime;
			MinMaxGradient o2 = ((TrailModule)(ref trails)).colorOverTrail;
			undo.Add(delegate
			{
				//IL_001e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0023: 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)
				//IL_0034: Unknown result type (might be due to invalid IL or missing references)
				if ((Object)(object)ps != (Object)null)
				{
					TrailModule trails2 = ps.trails;
					((TrailModule)(ref trails2)).colorOverLifetime = o1;
					((TrailModule)(ref trails2)).colorOverTrail = o2;
				}
			});
			((TrailModule)(ref trails)).colorOverLifetime = ShiftGradient(o1, target);
			((TrailModule)(ref trails)).colorOverTrail = ShiftGradient(o2, target);
		}

		public static void ShiftLive(GameObject root, Color target)
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: 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_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)root == (Object)null)
			{
				return;
			}
			Graphic[] componentsInChildren = root.GetComponentsInChildren<Graphic>(true);
			foreach (Graphic val in componentsInChildren)
			{
				if (IsGreen(val.color))
				{
					val.color = Shift(val.color, target);
				}
				Material materialForRendering = val.materialForRendering;
				if (!((Object)(object)materialForRendering != (Object)null))
				{
					continue;
				}
				string[] colorProps = ColorProps;
				foreach (string text in colorProps)
				{
					if (materialForRendering.HasProperty(text))
					{
						Color color = materialForRendering.GetColor(text);
						if (IsGreen(color))
						{
							materialForRendering.SetColor(text, Shift(color, target));
						}
					}
				}
			}
			SpriteRenderer[] componentsInChildren2 = root.GetComponentsInChildren<SpriteRenderer>(true);
			foreach (SpriteRenderer val2 in componentsInChildren2)
			{
				if (IsGreen(val2.color))
				{
					val2.color = Shift(val2.color, target);
				}
			}
			Renderer[] componentsInChildren3 = root.GetComponentsInChildren<Renderer>(true);
			foreach (Renderer val3 in componentsInChildren3)
			{
				if (val3 is SpriteRenderer || val3 is ParticleSystemRenderer)
				{
					continue;
				}
				Material material = val3.material;
				if ((Object)(object)material == (Object)null)
				{
					continue;
				}
				string[] colorProps = ColorProps;
				foreach (string text2 in colorProps)
				{
					if (material.HasProperty(text2))
					{
						Color color2 = material.GetColor(text2);
						if (IsGreen(color2))
						{
							material.SetColor(text2, Shift(color2, target));
						}
					}
				}
			}
		}
	}
	internal class SettingsMenu : MonoBehaviour
	{
		internal static bool IsOpen;

		private static readonly Color Bg = new Color(0.085f, 0.085f, 0.115f, 0.97f);

		private static readonly Color Card = new Color(0.135f, 0.135f, 0.18f, 1f);

		private static readonly Color Row = new Color(0.18f, 0.18f, 0.24f, 1f);

		private static readonly Color TextC = new Color(0.94f, 0.94f, 0.98f, 1f);

		private static readonly Color Dim = new Color(0.62f, 0.62f, 0.72f, 1f);

		private static readonly Color Accent = new Color(0.66f, 0.52f, 1f, 1f);

		private static readonly Color Off = new Color(0.42f, 0.43f, 0.47f, 1f);

		private Rect _rect = new Rect(80f, 60f, 620f, 640f);

		private Vector2 _scroll;

		private bool _rebinding;

		private CursorLockMode _prevLock;

		private bool _prevVisible;

		private float _toggleAt = -9f;

		private GUIStyle _label;

		private GUIStyle _small;

		private GUIStyle _hint;

		private GUIStyle _title;

		private GUIStyle _card;

		private GUIStyle _field;

		private GUIStyle _button;

		private GUIStyle _section;

		private Texture2D _tField;

		private readonly Dictionary<string, string> _bufs = new Dictionary<string, string>();

		private static readonly FieldInfo InputDisableTimer = AccessTools.Field(typeof(PlayerController), "InputDisableTimer");

		private void Update()
		{
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Invalid comparison between Unknown and I4
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Invalid comparison between Unknown and I4
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Invalid comparison between Unknown and I4
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Invalid comparison between Unknown and I4
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Invalid comparison between Unknown and I4
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (_rebinding)
				{
					foreach (KeyCode value in Enum.GetValues(typeof(KeyCode)))
					{
						if ((int)value != 0 && (int)value != 323 && (int)value != 324 && ((int)value < 330 || (int)value > 509) && InputCompat.GetKeyDown(value))
						{
							if ((int)value != 27)
							{
								Plugin.MenuKey.Value = value;
								Plugin.SaveConfig();
							}
							_rebinding = false;
							_toggleAt = Time.unscaledTime;
							break;
						}
					}
				}
				else if (InputCompat.GetKeyDown(Plugin.MenuKey.Value))
				{
					ToggleKey(fromGui: false);
				}
				if (IsOpen)
				{
					KeepCursorFree();
				}
			}
			catch (Exception ex)
			{
				Plugin.Log.LogWarning((object)("Menu update: " + ex.Message));
			}
		}

		private void ToggleKey(bool fromGui)
		{
			float unscaledTime = Time.unscaledTime;
			if (!(unscaledTime - _toggleAt < (fromGui ? 0.7f : 0.15f)))
			{
				_toggleAt = unscaledTime;
				Toggle();
			}
		}

		private void Toggle()
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Invalid comparison between Unknown and I4
			IsOpen = !IsOpen;
			if (IsOpen)
			{
				_prevLock = Cursor.lockState;
				_prevVisible = Cursor.visible;
				((Rect)(ref _rect)).x = Mathf.Max(8f, ((float)Screen.width / Scale() - ((Rect)(ref _rect)).width) / 2f);
				((Rect)(ref _rect)).y = Mathf.Max(8f, ((float)Screen.height / Scale() - ((Rect)(ref _rect)).height) / 2f);
				return;
			}
			_rebinding = false;
			Plugin.SaveConfig();
			try
			{
				GUI.FocusControl("");
				GUIUtility.keyboardControl = 0;
			}
			catch
			{
			}
			Cursor.lockState = (CursorLockMode)(((int)_prevLock == 0) ? 1 : ((int)_prevLock));
			Cursor.visible = _prevVisible && (int)_prevLock == 0;
		}

		private void KeepCursorFree()
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Invalid comparison between Unknown and I4
			Cursor.lockState = (CursorLockMode)0;
			Cursor.visible = true;
			if (!((Object)(object)GameDirector.instance != (Object)null) || (int)GameDirector.instance.currentState != 0)
			{
				if (InputDisableTimer != null && (Object)(object)PlayerController.instance != (Object)null)
				{
					InputDisableTimer.SetValue(PlayerController.instance, 0.1f);
				}
				if ((Object)(object)InputManager.instance != (Object)null)
				{
					InputManager.instance.DisableAiming(0.2f);
				}
			}
		}

		private static float Scale()
		{
			return Mathf.Clamp((float)Screen.height / 1080f, 0.8f, 1.6f);
		}

		private void OnGUI()
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Invalid comparison between Unknown and I4
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Expected O, but got Unknown
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Invalid comparison between Unknown and I4
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Invalid comparison between Unknown and I4
			if (_label == null)
			{
				BuildStyles();
			}
			Event current = Event.current;
			KeyCode value = Plugin.MenuKey.Value;
			if (current != null && (int)current.type == 4 && current.keyCode == value && (int)value >= 282 && (int)value <= 296 && !_rebinding)
			{
				ToggleKey(fromGui: true);
				current.Use();
			}
			if (IsOpen)
			{
				Matrix4x4 matrix = GUI.matrix;
				float num = Scale();
				GUI.matrix = Matrix4x4.Scale(new Vector3(num, num, 1f));
				((Rect)(ref _rect)).width = Mathf.Min(620f, (float)Screen.width / num - 16f);
				((Rect)(ref _rect)).height = Mathf.Min(640f, (float)Screen.height / num - 16f);
				_rect = GUI.Window(5394509, _rect, new WindowFunction(DrawWindow), GUIContent.none, GUIStyle.none);
				((Rect)(ref _rect)).x = Mathf.Clamp(((Rect)(ref _rect)).x, 0f, Mathf.Max(0f, (float)Screen.width / num - 120f));
				((Rect)(ref _rect)).y = Mathf.Clamp(((Rect)(ref _rect)).y, 0f, Mathf.Max(0f, (float)Screen.height / num - 60f));
				GUI.matrix = matrix;
			}
		}

		private void DrawWindow(int id)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Invalid comparison between Unknown and I4
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Expected O, but got Unknown
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: 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)
			if ((int)Event.current.type == 7)
			{
				RFill(new Rect(0f, 0f, ((Rect)(ref _rect)).width, ((Rect)(ref _rect)).height), Bg, 20f);
			}
			GUI.Label(new Rect(22f, 14f, 360f, 30f), RainbowText("RAINBOW POTIONS"), _title);
			GUI.Label(new Rect(((Rect)(ref _rect)).width - 230f, 20f, 208f, 22f), ((object)Plugin.MenuKey.Value/*cast due to .constrained prefix*/).ToString() + " = close", new GUIStyle(_small)
			{
				alignment = (TextAnchor)5
			});
			GUILayout.BeginArea(new Rect(16f, 54f, ((Rect)(ref _rect)).width - 32f, ((Rect)(ref _rect)).height - 70f));
			_scroll = GUILayout.BeginScrollView(_scroll, Array.Empty<GUILayoutOption>());
			CardBegin("HOST SETTINGS", "Only the host's values count. Players without the mod still get the effects.");
			Toggle(Plugin.SpawnEverywhere, "Potions on every map", "Normally potions only spawn on the Wizard map.");
			IntRow(Plugin.PotionsPerMap, "Potions per map", "How many potions lie on a map (max 20). Less on small maps.", 0, 20);
			IntRow(Plugin.UpgradeAmount, "Upgrade amount", "Upgrade levels a player gets per broken potion (1x - 5x).", 1, 5);
			Toggle(Plugin.HealEnabled, "Heal on break", "The potion also heals the player it breaks on.");
			IntRow(Plugin.HealPercent, "Heal percent", "Percent of max HP that gets healed.", 0, 100);
			FloatRow(Plugin.AffectRadius, "Hit radius (m)", "Only the nearest player inside this distance gets the upgrade.", 0.5f, 10f);
			Toggle(Plugin.NoDamage, "No damage from potions", "A potion that breaks on a player does not hurt.");
			CardEnd();
			CardBegin("YOUR SETTINGS", "Only for you: looks and texts.");
			Toggle(Plugin.UseShopColors, "Use shop upgrade colors", "Off = built-in color palette. Applies to new potions.");
			Toggle(Plugin.HintsEnabled, "Hints", "Your character mumbles hints about the potion you hold.");
			FloatRow(Plugin.HintInterval, "Hint interval (s)", "Seconds between hints while holding a potion.", 3f, 30f);
			KeyRow();
			CardEnd();
			GUILayout.Space(4f);
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			if (Btn("Reset to defaults", 170f))
			{
				ResetAll();
			}
			GUILayout.FlexibleSpace();
			if (Btn("Close", 110f))
			{
				Toggle();
			}
			GUILayout.EndHorizontal();
			GUILayout.Space(6f);
			GUILayout.EndScrollView();
			GUILayout.EndArea();
			GUI.DragWindow(new Rect(0f, 0f, ((Rect)(ref _rect)).width, 50f));
		}

		private void CardBegin(string title, string sub)
		{
			GUILayout.BeginVertical(_card, Array.Empty<GUILayoutOption>());
			GUILayout.Label(title, _section, Array.Empty<GUILayoutOption>());
			if (!string.IsNullOrEmpty(sub))
			{
				GUILayout.Label(sub, _hint, Array.Empty<GUILayoutOption>());
			}
			GUILayout.Space(6f);
		}

		private void CardEnd()
		{
			GUILayout.EndVertical();
			GUILayout.Space(8f);
		}

		private void Toggle(ConfigEntry<bool> e, string title, string desc)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: 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: Invalid comparison between Unknown and I4
			//IL_018e: 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_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: 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_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: Unknown result type (might be due to invalid IL or missing references)
			Rect rect = GUILayoutUtility.GetRect(10f, 52f, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) });
			bool flag = ((Rect)(ref rect)).Contains(Event.current.mousePosition);
			bool value = e.Value;
			if ((int)Event.current.type == 7)
			{
				RFill(rect, Color.Lerp(Row, Color.white, flag ? 0.06f : 0f), 12f);
				Rect r = default(Rect);
				((Rect)(ref r))..ctor(((Rect)(ref rect)).xMax - 60f, ((Rect)(ref rect)).center.y - 13f, 46f, 26f);
				RFill(r, value ? Accent : Off, 13f);
				RFill(new Rect(value ? (((Rect)(ref r)).xMax - 24f) : (((Rect)(ref r)).x + 2f), ((Rect)(ref r)).y + 2f, 22f, 22f), new Color(0.98f, 0.98f, 0.98f), 11f);
				GUI.Label(new Rect(((Rect)(ref rect)).x + 12f, ((Rect)(ref rect)).y + 5f, ((Rect)(ref rect)).width - 80f, 22f), title, _label);
				GUI.Label(new Rect(((Rect)(ref rect)).x + 12f, ((Rect)(ref rect)).y + 26f, ((Rect)(ref rect)).width - 80f, 22f), desc, _small);
			}
			if (GUI.Button(rect, GUIContent.none, GUIStyle.none))
			{
				e.Value = !value;
				Plugin.SaveConfig();
			}
			GUILayout.Space(3f);
		}

		private void IntRow(ConfigEntry<int> e, string title, string desc, int min, int max)
		{
			string typed;
			int num = Mathf.Clamp(Mathf.RoundToInt(SliderRow(((ConfigEntryBase)e).Definition.Key, title, desc, e.Value, min, max, integer: true, out typed)), min, max);
			if (num != e.Value)
			{
				e.Value = num;
			}
		}

		private void FloatRow(ConfigEntry<float> e, string title, string desc, float min, float max)
		{
			float num = SliderRow(((ConfigEntryBase)e).Definition.Key, title, desc, e.Value, min, max, integer: false, out var _);
			num = Mathf.Clamp(Mathf.Round(num * 10f) / 10f, min, max);
			if (Mathf.Abs(num - e.Value) > 0.0001f)
			{
				e.Value = num;
			}
		}

		private float SliderRow(string key, string title, string desc, float value, float min, float max, bool integer, out string typed)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Invalid comparison between Unknown and I4
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_025a: Unknown result type (might be due to invalid IL or missing references)
			Rect rect = GUILayoutUtility.GetRect(10f, 78f, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) });
			string text = "num_" + key;
			bool flag = GUI.GetNameOfFocusedControl() == text;
			if (!_bufs.TryGetValue(key, out var value2))
			{
				value2 = "";
			}
			string text2 = (integer ? Mathf.RoundToInt(value).ToString() : value.ToString("0.0", CultureInfo.InvariantCulture));
			if (!flag)
			{
				value2 = text2;
			}
			if ((int)Event.current.type == 7)
			{
				RFill(rect, Row, 12f);
				GUI.Label(new Rect(((Rect)(ref rect)).x + 12f, ((Rect)(ref rect)).y + 6f, ((Rect)(ref rect)).width - 110f, 22f), title, _label);
				GUI.Label(new Rect(((Rect)(ref rect)).x + 12f, ((Rect)(ref rect)).y + 27f, ((Rect)(ref rect)).width - 110f, 22f), desc, _small);
			}
			Rect val = new Rect(((Rect)(ref rect)).xMax - 84f, ((Rect)(ref rect)).y + 8f, 72f, 30f);
			GUI.SetNextControlName(text);
			string text3 = GUI.TextField(val, value2, 6, _field);
			if (text3 != value2)
			{
				StringBuilder stringBuilder = new StringBuilder();
				string text4 = text3;
				foreach (char c in text4)
				{
					if ((c >= '0' && c <= '9') || (!integer && (c == '.' || c == ',')))
					{
						stringBuilder.Append((c == ',') ? '.' : c);
					}
				}
				value2 = stringBuilder.ToString();
				if (float.TryParse(value2, NumberStyles.Float, CultureInfo.InvariantCulture, out var result))
				{
					if (result > max)
					{
						result = max;
						value2 = (integer ? ((int)max).ToString() : max.ToString("0.0", CultureInfo.InvariantCulture));
					}
					value = Mathf.Clamp(result, min, max);
					Plugin.SaveSoon();
				}
			}
			_bufs[key] = value2;
			Rect r = default(Rect);
			((Rect)(ref r))..ctor(((Rect)(ref rect)).x + 16f, ((Rect)(ref rect)).y + 54f, ((Rect)(ref rect)).width - 32f, 18f);
			float num = DrawSlider(r, value, min, max, integer);
			if (Mathf.Abs(num - value) > 0.0001f)
			{
				value = num;
				_bufs[key] = (integer ? Mathf.RoundToInt(value).ToString() : value.ToString("0.0", CultureInfo.InvariantCulture));
				if (flag)
				{
					GUI.FocusControl("");
				}
			}
			GUILayout.Space(3f);
			typed = value2;
			return value;
		}

		private float DrawSlider(Rect r, float value, float min, float max, bool integer)
		{
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: 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_0068: Expected I4, but got Unknown
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Invalid comparison between Unknown and I4
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01da: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
			int controlID = GUIUtility.GetControlID((FocusType)2);
			Event current = Event.current;
			Rect val = default(Rect);
			((Rect)(ref val))..ctor(((Rect)(ref r)).x - 10f, ((Rect)(ref r)).y - 4f, ((Rect)(ref r)).width + 20f, ((Rect)(ref r)).height + 8f);
			EventType typeForControl = current.GetTypeForControl(controlID);
			switch ((int)typeForControl)
			{
			default:
				if ((int)typeForControl == 7)
				{
					float num = Mathf.InverseLerp(min, max, value);
					Rect r2 = default(Rect);
					((Rect)(ref r2))..ctor(((Rect)(ref r)).x, ((Rect)(ref r)).center.y - 3f, ((Rect)(ref r)).width, 6f);
					RFill(r2, Off, 3f);
					RFill(new Rect(((Rect)(ref r2)).x, ((Rect)(ref r2)).y, Mathf.Max(6f, ((Rect)(ref r2)).width * num), ((Rect)(ref r2)).height), Accent, 3f);
					float num2 = ((Rect)(ref r)).x + ((Rect)(ref r)).width * num;
					RFill(c: (Color)((GUIUtility.hotControl == controlID || ((Rect)(ref val)).Contains(current.mousePosition)) ? Color.white : new Color(0.96f, 0.96f, 0.98f)), r: new Rect(num2 - 9f, ((Rect)(ref r)).center.y - 9f, 18f, 18f), radius: 9f);
				}
				break;
			case 0:
				if (current.button == 0 && ((Rect)(ref val)).Contains(current.mousePosition))
				{
					GUIUtility.hotControl = controlID;
					value = FromMouse(r, current.mousePosition.x, min, max, integer);
					current.Use();
				}
				break;
			case 3:
				if (GUIUtility.hotControl == controlID)
				{
					value = FromMouse(r, current.mousePosition.x, min, max, integer);
					current.Use();
				}
				break;
			case 1:
				if (GUIUtility.hotControl == controlID)
				{
					GUIUtility.hotControl = 0;
					Plugin.SaveConfig();
					current.Use();
				}
				break;
			case 2:
				break;
			}
			return value;
		}

		private static float FromMouse(Rect r, float x, float min, float max, bool integer)
		{
			float num = Mathf.Clamp01((x - ((Rect)(ref r)).x) / ((Rect)(ref r)).width);
			float num2 = Mathf.Lerp(min, max, num);
			if (!integer)
			{
				return Mathf.Round(num2 * 10f) / 10f;
			}
			return Mathf.Round(num2);
		}

		private void KeyRow()
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Invalid comparison between Unknown and I4
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			Rect rect = GUILayoutUtility.GetRect(10f, 52f, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) });
			if ((int)Event.current.type == 7)
			{
				RFill(rect, Row, 12f);
				GUI.Label(new Rect(((Rect)(ref rect)).x + 12f, ((Rect)(ref rect)).y + 5f, ((Rect)(ref rect)).width - 200f, 22f), "Menu key", _label);
				GUI.Label(new Rect(((Rect)(ref rect)).x + 12f, ((Rect)(ref rect)).y + 26f, ((Rect)(ref rect)).width - 200f, 22f), _rebinding ? "Press a key... (Esc = cancel)" : "The key that opens this menu.", _small);
			}
			if (GUI.Button(new Rect(((Rect)(ref rect)).xMax - 164f, ((Rect)(ref rect)).y + 10f, 152f, 32f), _rebinding ? "..." : ((object)Plugin.MenuKey.Value/*cast due to .constrained prefix*/).ToString(), _button))
			{
				_rebinding = !_rebinding;
			}
			GUILayout.Space(3f);
		}

		private bool Btn(string label, float width)
		{
			return GUILayout.Button(label, _button, (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.Width(width),
				GUILayout.Height(34f)
			});
		}

		private void ResetAll()
		{
			Plugin.ResetAll();
			_bufs.Clear();
			Plugin.SaveConfig();
		}

		private void BuildStyles()
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Expected O, but got Unknown
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Expected O, but got Unknown
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Expected O, but got Unknown
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Expected O, but got Unknown
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Expected O, but got Unknown
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: 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_012d: Expected O, but got Unknown
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Expected O, but got Unknown
			//IL_0141: Expected O, but got Unknown
			//IL_014e: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0175: Expected O, but got Unknown
			//IL_018b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01be: Expected O, but got Unknown
			//IL_020a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0214: Expected O, but got Unknown
			//IL_021f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0234: Unknown result type (might be due to invalid IL or missing references)
			//IL_0249: Unknown result type (might be due to invalid IL or missing references)
			//IL_025d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0267: Expected O, but got Unknown
			//IL_0269: Unknown result type (might be due to invalid IL or missing references)
			//IL_0276: Unknown result type (might be due to invalid IL or missing references)
			//IL_027b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0285: Unknown result type (might be due to invalid IL or missing references)
			//IL_029b: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a8: 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_02bb: Expected O, but got Unknown
			//IL_02fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0306: Expected O, but got Unknown
			//IL_0311: Unknown result type (might be due to invalid IL or missing references)
			//IL_0326: 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)
			_label = new GUIStyle(GUI.skin.label)
			{
				fontSize = 14,
				fontStyle = (FontStyle)1,
				wordWrap = false
			};
			_label.normal.textColor = TextC;
			_small = new GUIStyle(GUI.skin.label)
			{
				fontSize = 12,
				wordWrap = false
			};
			_small.normal.textColor = Dim;
			_hint = new GUIStyle(_small)
			{
				wordWrap = true
			};
			_title = new GUIStyle(GUI.skin.label)
			{
				fontSize = 20,
				fontStyle = (FontStyle)1,
				richText = true
			};
			_title.normal.textColor = TextC;
			_section = new GUIStyle(GUI.skin.label)
			{
				fontSize = 15,
				fontStyle = (FontStyle)1
			};
			_section.normal.textColor = Accent;
			_card = new GUIStyle(GUI.skin.box)
			{
				padding = new RectOffset(14, 14, 12, 12),
				margin = new RectOffset(0, 0, 4, 4)
			};
			_card.normal.background = RoundTex(14, Card);
			_card.border = new RectOffset(14, 14, 14, 14);
			_tField = RoundTex(8, new Color(0.07f, 0.07f, 0.1f, 1f));
			_field = new GUIStyle(GUI.skin.textField)
			{
				fontSize = 14,
				alignment = (TextAnchor)4
			};
			_field.normal.background = _tField;
			_field.focused.background = _tField;
			_field.hover.background = _tField;
			_field.border = new RectOffset(8, 8, 8, 8);
			_field.normal.textColor = TextC;
			_field.hover.textColor = TextC;
			_field.focused.textColor = Accent;
			_field.padding = new RectOffset(6, 6, 5, 5);
			Texture2D background = RoundTex(10, Row);
			Texture2D background2 = RoundTex(10, Color.Lerp(Row, Accent, 0.45f));
			_button = new GUIStyle(GUI.skin.button)
			{
				fontSize = 13,
				fontStyle = (FontStyle)1,
				alignment = (TextAnchor)4
			};
			_button.normal.background = background;
			_button.hover.background = background2;
			_button.active.background = background2;
			_button.border = new RectOffset(10, 10, 10, 10);
			_button.normal.textColor = TextC;
			_button.hover.textColor = Color.white;
			_button.active.textColor = Color.white;
		}

		private static Texture2D RoundTex(int radius, Color c)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: 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_001f: Expected O, but got Unknown
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unk