Decompiled source of LevelChanger v1.0.1

PaulLevelChanger.dll

Decompiled 2 days ago
using System;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
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("PaulLevelChanger")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.1.0")]
[assembly: AssemblyInformationalVersion("1.0.1")]
[assembly: AssemblyProduct("PaulLevelChanger")]
[assembly: AssemblyTitle("PaulLevelChanger")]
[assembly: AssemblyVersion("1.0.1.0")]
[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 PaulLevelChanger
{
	[BepInPlugin("paul.repo.levelchanger", "LevelChanger", "1.0.1")]
	public class LevelChangerPlugin : BaseUnityPlugin
	{
		public const string PluginGuid = "paul.repo.levelchanger";

		public const string PluginName = "LevelChanger";

		public const string PluginVersion = "1.0.1";

		internal static ManualLogSource Log;

		internal static ConfigEntry<KeyCode> cfgToggleKey;

		internal static ConfigEntry<int> cfgDefaultLevel;

		internal static ConfigEntry<bool> cfgShowWarning;

		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_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Expected O, but got Unknown
			//IL_0094: 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)
			Log = ((BaseUnityPlugin)this).Logger;
			cfgToggleKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("General", "Toggle Key", (KeyCode)287, "Taste zum Oeffnen/Schliessen der Level Changer GUI.");
			cfgDefaultLevel = ((BaseUnityPlugin)this).Config.Bind<int>("General", "Default Level", 1, new ConfigDescription("Level, das beim Oeffnen der GUI vorausgefuellt wird.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 99999), Array.Empty<object>()));
			cfgShowWarning = ((BaseUnityPlugin)this).Config.Bind<bool>("GUI", "Show Warning", true, "Zeigt den Hinweis 'be careful - it only gets harder from here' an.");
			GameObject val = new GameObject("LevelChangerRunner");
			Object.DontDestroyOnLoad((Object)val);
			((Object)val).hideFlags = (HideFlags)61;
			val.AddComponent<LevelChangerRunner>();
			Log.LogInfo((object)string.Format("{0} v{1} geladen. Toggle: {2}", "LevelChanger", "1.0.1", cfgToggleKey.Value));
		}
	}
	public class LevelChangerRunner : MonoBehaviour
	{
		private bool guiVisible;

		private string levelInput = "1";

		private const float WindowWidth = 520f;

		private Rect windowRect = new Rect(80f, 140f, 520f, 10f);

		private bool centerOnNextOpen = true;

		private string statusText = "";

		private Color statusColor = Color.white;

		private float statusUntil;

		private bool stylesReady;

		private GUIStyle windowStyle;

		private GUIStyle headerBarStyle;

		private GUIStyle headerTextStyle;

		private GUIStyle closeBtnStyle;

		private GUIStyle bodyStyle;

		private GUIStyle mutedStyle;

		private GUIStyle warnStyle;

		private GUIStyle inputStyle;

		private GUIStyle quickBtnStyle;

		private GUIStyle loadBtnStyle;

		private GUIStyle footerStyle;

		private GUIStyle statusStyle;

		private static readonly Color ColPanel = Hex("#2C2C2A");

		private static readonly Color ColHeaderBg = Hex("#501313");

		private static readonly Color ColHeaderTx = Hex("#F7C1C1");

		private static readonly Color ColAccent = Hex("#A32D2D");

		private static readonly Color ColAccentHov = Hex("#B73A3A");

		private static readonly Color ColInputBg = Hex("#1A1418");

		private static readonly Color ColTextLight = Hex("#F1EFE8");

		private static readonly Color ColMuted = Hex("#B4B2A9");

		private static readonly Color ColFooter = Hex("#888780");

		private static readonly Color ColWarn = Hex("#EF9F27");

		private static readonly Color ColError = Hex("#F09595");

		private static readonly Color ColOk = Hex("#9FE1CB");

		private bool inputBlocked;

		private Texture2D cursorCoreTex;

		private Texture2D cursorGlowTex;

		private const int CornerRadius = 10;

		private static ManualLogSource Log => LevelChangerPlugin.Log;

		private static ConfigEntry<KeyCode> cfgToggleKey => LevelChangerPlugin.cfgToggleKey;

		private static ConfigEntry<int> cfgDefaultLevel => LevelChangerPlugin.cfgDefaultLevel;

		private static ConfigEntry<bool> cfgShowWarning => LevelChangerPlugin.cfgShowWarning;

		private void Start()
		{
			levelInput = cfgDefaultLevel.Value.ToString();
		}

		private void Update()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			if (!Input.GetKeyDown(cfgToggleKey.Value))
			{
				return;
			}
			guiVisible = !guiVisible;
			if (guiVisible)
			{
				centerOnNextOpen = true;
				if (string.IsNullOrEmpty(levelInput))
				{
					levelInput = cfgDefaultLevel.Value.ToString();
				}
			}
			else
			{
				ReleaseGameFrozen();
			}
		}

		private void LateUpdate()
		{
			if (!guiVisible)
			{
				if (inputBlocked)
				{
					ReleaseGameFrozen();
				}
			}
			else
			{
				HoldGameFrozen();
				SuppressGameCursor();
			}
		}

		private void OnDisable()
		{
			if (inputBlocked)
			{
				ReleaseGameFrozen();
			}
		}

		private void OnGUI()
		{
			//IL_000f: 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_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Expected O, but got Unknown
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			if (guiVisible)
			{
				EnsureStyles();
				Matrix4x4 matrix = GUI.matrix;
				float num = 1.5f;
				GUIUtility.ScaleAroundPivot(new Vector2(num, num), Vector2.zero);
				if (centerOnNextOpen && ((Rect)(ref windowRect)).height > 20f)
				{
					float num2 = (float)Screen.width / num;
					float num3 = (float)Screen.height / num;
					((Rect)(ref windowRect)).x = (num2 - ((Rect)(ref windowRect)).width) * 0.5f;
					((Rect)(ref windowRect)).y = (num3 - ((Rect)(ref windowRect)).height) * 0.5f;
					centerOnNextOpen = false;
				}
				windowRect = GUILayout.Window(742891, windowRect, new WindowFunction(DrawWindow), GUIContent.none, windowStyle, Array.Empty<GUILayoutOption>());
				GUI.matrix = matrix;
				DrawCustomCursor();
			}
		}

		private void DrawCustomCursor()
		{
			//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_0025: 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_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: 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_0079: 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_0097: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)cursorCoreTex == (Object)null) && !((Object)(object)cursorGlowTex == (Object)null))
			{
				Vector3 mousePosition = Input.mousePosition;
				Vector2 val = default(Vector2);
				((Vector2)(ref val))..ctor(mousePosition.x, (float)Screen.height - mousePosition.y);
				float num = 26f;
				float num2 = 9f;
				GUI.DrawTexture(new Rect(val.x - num / 2f, val.y - num / 2f, num, num), (Texture)(object)cursorGlowTex, (ScaleMode)0, true);
				GUI.DrawTexture(new Rect(val.x - num2 / 2f, val.y - num2 / 2f, num2, num2), (Texture)(object)cursorCoreTex, (ScaleMode)0, true);
			}
		}

		private void DrawWindow(int id)
		{
			//IL_0318: Unknown result type (might be due to invalid IL or missing references)
			//IL_032e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0334: Invalid comparison between Unknown and I4
			//IL_02df: Unknown result type (might be due to invalid IL or missing references)
			//IL_033c: Unknown result type (might be due to invalid IL or missing references)
			GUILayout.BeginHorizontal(headerBarStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(34f) });
			GUILayout.Label("LEVEL CHANGER", headerTextStyle, Array.Empty<GUILayoutOption>());
			GUILayout.FlexibleSpace();
			if (GUILayout.Button("X", closeBtnStyle, (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.Width(30f),
				GUILayout.Height(24f)
			}))
			{
				guiVisible = false;
				ReleaseGameFrozen();
			}
			GUILayout.EndHorizontal();
			GUILayout.BeginVertical(bodyStyle, Array.Empty<GUILayoutOption>());
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			GUILayout.Label("ZIEL-LEVEL", mutedStyle, Array.Empty<GUILayoutOption>());
			GUILayout.FlexibleSpace();
			if (cfgShowWarning.Value)
			{
				GUILayout.Label("! be careful - it only gets harder from here", warnStyle, Array.Empty<GUILayoutOption>());
			}
			GUILayout.EndHorizontal();
			GUILayout.Space(4f);
			string source = GUILayout.TextField(levelInput, 5, inputStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(40f) });
			levelInput = new string(source.Where(char.IsDigit).ToArray());
			GUILayout.Space(10f);
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			if (GUILayout.Button("+1", quickBtnStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(30f) }))
			{
				Bump(1);
			}
			GUILayout.Space(6f);
			if (GUILayout.Button("+10", quickBtnStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(30f) }))
			{
				Bump(10);
			}
			GUILayout.Space(6f);
			if (GUILayout.Button("+100", quickBtnStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(30f) }))
			{
				Bump(100);
			}
			GUILayout.Space(6f);
			if (GUILayout.Button("RST", quickBtnStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(30f) }))
			{
				levelInput = "1";
			}
			GUILayout.EndHorizontal();
			GUILayout.Space(12f);
			if (GUILayout.Button("LEVEL LADEN", loadBtnStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(42f) }))
			{
				TryChangeLevel();
			}
			GUILayout.Space(8f);
			int currentLevel = GetCurrentLevel();
			string text = (string.IsNullOrEmpty(levelInput) ? "?" : levelInput);
			string text2 = ((currentLevel > 0) ? currentLevel.ToString() : "?");
			GUILayout.Label("Aktuell: Level " + text2 + "  ->  Ziel: Level " + text, footerStyle, Array.Empty<GUILayoutOption>());
			if (!string.IsNullOrEmpty(statusText) && Time.unscaledTime < statusUntil)
			{
				statusStyle.normal.textColor = statusColor;
				GUILayout.Label(statusText, statusStyle, Array.Empty<GUILayoutOption>());
			}
			GUILayout.EndVertical();
			GUI.DragWindow(new Rect(0f, 0f, 10000f, 34f));
			if (Event.current != null && (int)Event.current.type == 7)
			{
				DrawCursorLocal(Event.current.mousePosition);
			}
		}

		private void DrawCursorLocal(Vector2 pos)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: 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_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)cursorCoreTex == (Object)null) && !((Object)(object)cursorGlowTex == (Object)null))
			{
				float num = 26f;
				float num2 = 9f;
				GUI.DrawTexture(new Rect(pos.x - num / 2f, pos.y - num / 2f, num, num), (Texture)(object)cursorGlowTex, (ScaleMode)0, true);
				GUI.DrawTexture(new Rect(pos.x - num2 / 2f, pos.y - num2 / 2f, num2, num2), (Texture)(object)cursorCoreTex, (ScaleMode)0, true);
			}
		}

		private void Bump(int amount)
		{
			int.TryParse(levelInput, out var result);
			levelInput = Mathf.Clamp(result + amount, 1, 99999).ToString();
		}

		private void SetStatus(string text, Color color, float seconds = 4f)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			statusText = text;
			statusColor = color;
			statusUntil = Time.unscaledTime + seconds;
		}

		private void TryChangeLevel()
		{
			//IL_02a2: 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_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_0262: Unknown result type (might be due to invalid IL or missing references)
			if (!int.TryParse(levelInput, out var result) || result < 1)
			{
				SetStatus("Bitte eine gueltige Levelnummer eingeben.", ColError);
				return;
			}
			result = Mathf.Clamp(result, 1, 99999);
			if (!IsHostOrSingleplayer(out var reason))
			{
				SetStatus(reason, ColError);
				return;
			}
			if (!IsInRun())
			{
				SetStatus("Starte erst eine Mission, dann kannst du das Level wechseln.", ColWarn);
				return;
			}
			try
			{
				Type type = FindType("RunManager");
				if (type == null)
				{
					SetStatus("RunManager nicht gefunden (Game-Update?).", ColError);
					return;
				}
				object staticMemberValue = GetStaticMemberValue(type, "instance");
				if (staticMemberValue == null)
				{
					SetStatus("RunManager.instance ist null.", ColError);
					return;
				}
				FieldInfo field = type.GetField("levelsCompleted", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				if (field == null)
				{
					SetStatus("Feld 'levelsCompleted' nicht gefunden.", ColError);
					return;
				}
				field.SetValue(staticMemberValue, result - 1);
				MethodInfo methodInfo = (from m in type.GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)
					where m.Name == "ChangeLevel"
					orderby m.GetParameters().Length descending
					select m).FirstOrDefault();
				if (methodInfo == null)
				{
					SetStatus("Methode 'ChangeLevel' nicht gefunden.", ColError);
					return;
				}
				ParameterInfo[] parameters = methodInfo.GetParameters();
				object[] array = new object[parameters.Length];
				bool flag = true;
				for (int num = 0; num < parameters.Length; num++)
				{
					Type parameterType = parameters[num].ParameterType;
					if (parameterType == typeof(bool))
					{
						array[num] = flag;
						flag = false;
					}
					else if (parameterType.IsEnum)
					{
						array[num] = GetEnumValue(parameterType, "RunLevel", "Normal");
					}
					else if (parameters[num].HasDefaultValue)
					{
						array[num] = parameters[num].DefaultValue;
					}
					else
					{
						array[num] = (parameterType.IsValueType ? Activator.CreateInstance(parameterType) : null);
					}
				}
				methodInfo.Invoke(staticMemberValue, array);
				SetStatus($"Level {result} wird geladen...", ColOk);
				Log.LogInfo((object)$"ChangeLevel -> {result} ausgeloest.");
				guiVisible = false;
				ReleaseGameFrozen();
			}
			catch (Exception arg)
			{
				SetStatus("Fehler beim Levelwechsel - siehe BepInEx-Log.", ColError);
				Log.LogError((object)$"Levelwechsel fehlgeschlagen: {arg}");
			}
		}

		private int GetCurrentLevel()
		{
			try
			{
				Type type = FindType("RunManager");
				object obj = ((type == null) ? null : GetStaticMemberValue(type, "instance"));
				if (obj == null)
				{
					return -1;
				}
				FieldInfo field = type.GetField("levelsCompleted", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				if (field == null)
				{
					return -1;
				}
				return (int)field.GetValue(obj) + 1;
			}
			catch
			{
				return -1;
			}
		}

		private void HoldGameFrozen()
		{
			try
			{
				Type type = FindType("GameDirector");
				object obj = ((type == null) ? null : GetStaticMemberValue(type, "instance"));
				if (obj != null)
				{
					MethodInfo method = type.GetMethod("SetDisableInput", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, new Type[1] { typeof(float) }, null);
					if (method != null)
					{
						method.Invoke(obj, new object[1] { 0.1f });
					}
				}
				inputBlocked = true;
			}
			catch
			{
			}
		}

		private void SuppressGameCursor()
		{
			try
			{
				Type type = FindType("CursorManager");
				object obj = ((type == null) ? null : GetStaticMemberValue(type, "instance"));
				if (obj != null)
				{
					MethodInfo method = type.GetMethod("Unlock", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, new Type[1] { typeof(float) }, null);
					if (method != null)
					{
						method.Invoke(obj, new object[1] { 0.1f });
					}
				}
				Type type2 = FindType("MenuCursor");
				object obj2 = ((type2 == null) ? null : GetStaticMemberValue(type2, "instance"));
				if (obj2 == null)
				{
					return;
				}
				FieldInfo field = type2.GetField("mesh", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				if (field != null)
				{
					object? value = field.GetValue(obj2);
					GameObject val = (GameObject)((value is GameObject) ? value : null);
					if (val != null && (Object)(object)val != (Object)null && val.activeSelf)
					{
						val.SetActive(false);
					}
				}
				SetFloatField(type2, obj2, "showTimer", 0f);
				SetFloatField(type2, obj2, "overridePosTimer", 0.1f);
			}
			catch
			{
			}
		}

		private void ReleaseGameFrozen()
		{
			inputBlocked = false;
		}

		private static void SetFloatField(Type type, object inst, string name, float value)
		{
			FieldInfo field = type.GetField(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			if (field != null && field.FieldType == typeof(float))
			{
				field.SetValue(inst, value);
			}
		}

		private static bool IsHostOrSingleplayer(out string reason)
		{
			reason = null;
			try
			{
				Type type = FindType("Photon.Pun.PhotonNetwork");
				if (type == null)
				{
					return true;
				}
				if (!GetStaticBool(type, "InRoom"))
				{
					return true;
				}
				if (!GetStaticBool(type, "IsMasterClient"))
				{
					reason = "Nur der HOST kann das Level wechseln!";
					return false;
				}
				return true;
			}
			catch
			{
				return true;
			}
		}

		private static bool IsInRun()
		{
			try
			{
				Type type = FindType("SemiFunc");
				if (type == null)
				{
					return true;
				}
				bool flag = InvokeStaticBool(type, "RunIsLevel");
				bool flag2 = InvokeStaticBool(type, "RunIsShop");
				return flag || flag2;
			}
			catch
			{
				return true;
			}
		}

		private static Type FindType(string fullName)
		{
			Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
			foreach (Assembly assembly in assemblies)
			{
				try
				{
					Type type = assembly.GetType(fullName, throwOnError: false);
					if (type != null)
					{
						return type;
					}
				}
				catch
				{
				}
			}
			return null;
		}

		private static object GetStaticMemberValue(Type type, string name)
		{
			FieldInfo field = type.GetField(name, BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
			if (field != null)
			{
				return field.GetValue(null);
			}
			PropertyInfo property = type.GetProperty(name, BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
			if (property != null)
			{
				return property.GetValue(null);
			}
			return null;
		}

		private static bool GetStaticBool(Type type, string propertyName)
		{
			object staticMemberValue = GetStaticMemberValue(type, propertyName);
			bool flag = default(bool);
			int num;
			if (staticMemberValue is bool)
			{
				flag = (bool)staticMemberValue;
				num = 1;
			}
			else
			{
				num = 0;
			}
			return (byte)((uint)num & (flag ? 1u : 0u)) != 0;
		}

		private static bool InvokeStaticBool(Type type, string methodName)
		{
			MethodInfo method = type.GetMethod(methodName, BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic, null, Type.EmptyTypes, null);
			if (method == null || method.ReturnType != typeof(bool))
			{
				return false;
			}
			object obj = method.Invoke(null, null);
			bool flag = default(bool);
			int num;
			if (obj is bool)
			{
				flag = (bool)obj;
				num = 1;
			}
			else
			{
				num = 0;
			}
			return (byte)((uint)num & (flag ? 1u : 0u)) != 0;
		}

		private static object GetEnumValue(Type enumType, params string[] preferredNames)
		{
			foreach (string value in preferredNames)
			{
				try
				{
					if (Enum.IsDefined(enumType, value))
					{
						return Enum.Parse(enumType, value);
					}
				}
				catch
				{
				}
			}
			Array values = Enum.GetValues(enumType);
			if (values.Length <= 0)
			{
				return Activator.CreateInstance(enumType);
			}
			return values.GetValue(0);
		}

		private static Color Hex(string hex)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			Color result = default(Color);
			ColorUtility.TryParseHtmlString(hex, ref result);
			return result;
		}

		private static Texture2D SolidTex(Color color)
		{
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: 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_0012: 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_0021: Expected O, but got Unknown
			Texture2D val = new Texture2D(1, 1, (TextureFormat)4, false);
			val.SetPixel(0, 0, color);
			val.Apply();
			((Object)val).hideFlags = (HideFlags)61;
			return val;
		}

		private static Texture2D BuildDotTexture(int size, Color inner, Color outer, float coreRadius)
		{
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Expected O, but got Unknown
			//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_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: 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)
			Texture2D val = new Texture2D(size, size, (TextureFormat)4, false);
			((Object)val).hideFlags = (HideFlags)61;
			((Texture)val).filterMode = (FilterMode)1;
			((Texture)val).wrapMode = (TextureWrapMode)1;
			float num = (float)(size - 1) / 2f;
			float num2 = num;
			Color[] array = (Color[])(object)new Color[size * size];
			for (int i = 0; i < size; i++)
			{
				for (int j = 0; j < size; j++)
				{
					float num3 = (float)j - num;
					float num4 = (float)i - num;
					float num5 = Mathf.Clamp01(Mathf.Sqrt(num3 * num3 + num4 * num4) / num2);
					Color val2;
					if (num5 <= coreRadius)
					{
						val2 = inner;
					}
					else
					{
						float num6 = 1f - Mathf.InverseLerp(coreRadius, 1f, num5);
						val2 = outer;
						val2.a *= num6 * num6;
					}
					array[i * size + j] = val2;
				}
			}
			val.SetPixels(array);
			val.Apply();
			return val;
		}

		private static Texture2D RoundedTex(Color color, int radius, bool tl = true, bool tr = true, bool bl = true, bool br = true)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			//IL_004a: 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_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			int num = radius * 2 + 2;
			Texture2D val = new Texture2D(num, num, (TextureFormat)4, false);
			((Object)val).hideFlags = (HideFlags)61;
			((Texture)val).wrapMode = (TextureWrapMode)1;
			((Texture)val).filterMode = (FilterMode)1;
			Color[] array = (Color[])(object)new Color[num * num];
			for (int i = 0; i < num; i++)
			{
				for (int j = 0; j < num; j++)
				{
					float num2 = CornerAlpha(j, i, num, radius, tl, tr, bl, br);
					Color val2 = color;
					val2.a *= num2;
					array[i * num + j] = val2;
				}
			}
			val.SetPixels(array);
			val.Apply();
			return val;
		}

		private static float CornerAlpha(int x, int y, int size, int r, bool tl, bool tr, bool bl, bool br)
		{
			bool flag = false;
			float num;
			float num2;
			if (x < r && y >= size - r && tl)
			{
				num = r;
				num2 = size - r;
				flag = true;
			}
			else if (x >= size - r && y >= size - r && tr)
			{
				num = size - r;
				num2 = size - r;
				flag = true;
			}
			else if (x < r && y < r && bl)
			{
				num = r;
				num2 = r;
				flag = true;
			}
			else if (x >= size - r && y < r && br)
			{
				num = size - r;
				num2 = r;
				flag = true;
			}
			else
			{
				num = 0f;
				num2 = 0f;
			}
			if (!flag)
			{
				return 1f;
			}
			float num3 = Mathf.Sqrt(((float)x - num + 0.5f) * ((float)x - num + 0.5f) + ((float)y - num2 + 0.5f) * ((float)y - num2 + 0.5f));
			return Mathf.Clamp01((float)r - num3 + 0.5f);
		}

		private void EnsureStyles()
		{
			//IL_0040: 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_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: 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_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Expected O, but got Unknown
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Expected O, but got Unknown
			//IL_00e9: 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_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Expected O, but got Unknown
			//IL_011d: 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_0130: Expected O, but got Unknown
			//IL_0135: Expected O, but got Unknown
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: Expected O, but got Unknown
			//IL_0167: Unknown result type (might be due to invalid IL or missing references)
			//IL_016c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0182: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: Unknown result type (might be due to invalid IL or missing references)
			//IL_0192: 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)
			//IL_01ac: 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_01bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01db: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e5: Expected O, but got Unknown
			//IL_01ea: Expected O, but got Unknown
			//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f0: 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_0203: Expected O, but got Unknown
			//IL_0208: Expected O, but got Unknown
			//IL_0209: Unknown result type (might be due to invalid IL or missing references)
			//IL_020e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0216: Unknown result type (might be due to invalid IL or missing references)
			//IL_021c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0226: Unknown result type (might be due to invalid IL or missing references)
			//IL_0232: Expected O, but got Unknown
			//IL_0233: Unknown result type (might be due to invalid IL or missing references)
			//IL_0238: Unknown result type (might be due to invalid IL or missing references)
			//IL_0240: 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_024d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0257: Unknown result type (might be due to invalid IL or missing references)
			//IL_0263: Expected O, but got Unknown
			//IL_0264: Unknown result type (might be due to invalid IL or missing references)
			//IL_0269: Unknown result type (might be due to invalid IL or missing references)
			//IL_0271: Unknown result type (might be due to invalid IL or missing references)
			//IL_0277: Unknown result type (might be due to invalid IL or missing references)
			//IL_0281: Unknown result type (might be due to invalid IL or missing references)
			//IL_0287: 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_02a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02db: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fe: Expected O, but got Unknown
			//IL_02fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0305: Unknown result type (might be due to invalid IL or missing references)
			//IL_030f: Expected O, but got Unknown
			//IL_030f: Unknown result type (might be due to invalid IL or missing references)
			//IL_031b: Expected O, but got Unknown
			//IL_031c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0321: Unknown result type (might be due to invalid IL or missing references)
			//IL_0329: Unknown result type (might be due to invalid IL or missing references)
			//IL_0330: Unknown result type (might be due to invalid IL or missing references)
			//IL_0336: Unknown result type (might be due to invalid IL or missing references)
			//IL_0340: Unknown result type (might be due to invalid IL or missing references)
			//IL_0346: Unknown result type (might be due to invalid IL or missing references)
			//IL_035a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0360: Unknown result type (might be due to invalid IL or missing references)
			//IL_036a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0375: Unknown result type (might be due to invalid IL or missing references)
			//IL_0389: Unknown result type (might be due to invalid IL or missing references)
			//IL_038f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0399: Unknown result type (might be due to invalid IL or missing references)
			//IL_039f: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c2: Expected O, but got Unknown
			//IL_03c7: Expected O, but got Unknown
			//IL_03c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0412: Unknown result type (might be due to invalid IL or missing references)
			//IL_0418: Unknown result type (might be due to invalid IL or missing references)
			//IL_0422: Unknown result type (might be due to invalid IL or missing references)
			//IL_0428: Unknown result type (might be due to invalid IL or missing references)
			//IL_043c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0442: Unknown result type (might be due to invalid IL or missing references)
			//IL_044c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0452: Unknown result type (might be due to invalid IL or missing references)
			//IL_0466: Unknown result type (might be due to invalid IL or missing references)
			//IL_046b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0475: Expected O, but got Unknown
			//IL_047a: Expected O, but got Unknown
			//IL_047b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0480: Unknown result type (might be due to invalid IL or missing references)
			//IL_0488: Unknown result type (might be due to invalid IL or missing references)
			//IL_048e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0498: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a4: Expected O, but got Unknown
			//IL_04a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_04aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d5: Expected O, but got Unknown
			//IL_0083: 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)
			if (stylesReady)
			{
				GUIStyle obj = windowStyle;
				object obj2;
				if (obj == null)
				{
					obj2 = null;
				}
				else
				{
					GUIStyleState normal = obj.normal;
					obj2 = ((normal != null) ? normal.background : null);
				}
				if ((Object)obj2 != (Object)null)
				{
					return;
				}
			}
			if ((Object)(object)cursorCoreTex == (Object)null)
			{
				cursorCoreTex = BuildDotTexture(16, Color.white, new Color(1f, 1f, 1f, 0.9f), 0.45f);
			}
			if ((Object)(object)cursorGlowTex == (Object)null)
			{
				cursorGlowTex = BuildDotTexture(48, Hex("#F09595"), Hex("#A32D2D"), 0.12f);
			}
			GUIStyle val = new GUIStyle();
			val.normal.background = RoundedTex(ColPanel, 10);
			val.border = new RectOffset(10, 10, 10, 10);
			val.padding = new RectOffset(0, 0, 0, 0);
			windowStyle = val;
			GUIStyle val2 = new GUIStyle();
			val2.normal.background = RoundedTex(ColHeaderBg, 10, tl: true, tr: true, bl: false, br: false);
			val2.border = new RectOffset(10, 10, 10, 10);
			val2.padding = new RectOffset(16, 12, 9, 9);
			headerBarStyle = val2;
			GUIStyle val3 = new GUIStyle
			{
				fontSize = 15,
				fontStyle = (FontStyle)1
			};
			val3.normal.textColor = ColHeaderTx;
			val3.alignment = (TextAnchor)3;
			headerTextStyle = val3;
			GUIStyle val4 = new GUIStyle
			{
				fontSize = 13,
				fontStyle = (FontStyle)1,
				alignment = (TextAnchor)4
			};
			val4.normal.textColor = ColError;
			val4.normal.background = RoundedTex(ColHeaderBg, 6);
			val4.hover.textColor = Color.white;
			val4.hover.background = RoundedTex(ColAccent, 6);
			val4.border = new RectOffset(6, 6, 6, 6);
			closeBtnStyle = val4;
			bodyStyle = new GUIStyle
			{
				padding = new RectOffset(16, 16, 12, 14)
			};
			GUIStyle val5 = new GUIStyle
			{
				fontSize = 12
			};
			val5.normal.textColor = ColMuted;
			val5.alignment = (TextAnchor)3;
			mutedStyle = val5;
			GUIStyle val6 = new GUIStyle
			{
				fontSize = 11,
				fontStyle = (FontStyle)2
			};
			val6.normal.textColor = ColWarn;
			val6.alignment = (TextAnchor)5;
			warnStyle = val6;
			GUIStyle val7 = new GUIStyle
			{
				fontSize = 20
			};
			val7.normal.textColor = ColTextLight;
			val7.normal.background = RoundedTex(ColInputBg, 8);
			val7.focused.textColor = ColTextLight;
			val7.focused.background = RoundedTex(ColInputBg, 8);
			val7.hover.textColor = ColTextLight;
			val7.hover.background = RoundedTex(ColInputBg, 8);
			val7.border = new RectOffset(8, 8, 8, 8);
			val7.padding = new RectOffset(14, 14, 8, 8);
			val7.alignment = (TextAnchor)3;
			inputStyle = val7;
			GUIStyle val8 = new GUIStyle
			{
				fontSize = 13,
				alignment = (TextAnchor)4
			};
			val8.normal.textColor = ColMuted;
			val8.normal.background = RoundedTex(ColInputBg, 8);
			val8.hover.textColor = ColTextLight;
			val8.hover.background = RoundedTex(Hex("#3A3230"), 8);
			val8.active.textColor = ColTextLight;
			val8.active.background = RoundedTex(ColAccent, 8);
			val8.border = new RectOffset(8, 8, 8, 8);
			quickBtnStyle = val8;
			GUIStyle val9 = new GUIStyle
			{
				fontSize = 15,
				fontStyle = (FontStyle)1,
				alignment = (TextAnchor)4
			};
			val9.normal.textColor = Hex("#FCEBEB");
			val9.normal.background = RoundedTex(ColAccent, 8);
			val9.hover.textColor = Color.white;
			val9.hover.background = RoundedTex(ColAccentHov, 8);
			val9.active.textColor = Color.white;
			val9.active.background = RoundedTex(ColHeaderBg, 8);
			val9.border = new RectOffset(8, 8, 8, 8);
			loadBtnStyle = val9;
			GUIStyle val10 = new GUIStyle
			{
				fontSize = 11
			};
			val10.normal.textColor = ColFooter;
			val10.alignment = (TextAnchor)4;
			footerStyle = val10;
			GUIStyle val11 = new GUIStyle
			{
				fontSize = 12,
				fontStyle = (FontStyle)1,
				alignment = (TextAnchor)4
			};
			val11.normal.textColor = ColTextLight;
			statusStyle = val11;
			stylesReady = true;
		}
	}
}