Decompiled source of ColorsForEverybot v0.1.2

plugins/ColorsForEverybot.dll

Decompiled 19 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("ColorsForEverybot")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("ColorsForEverybot")]
[assembly: AssemblyTitle("ColorsForEverybot")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[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 ColorsForEverybot
{
	[BepInPlugin("princessusa.ColorsForEverybot", "Colors for Everybot", "0.1.2")]
	public sealed class Plugin : BaseUnityPlugin
	{
		public const string PluginGuid = "princessusa.ColorsForEverybot";

		public const string PluginName = "Colors for Everybot";

		public const string PluginVersion = "0.1.2";

		private ConfigEntry<bool> _enabled;

		private ConfigEntry<int> _fontSize;

		private ConfigEntry<bool> _showHex;

		private ConfigEntry<string> _prefix;

		private Type? _menuPageColorType;

		private FieldInfo? _hoveredColorButtonField;

		private PropertyInfo? _hoveredColorButtonProperty;

		private Object? _activePage;

		private object? _hoveredButton;

		private string _hoverText = string.Empty;

		private GUIStyle? _boxStyle;

		private float _nextPageSearch;

		private int _lastButtonId;

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

		private static readonly string[] PaletteNames = new string[36]
		{
			"White", "Medium Gray", "Dark Gray", "Light Red", "Bright Red", "Dark Red", "Maroon", "Raspberry Pink", "Hot Pink", "Magenta",
			"Light Pink", "Lavender", "Violet", "Dark Purple", "Purple", "Indigo", "Electric Blue", "Periwinkle Blue", "Cyan Blue", "Turquoise",
			"Mint", "Light Green", "Green", "Lime Green", "Bright Green", "Olive Green", "Sage Green", "Dark Teal", "Olive Brown", "Brown",
			"Tan", "Coral Orange", "Orange", "Mustard Yellow", "Bright Yellow", "Pale Yellow"
		};

		private static readonly Color32[] PaletteReferenceColors = (Color32[])(object)new Color32[36]
		{
			new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, byte.MaxValue),
			new Color32((byte)131, (byte)131, (byte)131, byte.MaxValue),
			new Color32((byte)38, (byte)38, (byte)38, byte.MaxValue),
			new Color32(byte.MaxValue, (byte)116, (byte)116, byte.MaxValue),
			new Color32(byte.MaxValue, (byte)61, (byte)61, byte.MaxValue),
			new Color32((byte)139, (byte)51, (byte)51, byte.MaxValue),
			new Color32((byte)87, (byte)47, (byte)48, byte.MaxValue),
			new Color32(byte.MaxValue, (byte)14, (byte)85, byte.MaxValue),
			new Color32(byte.MaxValue, (byte)1, (byte)117, byte.MaxValue),
			new Color32(byte.MaxValue, (byte)1, (byte)223, byte.MaxValue),
			new Color32(byte.MaxValue, (byte)163, (byte)250, byte.MaxValue),
			new Color32((byte)207, (byte)163, byte.MaxValue, byte.MaxValue),
			new Color32((byte)166, (byte)92, (byte)242, byte.MaxValue),
			new Color32((byte)56, (byte)40, (byte)82, byte.MaxValue),
			new Color32((byte)110, (byte)1, (byte)119, byte.MaxValue),
			new Color32((byte)58, (byte)60, (byte)146, byte.MaxValue),
			new Color32((byte)49, (byte)2, byte.MaxValue, byte.MaxValue),
			new Color32((byte)87, (byte)117, byte.MaxValue, byte.MaxValue),
			new Color32((byte)0, (byte)174, (byte)227, byte.MaxValue),
			new Color32((byte)1, byte.MaxValue, (byte)231, byte.MaxValue),
			new Color32((byte)153, byte.MaxValue, (byte)220, byte.MaxValue),
			new Color32((byte)151, byte.MaxValue, (byte)147, byte.MaxValue),
			new Color32((byte)73, (byte)218, (byte)109, byte.MaxValue),
			new Color32((byte)149, byte.MaxValue, (byte)1, byte.MaxValue),
			new Color32((byte)1, byte.MaxValue, (byte)36, byte.MaxValue),
			new Color32((byte)96, (byte)143, (byte)1, byte.MaxValue),
			new Color32((byte)73, (byte)117, (byte)74, byte.MaxValue),
			new Color32((byte)34, (byte)100, (byte)70, byte.MaxValue),
			new Color32((byte)112, (byte)104, (byte)52, byte.MaxValue),
			new Color32((byte)122, (byte)72, (byte)42, byte.MaxValue),
			new Color32((byte)190, (byte)151, (byte)95, byte.MaxValue),
			new Color32(byte.MaxValue, (byte)117, (byte)49, byte.MaxValue),
			new Color32(byte.MaxValue, (byte)131, (byte)0, byte.MaxValue),
			new Color32((byte)169, (byte)149, (byte)0, byte.MaxValue),
			new Color32(byte.MaxValue, (byte)229, (byte)0, byte.MaxValue),
			new Color32(byte.MaxValue, byte.MaxValue, (byte)102, byte.MaxValue)
		};

		private void Awake()
		{
			_enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "Show a written color name while hovering a Semibot color swatch.");
			_fontSize = ((BaseUnityPlugin)this).Config.Bind<int>("Display", "FontSize", 22, "Tooltip font size.");
			_showHex = ((BaseUnityPlugin)this).Config.Bind<bool>("Display", "ShowHexValue", false, "Also show the RGB hex value, for example Blue (#315DFF).");
			_prefix = ((BaseUnityPlugin)this).Config.Bind<string>("Display", "Prefix", "Color: ", "Text shown before the detected color name.");
			ResolveGameTypes();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Colors for Everybot 0.1.2 loaded.");
		}

		private void ResolveGameTypes()
		{
			_menuPageColorType = FindType("MenuPageColor");
			if (_menuPageColorType == null)
			{
				((BaseUnityPlugin)this).Logger.LogWarning((object)"Could not find MenuPageColor yet; will retry when a menu is open.");
				return;
			}
			_hoveredColorButtonField = _menuPageColorType.GetField("hoveredColorButton", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			_hoveredColorButtonProperty = _menuPageColorType.GetProperty("hoveredColorButton", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			if (_hoveredColorButtonField == null && _hoveredColorButtonProperty == null)
			{
				((BaseUnityPlugin)this).Logger.LogWarning((object)"MenuPageColor was found, but hoveredColorButton was not. The mod will keep probing compatible members.");
			}
		}

		private static Type? FindType(string simpleName)
		{
			Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
			foreach (Assembly assembly in assemblies)
			{
				try
				{
					Type type = assembly.GetType(simpleName, throwOnError: false);
					if (type != null)
					{
						return type;
					}
					Type[] types = assembly.GetTypes();
					foreach (Type type2 in types)
					{
						if (type2.Name == simpleName)
						{
							return type2;
						}
					}
				}
				catch (ReflectionTypeLoadException ex)
				{
					Type[] types = ex.Types;
					foreach (Type type3 in types)
					{
						if (type3 != null && type3.Name == simpleName)
						{
							return type3;
						}
					}
				}
				catch
				{
				}
			}
			return null;
		}

		private void Update()
		{
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_016c: Unknown result type (might be due to invalid IL or missing references)
			if (!_enabled.Value)
			{
				ClearHover();
				return;
			}
			if (_menuPageColorType == null)
			{
				if (Time.unscaledTime >= _nextPageSearch)
				{
					_nextPageSearch = Time.unscaledTime + 1f;
					ResolveGameTypes();
				}
				return;
			}
			if (_activePage == (Object)null || !IsPageActive(_activePage))
			{
				if (Time.unscaledTime < _nextPageSearch)
				{
					ClearHover();
					return;
				}
				_nextPageSearch = Time.unscaledTime + 0.35f;
				_activePage = FindActiveColorPage();
				if (_activePage == (Object)null)
				{
					ClearHover();
					return;
				}
			}
			object hoveredButton = GetHoveredButton(_activePage);
			if (hoveredButton == null)
			{
				ClearHover();
				return;
			}
			_hoveredButton = hoveredButton;
			int unityObjectId = GetUnityObjectId(hoveredButton);
			if (unityObjectId != 0 && unityObjectId == _lastButtonId && !string.IsNullOrEmpty(_hoverText))
			{
				return;
			}
			_lastButtonId = unityObjectId;
			Color color;
			if (unityObjectId != 0 && _cachedNames.TryGetValue(unityObjectId, out string value))
			{
				_hoverText = value;
			}
			else if (TryGetButtonColor(hoveredButton, out color))
			{
				int index;
				string text = string.Concat(str1: (!TryGetPaletteIndex(hoveredButton, out index) || index < 0 || index >= PaletteNames.Length) ? DescribePaletteColor(color) : PaletteNames[index], str0: _prefix.Value);
				if (_showHex.Value)
				{
					text = text + " (#" + ColorUtility.ToHtmlStringRGB(color) + ")";
				}
				_hoverText = text;
				if (unityObjectId != 0)
				{
					_cachedNames[unityObjectId] = text;
				}
			}
			else
			{
				_hoverText = _prefix.Value + "Unknown";
			}
		}

		private Object? FindActiveColorPage()
		{
			if (_menuPageColorType == null)
			{
				return null;
			}
			Object[] array;
			try
			{
				array = Resources.FindObjectsOfTypeAll(_menuPageColorType);
			}
			catch
			{
				return null;
			}
			Object[] array2 = array;
			foreach (Object val in array2)
			{
				if (IsPageActive(val))
				{
					return val;
				}
			}
			return null;
		}

		private static bool IsPageActive(Object obj)
		{
			if (obj == (Object)null)
			{
				return false;
			}
			Component val = (Component)(object)((obj is Component) ? obj : null);
			if (val != null)
			{
				return val.gameObject.activeInHierarchy;
			}
			return true;
		}

		private object? GetHoveredButton(Object page)
		{
			try
			{
				if (_hoveredColorButtonField != null)
				{
					return _hoveredColorButtonField.GetValue(page);
				}
				if (_hoveredColorButtonProperty != null)
				{
					return _hoveredColorButtonProperty.GetValue(page, null);
				}
				Type type = ((object)page).GetType();
				FieldInfo[] fields = type.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				foreach (FieldInfo fieldInfo in fields)
				{
					if (fieldInfo.Name.IndexOf("hover", StringComparison.OrdinalIgnoreCase) >= 0 && fieldInfo.Name.IndexOf("color", StringComparison.OrdinalIgnoreCase) >= 0)
					{
						return fieldInfo.GetValue(page);
					}
				}
				PropertyInfo[] properties = type.GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				foreach (PropertyInfo propertyInfo in properties)
				{
					if (propertyInfo.GetIndexParameters().Length == 0 && propertyInfo.Name.IndexOf("hover", StringComparison.OrdinalIgnoreCase) >= 0 && propertyInfo.Name.IndexOf("color", StringComparison.OrdinalIgnoreCase) >= 0)
					{
						return propertyInfo.GetValue(page, null);
					}
				}
			}
			catch
			{
			}
			return null;
		}

		private static int GetUnityObjectId(object obj)
		{
			try
			{
				Object val = (Object)((obj is Object) ? obj : null);
				if (val != null)
				{
					return val.GetInstanceID();
				}
			}
			catch
			{
			}
			return obj.GetHashCode();
		}

		private static bool TryGetButtonColor(object button, out Color color)
		{
			//IL_00a7: 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)
			if (TryGetColorFromObject(button, out color, inspectNested: true))
			{
				return true;
			}
			Component val = (Component)((button is Component) ? button : null);
			if (val != null)
			{
				try
				{
					Component[] components = val.gameObject.GetComponents<Component>();
					foreach (Component val2 in components)
					{
						if (!((Object)(object)val2 == (Object)null) && val2 != val && TryGetColorFromObject(val2, out color, inspectNested: false))
						{
							return true;
						}
					}
					components = val.gameObject.GetComponentsInChildren<Component>(true);
					foreach (Component val3 in components)
					{
						if (!((Object)(object)val3 == (Object)null) && !((Object)(object)val3.gameObject == (Object)(object)val.gameObject) && TryGetColorFromObject(val3, out color, inspectNested: false))
						{
							return true;
						}
					}
				}
				catch
				{
				}
			}
			color = Color.clear;
			return false;
		}

		private static bool TryGetColorFromObject(object obj, out Color best, bool inspectNested)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: 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_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: 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_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0201: Unknown result type (might be due to invalid IL or missing references)
			//IL_0203: 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_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_0215: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0227: Unknown result type (might be due to invalid IL or missing references)
			//IL_0229: Unknown result type (might be due to invalid IL or missing references)
			//IL_0182: 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)
			//IL_0198: Unknown result type (might be due to invalid IL or missing references)
			best = Color.clear;
			int num = int.MinValue;
			if (obj == null)
			{
				return false;
			}
			Type type = obj.GetType();
			MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			foreach (MethodInfo methodInfo in methods)
			{
				try
				{
					if (methodInfo.ReturnType != typeof(Color) || methodInfo.GetParameters().Length != 0 || methodInfo.Name.IndexOf("color", StringComparison.OrdinalIgnoreCase) < 0 || !(methodInfo.Invoke(obj, null) is Color val) || !IsUsableColor(val))
					{
						continue;
					}
					best = val;
					return true;
				}
				catch
				{
				}
			}
			FieldInfo[] fields = type.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			foreach (FieldInfo fieldInfo in fields)
			{
				try
				{
					if (fieldInfo.FieldType == typeof(Color))
					{
						Color val2 = (Color)fieldInfo.GetValue(obj);
						if (IsUsableColor(val2))
						{
							int num2 = ScoreColorMember(fieldInfo.Name, val2);
							if (num2 > num)
							{
								num = num2;
								best = val2;
							}
						}
					}
					else
					{
						if (!inspectNested || fieldInfo.Name.IndexOf("color", StringComparison.OrdinalIgnoreCase) < 0)
						{
							continue;
						}
						object value = fieldInfo.GetValue(obj);
						if (value != null && !fieldInfo.FieldType.IsPrimitive && fieldInfo.FieldType != typeof(string) && TryGetColorFromObject(value, out var best2, inspectNested: false))
						{
							int num3 = ScoreColorMember(fieldInfo.Name, best2) + 5;
							if (num3 > num)
							{
								num = num3;
								best = best2;
							}
						}
						continue;
					}
				}
				catch
				{
				}
			}
			PropertyInfo[] properties = type.GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			foreach (PropertyInfo propertyInfo in properties)
			{
				try
				{
					if (propertyInfo.GetIndexParameters().Length != 0 || !propertyInfo.CanRead || propertyInfo.PropertyType != typeof(Color))
					{
						continue;
					}
					Color val3 = (Color)propertyInfo.GetValue(obj, null);
					if (IsUsableColor(val3))
					{
						int num4 = ScoreColorMember(propertyInfo.Name, val3);
						if (num4 > num)
						{
							num = num4;
							best = val3;
						}
					}
				}
				catch
				{
				}
			}
			return num > int.MinValue;
		}

		private static int ScoreColorMember(string name, Color c)
		{
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			int num = 0;
			string text = name.ToLowerInvariant();
			if (text == "color")
			{
				num += 100;
			}
			if (text.Contains("maincolor"))
			{
				num += 90;
			}
			if (text.Contains("currentcolor"))
			{
				num += 80;
			}
			if (text.Contains("playercolor") || text.Contains("bodycolor"))
			{
				num += 75;
			}
			if (text.Contains("color"))
			{
				num += 30;
			}
			if (text.Contains("text") || text.Contains("font"))
			{
				num -= 60;
			}
			if (text.Contains("border") || text.Contains("background") || text.Contains("inactive"))
			{
				num -= 35;
			}
			float num2 = default(float);
			float num3 = default(float);
			float num4 = default(float);
			Color.RGBToHSV(c, ref num2, ref num3, ref num4);
			return num + (int)(num3 * 25f);
		}

		private static bool IsUsableColor(Color c)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: 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)
			//IL_0041: 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)
			if (c.a > 0.05f && c.r >= 0f && c.r <= 1.1f && c.g >= 0f && c.g <= 1.1f && c.b >= 0f)
			{
				return c.b <= 1.1f;
			}
			return false;
		}

		private static bool TryGetPaletteIndex(object button, out int index)
		{
			index = -1;
			if (button == null)
			{
				return false;
			}
			Type type = button.GetType();
			string[] array = new string[4] { "colorIndex", "_colorIndex", "playerColorIndex", "index" };
			foreach (string name in array)
			{
				try
				{
					FieldInfo field = type.GetField(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
					if (field != null && TryConvertIndex(field.GetValue(button), out index))
					{
						return true;
					}
					PropertyInfo property = type.GetProperty(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
					if (property != null && property.CanRead && property.GetIndexParameters().Length == 0 && TryConvertIndex(property.GetValue(button, null), out index))
					{
						return true;
					}
				}
				catch
				{
				}
			}
			FieldInfo[] fields = type.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			foreach (FieldInfo fieldInfo in fields)
			{
				try
				{
					string text = fieldInfo.Name.ToLowerInvariant();
					if (text.Contains("color") && text.Contains("index") && TryConvertIndex(fieldInfo.GetValue(button), out index))
					{
						return true;
					}
				}
				catch
				{
				}
			}
			return false;
		}

		private static bool TryConvertIndex(object? value, out int index)
		{
			index = -1;
			if (value == null)
			{
				return false;
			}
			try
			{
				index = Convert.ToInt32(value);
				return index >= 0 && index < PaletteNames.Length;
			}
			catch
			{
				return false;
			}
		}

		private static string DescribePaletteColor(Color color)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: 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)
			//IL_0022: 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: 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: 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_004a: Unknown result type (might be due to invalid IL or missing references)
			Color32 val = Color32.op_Implicit(color);
			int num = 0;
			long num2 = long.MaxValue;
			for (int i = 0; i < PaletteReferenceColors.Length; i++)
			{
				Color32 val2 = PaletteReferenceColors[i];
				int num3 = val.r - val2.r;
				int num4 = val.g - val2.g;
				int num5 = val.b - val2.b;
				long num6 = (long)num3 * (long)num3 + (long)num4 * (long)num4 + (long)num5 * (long)num5;
				if (num6 < num2)
				{
					num2 = num6;
					num = i;
				}
			}
			return PaletteNames[num];
		}

		private static string DescribeColor(Color color)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			float num = default(float);
			float num2 = default(float);
			float num3 = default(float);
			Color.RGBToHSV(color, ref num, ref num2, ref num3);
			float num4 = num * 360f;
			if (num2 < 0.1f)
			{
				if (num3 < 0.1f)
				{
					return "Black";
				}
				if (num3 < 0.23f)
				{
					return "Charcoal";
				}
				if (num3 < 0.4f)
				{
					return "Dark Gray";
				}
				if (num3 < 0.62f)
				{
					return "Gray";
				}
				if (num3 < 0.78f)
				{
					return "Silver";
				}
				if (num3 < 0.92f)
				{
					return "Light Gray";
				}
				return "White";
			}
			if (num3 < 0.18f)
			{
				if (num4 < 18f || num4 >= 345f)
				{
					return "Near-Black Red";
				}
				if (num4 < 55f)
				{
					return "Near-Black Brown";
				}
				if (num4 < 85f)
				{
					return "Near-Black Olive";
				}
				if (num4 < 170f)
				{
					return "Near-Black Green";
				}
				if (num4 < 205f)
				{
					return "Near-Black Teal";
				}
				if (num4 < 255f)
				{
					return "Near-Black Blue";
				}
				if (num4 < 300f)
				{
					return "Near-Black Purple";
				}
				return "Near-Black Magenta";
			}
			if (num4 >= 12f && num4 < 50f && num2 < 0.72f)
			{
				if (num3 < 0.42f)
				{
					return "Dark Brown";
				}
				if (num3 < 0.62f)
				{
					return "Brown";
				}
				if (num3 < 0.82f)
				{
					return "Tan";
				}
				return "Beige";
			}
			string text = ((num4 < 8f || num4 >= 352f) ? "Red" : ((num4 < 18f) ? "Scarlet" : ((num4 < 32f) ? "Orange" : ((num4 < 45f) ? "Amber" : ((num4 < 58f) ? "Gold" : ((num4 < 70f) ? "Yellow" : ((num4 < 88f) ? "Lime" : ((num4 < 112f) ? "Yellow-Green" : ((num4 < 145f) ? "Green" : ((num4 < 165f) ? "Mint Green" : ((num4 < 180f) ? "Teal" : ((num4 < 195f) ? "Turquoise" : ((num4 < 205f) ? "Cyan" : ((num4 < 218f) ? "Sky Blue" : ((num4 < 232f) ? "Azure" : ((num4 < 248f) ? "Blue" : ((num4 < 260f) ? "Royal Blue" : ((num4 < 272f) ? "Indigo" : ((num4 < 288f) ? "Violet" : ((num4 < 306f) ? "Purple" : ((num4 < 322f) ? "Magenta" : ((num4 < 335f) ? "Hot Pink" : ((!(num4 < 345f)) ? "Rose" : "Pink")))))))))))))))))))))));
			switch (text)
			{
			case "Blue":
			case "Royal Blue":
			case "Azure":
				if (num3 < 0.42f)
				{
					return "Navy";
				}
				break;
			}
			if (text == "Purple" && num2 < 0.42f && num3 > 0.72f)
			{
				return "Lavender";
			}
			if (text == "Violet" && num2 < 0.42f && num3 > 0.72f)
			{
				return "Lavender";
			}
			if ((text == "Pink" || text == "Rose") && num2 < 0.4f && num3 > 0.82f)
			{
				return "Light Pink";
			}
			if (text == "Orange" && num2 < 0.55f && num3 > 0.78f)
			{
				return "Peach";
			}
			if (text == "Red" && num2 < 0.58f && num3 > 0.72f)
			{
				return "Coral";
			}
			if (text == "Green" && num2 < 0.45f && num3 > 0.74f)
			{
				return "Light Green";
			}
			if (text == "Sky Blue" && num2 < 0.42f && num3 > 0.8f)
			{
				return "Light Blue";
			}
			if (num3 < 0.42f)
			{
				return "Dark " + text;
			}
			if (num3 > 0.86f && num2 < 0.58f && text != "Yellow" && text != "Gold" && text != "Lime")
			{
				return "Light " + text;
			}
			return text;
		}

		private void ClearHover()
		{
			_hoveredButton = null;
			_hoverText = string.Empty;
			_lastButtonId = 0;
		}

		private void OnGUI()
		{
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: 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_008a: Expected O, but got Unknown
			//IL_008f: Expected O, but got Unknown
			//IL_009a: 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_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Expected O, but got Unknown
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: 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_0158: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			if (_enabled.Value && _hoveredButton != null && !string.IsNullOrEmpty(_hoverText))
			{
				if (_boxStyle == null || _boxStyle.fontSize != _fontSize.Value)
				{
					_boxStyle = new GUIStyle(GUI.skin.box)
					{
						fontSize = Math.Max(12, _fontSize.Value),
						fontStyle = (FontStyle)1,
						alignment = (TextAnchor)4,
						padding = new RectOffset(12, 12, 7, 7)
					};
					_boxStyle.normal.textColor = Color.white;
				}
				Vector3 mousePosition = Input.mousePosition;
				GUIContent val = new GUIContent(_hoverText);
				Vector2 val2 = _boxStyle.CalcSize(val);
				val2.x = Math.Max(val2.x + 8f, 130f);
				val2.y = Math.Max(val2.y + 4f, 34f);
				float num = Mathf.Clamp(mousePosition.x + 18f, 6f, (float)Screen.width - val2.x - 6f);
				float num2 = Mathf.Clamp((float)Screen.height - mousePosition.y + 18f, 6f, (float)Screen.height - val2.y - 6f);
				GUI.Box(new Rect(num, num2, val2.x, val2.y), val, _boxStyle);
			}
		}
	}
}