Decompiled source of SkToolbox Reupload v1.6.0

FTKSkToolbox.dll

Decompiled 8 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Net;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Text;
using System.Text.RegularExpressions;
using BepInEx;
using GridEditor;
using HarmonyLib;
using SkToolbox.Commands;
using SkToolbox.Loaders;
using SkToolbox.SkModules;
using SkToolbox.Utility;
using StatsAchievements;
using UnityEngine;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("ForTheKing")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Skrip @ The Last Echelon")]
[assembly: AssemblyProduct("ForTheKing SkToolbox")]
[assembly: AssemblyCopyright("Copyright ©  2021")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("5c847245-1b68-4fca-992f-ff439f87ef20")]
[assembly: AssemblyFileVersion("1.5.0.0")]
[assembly: AssemblyVersion("1.5.0.0")]
namespace SkToolbox
{
	[BepInPlugin("com.Skrip.SkToolboxForTheKing", "SkToolboxForTheKing", "1.5.0.0")]
	internal class SkBepInExLoader : BaseUnityPlugin
	{
		public const string MODNAME = "SkToolboxForTheKing";

		public const string AUTHOR = "Skrip";

		public const string GUID = "com.Skrip.SkToolboxForTheKing";

		public const string VERSION = "1.5.0.0";

		private void Start()
		{
			((Component)this).transform.parent = null;
			Object.DontDestroyOnLoad((Object)(object)this);
			SkLoader.Init();
		}
	}
	public class SkCommandProcessor
	{
		private static SkCommandProcessor _instance;

		private List<SkCommand> commandList = new List<SkCommand>();

		public static SkCommandProcessor Instance
		{
			get
			{
				if (_instance == null)
				{
					_instance = new SkCommandProcessor();
				}
				return _instance;
			}
		}

		public List<SkCommand> CommandList
		{
			get
			{
				return commandList;
			}
			set
			{
				commandList = value;
			}
		}

		public void AddCommand(SkCommand newCommand, bool sort = true)
		{
			if (CommandExists(newCommand))
			{
				SkUtilities.Logz(new string[3] { "CONSOLE", "ADDCMD", "ERR" }, new string[2]
				{
					"Command '" + newCommand.Command + "' already exists.",
					newCommand.GetType().ToString()
				}, (LogType)3);
				return;
			}
			if (newCommand.Command.Contains("\""))
			{
				SkUtilities.Logz(new string[3] { "CONSOLE", "ADDCMD", "ERR" }, new string[2] { "Command cannot contain a quote in the name.", newCommand.Command }, (LogType)3);
				return;
			}
			if (newCommand.Command.Contains(" "))
			{
				SkUtilities.Logz(new string[3] { "CONSOLE", "ADDCMD", "ERR" }, new string[2] { "Command cannot contain a space in the name.", newCommand.Command }, (LogType)3);
				return;
			}
			CommandList.Add(newCommand);
			if (sort)
			{
				CommandList.Sort((SkCommand cmdA, SkCommand cmdB) => cmdA.Command.CompareTo(cmdB.Command));
			}
		}

		public void SortCommands()
		{
			CommandList.Sort((SkCommand cmdA, SkCommand cmdB) => cmdA.Command.CompareTo(cmdB.Command));
		}

		public bool CommandExists(SkCommand command)
		{
			if (CommandList.Exists((SkCommand cmd) => cmd.Command == command.Command))
			{
				return true;
			}
			return false;
		}

		public void ExecuteCommand(string commandString)
		{
			if (string.IsNullOrEmpty(commandString))
			{
				return;
			}
			string[] array = commandString.Split(new char[1] { ';' });
			for (int i = 0; i < array.Length; i++)
			{
				string text = array[i].Trim();
				if (string.IsNullOrEmpty(text))
				{
					continue;
				}
				string[] commandSpl = text.Split(new char[1] { ' ' });
				SkCommand skCommand = Instance.CommandList.FirstOrDefault((SkCommand cmd) => cmd.Command.Equals(commandSpl[0], StringComparison.InvariantCultureIgnoreCase));
				if (skCommand != null)
				{
					string[] args = (from Match p in Regex.Matches(text, "\"[^\"]+\"|\\S+")
						select p.Value.Trim(new char[1] { '"' })).Skip(1).ToArray();
					try
					{
						skCommand.Execute(args);
					}
					catch (Exception ex)
					{
						SkUtilities.Logz(new string[2] { "CONTROLLER", "ERROR" }, new string[2] { "Command executed but failed.", ex.Message }, (LogType)3);
					}
				}
			}
		}

		public void DiscoverCommands()
		{
			foreach (SkCommand item in SkUtilities.FindImplementationsByType<SkCommand>(typeof(SkCommand)))
			{
				if (item.Enabled)
				{
					Instance.AddCommand(item, sort: false);
				}
			}
			Instance.SortCommands();
		}
	}
	internal class SkConsole : MonoBehaviour
	{
		private class History
		{
			public List<string> history = new List<string>();

			private int index;

			private string current;

			public void Add(string item)
			{
				history.Add(item);
				index = 0;
			}

			public string Fetch(string current, bool next)
			{
				if (index == 0)
				{
					this.current = current;
				}
				if (history.Count == 0)
				{
					return current;
				}
				index += ((!next) ? 1 : (-1));
				if (history.Count + index < 0 || history.Count + index > history.Count - 1)
				{
					index = 0;
					return this.current;
				}
				return history[history.Count + index];
			}
		}

		public static Version SkConsoleVersion = new Version(1, 1, 1);

		public KeyCode toggleKey = (KeyCode)96;

		public bool openOnStart;

		public bool shakeToOpen;

		public bool shakeRequiresTouch;

		public float shakeAcceleration = 3f;

		public float toggleThresholdSeconds = 0.5f;

		private float lastToggleTime;

		public bool restrictLogCount = true;

		public int maxLogCount = 150;

		public int logFontSize = 12;

		private int logLineNumber;

		public float scaleFactor = 1f;

		public static bool writeToFile = false;

		public static bool cursorUnlock = false;

		public static bool enableInput = true;

		private string logSavePath;

		private History consoleHistory = new History();

		private static readonly GUIContent clearLabel = new GUIContent("Clear", "Clear the contents of the console.");

		private static readonly GUIContent submitLabel = new GUIContent("Submit", "Submit the input.");

		private static string inputString = string.Empty;

		private static readonly GUIContent collapseLabel = new GUIContent("Collapse", "Hide repeated messages.");

		private const int margin = 150;

		private const string windowTitle = "SkToolbox [Console]";

		private static readonly Dictionary<LogType, Color> logTypeColors = new Dictionary<LogType, Color>
		{
			{
				(LogType)3,
				Color.white
			},
			{
				(LogType)1,
				Color.white
			},
			{
				(LogType)2,
				Color.yellow
			},
			{
				(LogType)0,
				Color.red
			},
			{
				(LogType)4,
				Color.red
			}
		};

		private bool isCollapsed;

		private bool isVisible;

		private bool announcedCmds;

		private Font customFont;

		private readonly List<Log> logs = new List<Log>();

		private readonly ConcurrentQueue<Log> queuedLogs = new ConcurrentQueue<Log>();

		private Vector2 scrollPosition;

		private readonly Rect titleBarRect = new Rect(0f, 0f, 10000f, 21f);

		private float windowX = 150f;

		private float windowY = 150f;

		private float width;

		private float height;

		private TextEditor editor;

		private string suggestedCommands = string.Empty;

		private string previousInput = string.Empty;

		private bool singleFrame = true;

		private List<LogType> lFKeys;

		private readonly Dictionary<LogType, bool> logTypeFilters = new Dictionary<LogType, bool>
		{
			{
				(LogType)3,
				true
			},
			{
				(LogType)1,
				false
			},
			{
				(LogType)2,
				false
			},
			{
				(LogType)0,
				false
			},
			{
				(LogType)4,
				false
			}
		};

		public bool NewInput
		{
			get
			{
				if (!previousInput.Equals(inputString))
				{
					previousInput = inputString;
					return true;
				}
				return false;
			}
		}

		private void OnDisable()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			Application.logMessageReceivedThreaded -= new LogCallback(HandleLogThreaded);
		}

		private void OnEnable()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			Application.logMessageReceivedThreaded += new LogCallback(HandleLogThreaded);
		}

		private void Start()
		{
			lFKeys = logTypeFilters.Keys.ToList();
			logSavePath = Application.persistentDataPath + "/!SkToolbox Console Log.txt";
			if (openOnStart)
			{
				isVisible = true;
			}
			SkCommandProcessor.Instance.DiscoverCommands();
			customFont = Font.CreateDynamicFontFromOSFont("Consolas.ttf", logFontSize);
			width = (float)Screen.width / scaleFactor - 300f;
			height = (float)Screen.height / scaleFactor - 300f;
			width = Mathf.Clamp(width, 100f, 1280f);
			height = Mathf.Clamp(height, 100f, 720f);
			windowX = (float)(Screen.width / 2) - width / 2f;
			windowY = (float)(Screen.height / 2) - height / 2f;
		}

		private void OnGUI()
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Invalid comparison between Unknown and I4
			//IL_0250: 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_028e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0296: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ab: Expected O, but got Unknown
			//IL_02a6: 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_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Invalid comparison between Unknown and I4
			//IL_0378: Unknown result type (might be due to invalid IL or missing references)
			//IL_037e: Invalid comparison between Unknown and I4
			//IL_02e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ec: Invalid comparison between Unknown and I4
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Invalid comparison between Unknown and I4
			//IL_0385: Unknown result type (might be due to invalid IL or missing references)
			//IL_038c: Invalid comparison between Unknown and I4
			//IL_02fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0316: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Expected I4, but got Unknown
			//IL_03a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0237: Unknown result type (might be due to invalid IL or missing references)
			Event current = Event.current;
			if (current.isKey && (int)current.keyCode == 96)
			{
				isVisible = !isVisible;
				inputString = string.Empty;
			}
			if (!isVisible)
			{
				return;
			}
			GUI.FocusControl("inputBar");
			if (current.isKey && singleFrame)
			{
				KeyCode keyCode = current.keyCode;
				if ((int)keyCode != 9)
				{
					if ((int)keyCode != 13)
					{
						switch (keyCode - 271)
						{
						case 2:
							inputString = consoleHistory.Fetch(inputString, next: true);
							editor.MoveCursorToPosition(new Vector2(0f, 9999f));
							break;
						case 3:
							inputString = consoleHistory.Fetch(inputString, next: false);
							break;
						case 0:
							if (!inputString.Equals(string.Empty))
							{
								HandleInput(inputString);
								ScrollToBottom();
							}
							break;
						}
					}
					else if (!inputString.Equals(string.Empty))
					{
						HandleInput(inputString);
						ScrollToBottom();
					}
				}
				else if (!string.IsNullOrEmpty(inputString))
				{
					singleFrame = false;
					try
					{
						string[] array = inputString.Split(new char[1] { ';' });
						string inputSplit2 = array[^1].Trim().Split(new char[1] { ' ' })[0];
						SkCommand skCommand = SkCommandProcessor.Instance.CommandList.Where((SkCommand cmd) => cmd.Command.StartsWith(inputSplit2, StringComparison.InvariantCultureIgnoreCase) && !cmd.Command.Equals(inputSplit2)).First();
						if (!string.IsNullOrEmpty(skCommand.Command))
						{
							if (array.Length > 1)
							{
								inputString = string.Empty;
								for (int i = 0; i < array.Length - 1; i++)
								{
									inputString = inputString + array[i].Trim() + "; ";
								}
								inputString += skCommand.Command;
							}
							else
							{
								inputString = skCommand.Command;
							}
						}
						editor.MoveCursorToPosition(new Vector2(0f, 9999f));
					}
					catch (Exception)
					{
					}
				}
				Event.current.Use();
			}
			GUI.matrix = Matrix4x4.Scale(Vector3.one * scaleFactor);
			Rect val = default(Rect);
			((Rect)(ref val))..ctor(windowX, windowY, width, height);
			Rect val2 = GUILayout.Window(8675309, val, new WindowFunction(DrawWindow), "SkToolbox [Console]", (GUILayoutOption[])(object)new GUILayoutOption[0]);
			windowX = ((Rect)(ref val2)).x;
			windowY = ((Rect)(ref val2)).y;
			int button = Event.current.button;
			if (button != 0 && button == 1 && (int)Event.current.type == 3)
			{
				width += Event.current.delta.x;
				height += Event.current.delta.y;
				width = Mathf.Clamp(width, 426f, 9999f);
				height = Mathf.Clamp(height, 240f, 9999f);
				Event.current.Use();
			}
			if (cursorUnlock)
			{
				unlockCursor();
			}
			if ((int)Event.current.type == 5 && (int)Event.current.keyCode == 9)
			{
				singleFrame = true;
				editor.MoveCursorToPosition(new Vector2(0f, 9999f));
			}
		}

		private void Update()
		{
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01be: Unknown result type (might be due to invalid IL or missing references)
			if ((!announcedCmds && SkMenuController.SkMenuControllerStatus == SkUtilities.Status.Ready) || (!announcedCmds && !SkLoader.MenuEnabled))
			{
				SkUtilities.Logz(new string[3] { "TOOLBOX", "CONSOLE", "NOTIFY" }, new string[2]
				{
					SkCommandProcessor.Instance.CommandList.Count + " COMMANDS LOADED",
					"STATUS: READY"
				}, (LogType)3);
				announcedCmds = true;
			}
			UpdateQueuedLogs();
			float realtimeSinceStartup = Time.realtimeSinceStartup;
			if (Input.GetKeyDown(toggleKey))
			{
				isVisible = !isVisible;
				if (!isVisible)
				{
					inputString = string.Empty;
				}
				else
				{
					ScrollToBottom();
					GUI.FocusControl("inputBar");
				}
			}
			if (isVisible)
			{
				if (!string.IsNullOrEmpty(inputString))
				{
					if (!NewInput)
					{
						suggestedCommands = string.Empty;
						string commandOnRight = editor.text.Split(new char[1] { ';' })[^1].Trim().Split(new char[1] { ' ' })[0];
						foreach (SkCommand item in SkCommandProcessor.Instance.CommandList.Where((SkCommand cmd) => cmd.Command.ToLower().Contains(commandOnRight.ToLower()) && cmd.VisibilityFlag != SkCommandEnum.VisiblityFlag.Hidden && cmd.VisibilityFlag != SkCommandEnum.VisiblityFlag.FullHidden).ToList())
						{
							suggestedCommands = suggestedCommands + item.Command + " ";
						}
					}
				}
				else
				{
					suggestedCommands = string.Empty;
				}
			}
			if (shakeToOpen)
			{
				Vector3 acceleration = Input.acceleration;
				if (((Vector3)(ref acceleration)).sqrMagnitude > shakeAcceleration && realtimeSinceStartup - lastToggleTime >= toggleThresholdSeconds && (!shakeRequiresTouch || Input.touchCount > 2))
				{
					isVisible = !isVisible;
					lastToggleTime = realtimeSinceStartup;
				}
			}
		}

		private void DrawLog(Log log, GUIStyle logStyle, GUIStyle badgeStyle)
		{
			//IL_0006: 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_008c: Unknown result type (might be due to invalid IL or missing references)
			GUI.contentColor = logTypeColors[log.type];
			if (isCollapsed)
			{
				GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[0]);
				GUILayout.Label(log.GetTruncatedMessage(), logStyle, (GUILayoutOption[])(object)new GUILayoutOption[0]);
				GUILayout.FlexibleSpace();
				GUILayout.Label(log.count.ToString(), GUI.skin.box, (GUILayoutOption[])(object)new GUILayoutOption[0]);
				GUILayout.EndHorizontal();
			}
			else
			{
				for (int i = 0; i < log.count; i++)
				{
					GUILayout.Label(log.GetTruncatedMessage(), logStyle, (GUILayoutOption[])(object)new GUILayoutOption[0]);
				}
			}
			GUI.contentColor = Color.white;
		}

		private void DrawLogList()
		{
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: 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_00c1: 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_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_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Invalid comparison between Unknown and I4
			//IL_00e0: 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)
			GUIStyle box = GUI.skin.box;
			box.fontSize = logFontSize;
			try
			{
				box.font = customFont;
			}
			catch (Exception)
			{
			}
			GUIStyle label = GUI.skin.label;
			label.fontSize = logFontSize;
			try
			{
				label.font = customFont;
			}
			catch (Exception)
			{
			}
			scrollPosition = GUILayout.BeginScrollView(scrollPosition, (GUILayoutOption[])(object)new GUILayoutOption[0]);
			GUILayout.BeginVertical((GUILayoutOption[])(object)new GUILayoutOption[0]);
			foreach (Log item in logs.Where(IsLogVisible))
			{
				DrawLog(item, label, box);
			}
			GUILayout.EndVertical();
			Rect lastRect = GUILayoutUtility.GetLastRect();
			GUILayout.EndScrollView();
			Rect lastRect2 = GUILayoutUtility.GetLastRect();
			if ((int)Event.current.type == 7 && IsScrolledToBottom(lastRect, lastRect2))
			{
				ScrollToBottom();
			}
		}

		private void DrawToolbar()
		{
			//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_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[0]);
			if (GUILayout.Button(clearLabel, (GUILayoutOption[])(object)new GUILayoutOption[0]))
			{
				logs.Clear();
			}
			foreach (LogType lFKey in lFKeys)
			{
				LogType current = lFKey;
				bool flag = logTypeFilters[current];
				string text = ((object)(LogType)(ref current)).ToString();
				logTypeFilters[current] = GUILayout.Toggle(flag, text, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) });
				GUILayout.Space(20f);
			}
			isCollapsed = GUILayout.Toggle(isCollapsed, collapseLabel, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) });
			GUILayout.EndHorizontal();
		}

		private void DrawInput()
		{
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Expected O, but got Unknown
			GUILayout.Label(string.IsNullOrEmpty(suggestedCommands) ? "" : ("Suggested: " + suggestedCommands), (GUILayoutOption[])(object)new GUILayoutOption[0]);
			GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[0]);
			GUI.SetNextControlName("inputBar");
			inputString = GUILayout.TextField(inputString, 2000, (GUILayoutOption[])(object)new GUILayoutOption[0]);
			editor = (TextEditor)GUIUtility.GetStateObject(typeof(TextEditor), GUIUtility.keyboardControl);
			editor.multiline = false;
			if (GUILayout.Button(submitLabel, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) }))
			{
				HandleInput(inputString);
				inputString = string.Empty;
			}
			GUILayout.EndHorizontal();
		}

		private void HandleInput(string consoleInput)
		{
			if (!string.IsNullOrEmpty(consoleInput))
			{
				if (!consoleInput.Equals("cls"))
				{
					SkUtilities.Logz(new string[1] { "IN" }, new string[1] { consoleInput }, (LogType)3);
				}
				consoleHistory.Add(inputString);
				SkCommandProcessor.Instance.ExecuteCommand(inputString);
				suggestedCommands = string.Empty;
				inputString = string.Empty;
			}
		}

		private void DrawWindow(int windowID)
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			DrawLogList();
			if (enableInput)
			{
				DrawInput();
			}
			DrawToolbar();
			GUI.DragWindow(titleBarRect);
		}

		private Log? GetLastLog()
		{
			if (logs.Count == 0)
			{
				return null;
			}
			return logs.Last();
		}

		private void UpdateQueuedLogs()
		{
			Log result;
			while (queuedLogs.TryDequeue(out result))
			{
				ProcessLogItem(result);
			}
		}

		private void HandleLogThreaded(string message, string stackTrace, LogType type)
		{
			//IL_0022: 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)
			Log log = default(Log);
			log.count = 1;
			log.message = message;
			log.stackTrace = stackTrace;
			log.type = type;
			Log item = log;
			if (writeToFile)
			{
				logLineNumber++;
				using StreamWriter streamWriter = new StreamWriter(logSavePath, append: true);
				streamWriter.WriteLine(logLineNumber + "\t:\t" + message);
			}
			queuedLogs.Enqueue(item);
		}

		private void ProcessLogItem(Log log)
		{
			Log? lastLog = GetLastLog();
			if (lastLog.HasValue && log.Equals(lastLog.Value))
			{
				log.count = lastLog.Value.count + 1;
				logs[logs.Count - 1] = log;
			}
			else
			{
				logs.Add(log);
				TrimExcessLogs();
			}
		}

		private bool IsLogVisible(Log log)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			return logTypeFilters[log.type];
		}

		private bool IsScrolledToBottom(Rect innerScrollRect, Rect outerScrollRect)
		{
			float num = ((Rect)(ref innerScrollRect)).height;
			float num2 = ((Rect)(ref outerScrollRect)).height - (float)GUI.skin.box.padding.vertical;
			if (num2 > num)
			{
				return true;
			}
			return Mathf.Approximately(num, scrollPosition.y + num2);
		}

		private void ScrollToBottom()
		{
			//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)
			scrollPosition = new Vector2(0f, 2.1474836E+09f);
		}

		private void TrimExcessLogs()
		{
			if (restrictLogCount)
			{
				int num = logs.Count - maxLogCount;
				if (num > 0)
				{
					logs.RemoveRange(0, num);
				}
			}
		}

		public void ClearConsole()
		{
			logs.Clear();
		}

		private void unlockCursor()
		{
			Cursor.lockState = (CursorLockMode)0;
			Cursor.visible = true;
		}
	}
	internal struct Log
	{
		public int count;

		public string message;

		public string stackTrace;

		public LogType type;

		private const int maxMessageLength = 16382;

		public bool Equals(Log log)
		{
			//IL_0027: 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)
			if (message == log.message && stackTrace == log.stackTrace)
			{
				return type == log.type;
			}
			return false;
		}

		public string GetTruncatedMessage()
		{
			if (string.IsNullOrEmpty(message))
			{
				return message;
			}
			if (message.Length > 16382)
			{
				return message.Substring(0, 16382);
			}
			return message;
		}
	}
	internal class ConcurrentQueue<T>
	{
		private readonly Queue<T> queue = new Queue<T>();

		private readonly object queueLock = new object();

		public void Enqueue(T item)
		{
			lock (queueLock)
			{
				queue.Enqueue(item);
			}
		}

		public bool TryDequeue(out T result)
		{
			lock (queueLock)
			{
				if (queue.Count == 0)
				{
					result = default(T);
					return false;
				}
				result = queue.Dequeue();
				return true;
			}
		}
	}
	public class SkMenu
	{
		private List<SkMenuItem> listItems = new List<SkMenuItem>();

		private readonly string toggleStrOn = "[ON]";

		private readonly string toggleStrOff = "[OFF]";

		public void AddItem(string inText, Action outMethod, string inTip = null)
		{
			listItems.Add(new SkMenuItem(inText, outMethod, inTip));
		}

		public void AddItem(string inText, Action<string> outMethod, string inTip = null)
		{
			listItems.Add(new SkMenuItem(inText, outMethod, inTip));
		}

		public void AddItem(SkMenuItem menuItem)
		{
			listItems.Add(menuItem);
		}

		public void AddItemToggle(string inText, ref bool inToggleVar, Action outMethod, string inTip = null)
		{
			listItems.Add(new SkMenuItem(inText + " " + (inToggleVar ? toggleStrOn : toggleStrOff), outMethod, inTip));
		}

		public void AddItemToggle(string inText, ref bool inToggleVar, Action<string> outMethod, string inTip = null)
		{
			listItems.Add(new SkMenuItem(inText + " " + (inToggleVar ? toggleStrOn : toggleStrOff), outMethod, inTip));
		}

		public int RemoveItem(SkMenuItem menuItem)
		{
			int num = 0;
			try
			{
				foreach (SkMenuItem listItem in listItems)
				{
					if (listItem.Compare(menuItem))
					{
						listItems.Remove(menuItem);
						num++;
					}
				}
				return num;
			}
			catch (Exception)
			{
				return -1;
			}
		}

		public List<SkMenuItem> FlushMenu()
		{
			return listItems;
		}

		public void ClearItems()
		{
			listItems.Clear();
		}

		public int Count()
		{
			return listItems.Count();
		}
	}
	public class SkMenuController : MonoBehaviour
	{
		private string contextTipInfo1 = "NumPad Arrows";

		private string contextTipInfo2 = "NumPad 5 to Select";

		private string contextTipInfo3 = "NumPad . to Back";

		internal static Version SkMenuControllerVersion = new Version(1, 5, 0);

		internal static SkUtilities.Status SkMenuControllerStatus = SkUtilities.Status.Initialized;

		private readonly string appName = "SkToolbox";

		private readonly string welcomeMsg = "[SkToolbox Loaded]\nPress NumPad 0\nto Toggle Menu.";

		private readonly string welcomeMotd = "";

		private bool displayWelcome = true;

		private bool initialCheck = true;

		internal bool logResponse;

		private bool menuOpen;

		private bool subMenuOpen;

		private bool menuProcessInitialOptSize = true;

		private bool subMenuProcessInitialOptSize = true;

		public float inputDelay = -1f;

		public float currentInputDelay;

		private int menuSelection = 1;

		private int subMenuSelection = 1;

		private int maxSelectionOption;

		private int subMaxSelectionOption = 1;

		private int subMenuMaxItemsPerPage = 12;

		private int subMenuCurrentPage = 1;

		public List<SkBaseModule> menuOptions;

		public List<SkMenuItem> subMenuOptions;

		public List<SkMenuItem> subMenuOptionsDisplay;

		public SkModuleController SkModuleController;

		private int ypos_initial;

		private int ypos_offset = 22;

		private int mWidth;

		private int subMenu_xpos_offset = 35;

		private int sWidth;

		private Color menuOptionHighlight = Color.cyan;

		private Color menuOptionSelected = Color.yellow;

		internal Dictionary<string, KeyCode> keyBindings = new Dictionary<string, KeyCode>
		{
			{
				"selToggle",
				(KeyCode)256
			},
			{
				"selUp",
				(KeyCode)264
			},
			{
				"selDown",
				(KeyCode)258
			},
			{
				"selChoose",
				(KeyCode)261
			},
			{
				"selBack",
				(KeyCode)266
			}
		};

		private void Start()
		{
			SkMenuControllerStatus = SkUtilities.Status.Loading;
			SkUtilities.Logz(new string[2] { "CONTROLLER", "NOTIFY" }, new string[2] { "LOADING...", "WAITING FOR TOOLBOX." }, (LogType)3);
			SkModuleController = ((Component)this).gameObject.AddComponent<SkModuleController>();
		}

		private void Update()
		{
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_045f: 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_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_027f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: Unknown result type (might be due to invalid IL or missing references)
			//IL_035a: 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_01db: Unknown result type (might be due to invalid IL or missing references)
			//IL_018b: Unknown result type (might be due to invalid IL or missing references)
			if (initialCheck)
			{
				List<SkBaseModule> list = menuOptions;
				if (list != null && list.Count == 0)
				{
					UpdateMenuOptions(SkModuleController.GetOptions());
				}
				else
				{
					SkMenuControllerStatus = SkUtilities.Status.Ready;
					if (SkMenuControllerStatus == SkUtilities.Status.Ready && SkModuleController.SkMainStatus == SkUtilities.Status.Ready)
					{
						initialCheck = false;
						SkUtilities.Logz(new string[2] { "CONTROLLER", "NOTIFY" }, new string[1] { "READY." }, (LogType)3);
					}
				}
			}
			if (Input.GetKeyDown(keyBindings["selToggle"]))
			{
				displayWelcome = false;
				menuOpen = !menuOpen;
			}
			if (menuOpen)
			{
				if (!subMenuOpen)
				{
					if ((inputDelay == -1f && Input.GetKeyDown(keyBindings["selDown"])) || (inputDelay > -1f && Input.GetKey(keyBindings["selDown"]) && currentInputDelay <= 0f))
					{
						currentInputDelay = inputDelay;
						subMenuSelection = 1;
						if (menuSelection != maxSelectionOption)
						{
							menuSelection++;
						}
						else
						{
							menuSelection = 1;
						}
					}
					if ((inputDelay == -1f && Input.GetKeyDown(keyBindings["selUp"])) || (inputDelay > -1f && Input.GetKey(keyBindings["selUp"]) && currentInputDelay <= 0f))
					{
						subMenuSelection = 1;
						if (menuSelection != 1)
						{
							menuSelection--;
						}
						else
						{
							menuSelection = maxSelectionOption;
						}
					}
					if (Input.GetKeyDown(keyBindings["selChoose"]))
					{
						try
						{
							RunMethod(menuOptions[menuSelection - 1].CallerEntry.ItemClass);
						}
						catch (Exception ex)
						{
							SkUtilities.Logz(new string[2] { "CONTROLLER", "ERROR" }, new string[1] { ex.Message }, (LogType)3);
						}
					}
				}
				else
				{
					if ((inputDelay == -1f && Input.GetKeyDown(keyBindings["selDown"])) || (inputDelay > -1f && Input.GetKey(keyBindings["selDown"]) && currentInputDelay <= 0f))
					{
						currentInputDelay = inputDelay;
						if (subMenuSelection != subMaxSelectionOption)
						{
							subMenuSelection++;
						}
						else
						{
							subMenuSelection = 1;
						}
					}
					if ((inputDelay == -1f && Input.GetKeyDown(keyBindings["selUp"])) || (inputDelay > -1f && Input.GetKey(keyBindings["selUp"]) && currentInputDelay <= 0f))
					{
						currentInputDelay = inputDelay;
						if (subMenuSelection != 1)
						{
							subMenuSelection--;
						}
						else
						{
							subMenuSelection = subMaxSelectionOption;
						}
					}
					if (Input.GetKeyDown(keyBindings["selChoose"]))
					{
						subMenuOpen = false;
						try
						{
							RunMethod(subMenuOptionsDisplay[subMenuSelection - 1].ItemClass);
						}
						catch (Exception)
						{
							try
							{
								if (subMenuOptionsDisplay[subMenuSelection - 1].ItemText.Equals("Next >"))
								{
									IncreasePage();
								}
								else if (subMenuOptionsDisplay[subMenuSelection - 1].ItemText.Equals("< Previous"))
								{
									DecreasePage();
								}
								else
								{
									RunMethod(subMenuOptionsDisplay[subMenuSelection - 1].ItemClassStr, subMenuOptionsDisplay[subMenuSelection - 1].ItemText);
								}
							}
							catch (Exception ex2)
							{
								SkUtilities.Logz(new string[2] { "CONTROLLER", "ERROR" }, new string[1] { ex2.Message }, (LogType)3);
							}
						}
					}
				}
				if (Input.GetKeyDown(keyBindings["selBack"]))
				{
					if (!subMenuOpen)
					{
						menuOpen = false;
					}
					subMenuOpen = false;
				}
			}
			currentInputDelay -= Time.deltaTime;
			currentInputDelay = Mathf.Clamp(currentInputDelay, 0f, 999f);
		}

		private void OnGUI()
		{
			//IL_0000: 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_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Expected O, but got Unknown
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_039e: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a4: Invalid comparison between Unknown and I4
			//IL_03ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b1: Invalid comparison between Unknown and I4
			//IL_03b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0172: 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_01a3: Expected O, but got Unknown
			//IL_019e: Unknown result type (might be due to invalid IL or missing references)
			//IL_036b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0377: Unknown result type (might be due to invalid IL or missing references)
			//IL_038c: Expected O, but got Unknown
			//IL_0387: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02be: 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_00ce: Expected O, but got Unknown
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: 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_0323: Expected O, but got Unknown
			//IL_031e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ef: Expected O, but got Unknown
			//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0205: Unknown result type (might be due to invalid IL or missing references)
			GUI.color = Color.white;
			if (displayWelcome)
			{
				GUILayout.Window(49101, new Rect(7f, (float)ypos_initial, 150f, 55f), new WindowFunction(ProcessWelcome), "", (GUILayoutOption[])(object)new GUILayoutOption[0]);
			}
			if (menuOptions == null || menuOptions.Count == 0 || ypos_initial == 0)
			{
				UpdateMenuOptions(SkModuleController.GetOptions());
			}
			else if (menuOpen)
			{
				if (menuProcessInitialOptSize)
				{
					float num = 0f;
					GUIStyle box = GUI.skin.box;
					foreach (SkBaseModule menuOption in menuOptions)
					{
						GUIContent val = new GUIContent(menuOption.CallerEntry.ItemText);
						Vector2 val2 = box.CalcSize(val);
						if (val2.x > num)
						{
							num = val2.x;
						}
					}
					mWidth = ((mWidth == 0) ? Mathf.CeilToInt(num) : mWidth);
					mWidth = Mathf.Clamp(mWidth, 125, 1024);
					menuProcessInitialOptSize = false;
				}
				GUILayout.Window(49000, new Rect(7f, (float)ypos_initial, (float)(mWidth + ypos_offset), (float)(30 + ypos_offset * menuOptions.Count)), new WindowFunction(ProcessMainMenu), "- [" + appName + "] -", (GUILayoutOption[])(object)new GUILayoutOption[0]);
				if (subMenuOpen)
				{
					if (subMenuProcessInitialOptSize)
					{
						float num2 = 0f;
						GUIStyle box2 = GUI.skin.box;
						foreach (SkMenuItem subMenuOption in subMenuOptions)
						{
							GUIContent val3 = new GUIContent(subMenuOption.ItemText);
							Vector2 val4 = box2.CalcSize(val3);
							if (val4.x > num2)
							{
								num2 = val4.x;
							}
						}
						sWidth = ((sWidth == 0) ? Mathf.CeilToInt(num2) : sWidth);
						sWidth = Mathf.Clamp(sWidth, 105, 1024);
					}
					if (subMenuOptions.Count > subMenuMaxItemsPerPage)
					{
						GUILayout.Window(49001, new Rect((float)(mWidth + subMenu_xpos_offset), (float)(ypos_initial - ypos_offset), (float)(sWidth + subMenu_xpos_offset), (float)(30 + ypos_offset * subMenuMaxItemsPerPage)), new WindowFunction(ProcessSubMenu), "- Submenu - " + subMenuCurrentPage + "/" + (Mathf.Ceil((float)(subMenuOptions.Count / subMenuMaxItemsPerPage)) + (float)((subMenuOptions.Count % subMenuMaxItemsPerPage != 0) ? 1 : 0)), (GUILayoutOption[])(object)new GUILayoutOption[0]);
					}
					else
					{
						GUILayout.Window(49001, new Rect((float)(mWidth + subMenu_xpos_offset), (float)(ypos_initial - ypos_offset), (float)(sWidth + subMenu_xpos_offset), (float)(30 + ypos_offset * subMenuOptions.Count)), new WindowFunction(ProcessSubMenu), "- Submenu -", (GUILayoutOption[])(object)new GUILayoutOption[0]);
					}
				}
			}
			if (Event.current.button == 0 && (int)Event.current.type != 7 && (int)Event.current.type != 8 && (int)Event.current.type == 0)
			{
				Event.current.Use();
			}
		}

		private void ProcessMainMenu(int windowID)
		{
			try
			{
				ProcessMainMenu();
				ProcessContextMenu(windowID);
			}
			catch (Exception ex)
			{
				SkUtilities.Logz(new string[2] { "CONTROLLER", "ERROR" }, new string[1] { ex.Message }, (LogType)3);
			}
		}

		private void ProcessSubMenu(int windowID)
		{
			try
			{
				ProcessSubMenu(subMenuOptions);
			}
			catch (Exception ex)
			{
				SkUtilities.Logz(new string[2] { "CONTROLLER", "ERROR" }, new string[1] { ex.Message }, (LogType)3);
			}
		}

		private void ProcessContextMenu(int windowID)
		{
			try
			{
				ProcessMenuTip();
			}
			catch (Exception ex)
			{
				SkUtilities.Logz(new string[2] { "CONTROLLER", "ERROR" }, new string[1] { ex.Message }, (LogType)3);
			}
		}

		private void ProcessWelcome(int windowID)
		{
			try
			{
				GUILayout.BeginVertical((GUILayoutOption[])(object)new GUILayoutOption[0]);
				GUILayout.Label(welcomeMsg, (GUILayoutOption[])(object)new GUILayoutOption[0]);
				if (!welcomeMotd.Equals(""))
				{
					GUILayout.Label(welcomeMotd, (GUILayoutOption[])(object)new GUILayoutOption[0]);
				}
				GUILayout.EndVertical();
			}
			catch (Exception ex)
			{
				SkUtilities.Logz(new string[2] { "CONTROLLER", "ERROR" }, new string[1] { ex.Message }, (LogType)3);
			}
		}

		private void ProcessMainMenu()
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			//IL_00ee: 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_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			GUIStyle val = new GUIStyle(GUI.skin.box);
			GUILayout.BeginVertical((GUILayoutOption[])(object)new GUILayoutOption[0]);
			for (int i = 0; i < menuOptions.Count; i++)
			{
				if (i == menuSelection - 1)
				{
					if (subMenuOpen)
					{
						GUI.color = menuOptionSelected;
					}
					else
					{
						GUI.color = menuOptionHighlight;
					}
				}
				else
				{
					GUI.color = Color.white;
				}
				if (GUILayout.Button(menuOptions[i].CallerEntry.ItemText, val, (GUILayoutOption[])(object)new GUILayoutOption[0]))
				{
					subMenuOpen = false;
					menuSelection = i + 1;
					try
					{
						RunMethod(menuOptions[i].CallerEntry.ItemClass);
					}
					catch (Exception ex)
					{
						SkUtilities.Logz(new string[2] { "CONTROLLER", "ERROR" }, new string[1] { ex.Message }, (LogType)3);
					}
				}
			}
			GUI.color = Color.white;
			GUILayout.EndVertical();
		}

		public void IncreasePage()
		{
			subMenuCurrentPage++;
			if (subMenuCurrentPage == 2)
			{
				subMenuSelection++;
			}
			subMenuOpen = true;
		}

		public void DecreasePage()
		{
			subMenuCurrentPage--;
			subMenuOpen = true;
		}

		public void RequestSubMenu(List<SkMenuItem> subMenuOptions, float refreshTime = 0f, int subWidth = 0)
		{
			if (subMenuOptions != null && subMenuOptions.Count != 0)
			{
				subMenuCurrentPage = 1;
				sWidth = subWidth;
				subMenuOpen = true;
				subMenuProcessInitialOptSize = true;
				this.subMenuOptions = subMenuOptions;
				subMaxSelectionOption = subMenuOptions.Count;
				if (subMenuSelection > subMenuOptions.Count)
				{
					subMenuSelection = 1;
				}
				if (refreshTime > 0f)
				{
					refreshTime = Mathf.Clamp(refreshTime, 0.01f, 5f);
					((MonoBehaviour)this).StartCoroutine(RealTimeMenuUpdate(refreshTime));
				}
				else if (logResponse)
				{
					SkUtilities.Logz(new string[2] { "CONTROLLER", "RESP" }, new string[1] { "Submenu created." }, (LogType)3);
				}
			}
		}

		public void RequestSubMenu(SkMenu subMenuOptions, float refreshTime = 0f, int subWidth = 0)
		{
			if (subMenuOptions != null)
			{
				RequestSubMenu(subMenuOptions.FlushMenu(), refreshTime, subWidth);
			}
		}

		private void ProcessSubMenu(List<SkMenuItem> subMenuOptions)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_02b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a2: 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)
			if (!subMenuOpen)
			{
				return;
			}
			GUIStyle val = new GUIStyle(GUI.skin.box);
			if (subMenuOptions.Count > subMenuMaxItemsPerPage)
			{
				List<SkMenuItem> list = new List<SkMenuItem>();
				if (subMenuCurrentPage > 1)
				{
					list.Add(new SkMenuItem("◄\tPrevious Page", (Action)delegate
					{
						DecreasePage();
					}, "Previous Page"));
				}
				try
				{
					for (int i = subMenuMaxItemsPerPage * subMenuCurrentPage - subMenuMaxItemsPerPage; i < ((subMenuOptions.Count > subMenuMaxItemsPerPage * (subMenuCurrentPage + 1) - subMenuMaxItemsPerPage) ? (subMenuMaxItemsPerPage * (subMenuCurrentPage + 1) - subMenuMaxItemsPerPage) : subMenuOptions.Count); i++)
					{
						list.Add(subMenuOptions[i]);
					}
				}
				catch (IndexOutOfRangeException)
				{
					for (int j = subMenuMaxItemsPerPage * subMenuCurrentPage - subMenuMaxItemsPerPage; j < subMenuOptions.Count - 1; j++)
					{
						list.Add(subMenuOptions[j]);
					}
					subMenuProcessInitialOptSize = true;
				}
				if (subMenuOptions.Count > subMenuMaxItemsPerPage * (subMenuCurrentPage + 1) - subMenuMaxItemsPerPage)
				{
					list.Add(new SkMenuItem("Next Page\t►", (Action)delegate
					{
						IncreasePage();
					}, "Next Page"));
				}
				subMenuOptions = list;
				subMenuOptionsDisplay = list;
				subMaxSelectionOption = subMenuOptions.Count;
				if (subMenuSelection > subMenuOptions.Count)
				{
					subMenuSelection = 1;
				}
			}
			else
			{
				subMenuOptionsDisplay = subMenuOptions;
			}
			GUILayout.BeginVertical((GUILayoutOption[])(object)new GUILayoutOption[0]);
			for (int k = 0; k < subMenuOptions.Count; k++)
			{
				if (k == subMenuSelection - 1)
				{
					GUI.color = menuOptionHighlight;
				}
				else
				{
					GUI.color = Color.white;
				}
				if (!GUILayout.Button(subMenuOptions[k].ItemText, val, (GUILayoutOption[])(object)new GUILayoutOption[0]))
				{
					continue;
				}
				subMenuSelection = k + 1;
				try
				{
					RunMethod(subMenuOptionsDisplay[k].ItemClass);
				}
				catch (Exception)
				{
					try
					{
						if (subMenuOptionsDisplay[k].ItemText.Equals("Next >"))
						{
							IncreasePage();
						}
						else if (subMenuOptionsDisplay[k].ItemText.Equals("< Previous"))
						{
							DecreasePage();
						}
						else
						{
							RunMethod(subMenuOptionsDisplay[k].ItemClassStr, subMenuOptionsDisplay[k].ItemText);
						}
					}
					catch (Exception ex2)
					{
						SkUtilities.Logz(new string[2] { "CONTROLLER", "ERROR" }, new string[1] { ex2.Message }, (LogType)3);
					}
				}
			}
			GUILayout.EndVertical();
			GUI.color = Color.white;
		}

		private void ProcessMenuTip()
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
			GUIStyle val = new GUIStyle(GUI.skin.label);
			val.alignment = (TextAnchor)4;
			GUILayout.BeginVertical((GUILayoutOption[])(object)new GUILayoutOption[0]);
			try
			{
				if (subMenuOpen)
				{
					try
					{
						if (subMenuOptionsDisplay.Count > 0 && subMenuOptionsDisplay[subMenuSelection - 1] != null && subMenuOptionsDisplay[subMenuSelection - 1].ItemTip != null && !subMenuOptionsDisplay[subMenuSelection - 1].ItemTip.Equals(""))
						{
							GUILayout.Label("- Context -", val, (GUILayoutOption[])(object)new GUILayoutOption[0]);
							GUILayout.Label(subMenuOptionsDisplay[subMenuSelection - 1].ItemTip, (GUILayoutOption[])(object)new GUILayoutOption[0]);
						}
					}
					catch (NullReferenceException)
					{
					}
				}
				else if (menuOptions[menuSelection - 1].CallerEntry != null && menuOptions[menuSelection - 1].CallerEntry.ItemTip != null && !menuOptions[menuSelection - 1].CallerEntry.ItemTip.Equals(""))
				{
					GUILayout.Label("- Context -", val, (GUILayoutOption[])(object)new GUILayoutOption[0]);
					GUILayout.Label(menuOptions[menuSelection - 1].CallerEntry.ItemTip, (GUILayoutOption[])(object)new GUILayoutOption[0]);
				}
				GUILayout.Label("- Controls -", val, (GUILayoutOption[])(object)new GUILayoutOption[0]);
				GUILayout.Label(contextTipInfo1, (GUILayoutOption[])(object)new GUILayoutOption[0]);
				GUILayout.Label(contextTipInfo2, (GUILayoutOption[])(object)new GUILayoutOption[0]);
				if (subMenuOpen)
				{
					GUILayout.Label(contextTipInfo3, (GUILayoutOption[])(object)new GUILayoutOption[0]);
				}
			}
			catch (ArgumentException)
			{
			}
			GUILayout.EndVertical();
			GUI.color = Color.white;
		}

		private IEnumerator RealTimeMenuUpdate(float waitTime)
		{
			yield return (object)new WaitForSeconds(waitTime);
			if (subMenuOpen)
			{
				RunMethod(subMenuOptions[subMenuSelection - 1].ItemClass);
			}
		}

		public void UpdateMenuOptions(List<SkBaseModule> newMenuOptions)
		{
			subMenuOpen = false;
			menuOpen = false;
			menuSelection = 1;
			subMenuSelection = 1;
			menuOptions = newMenuOptions;
			List<SkBaseModule> list = menuOptions;
			if (list != null && list.Count > 0)
			{
				ypos_initial = Screen.height / 2 - menuOptions.Count / 2 * ypos_offset;
				maxSelectionOption = menuOptions.Count;
			}
			menuProcessInitialOptSize = true;
		}

		private void RunMethod(Action methodName)
		{
			methodName();
		}

		private void RunMethod(Action<string> methodName, string methodParameter = "")
		{
			try
			{
				methodName?.Invoke(methodParameter);
			}
			catch (Exception ex)
			{
				SkUtilities.Logz(new string[2] { "CONTROLLER", "ERROR" }, new string[1] { "Error running method. Likely not found... " + ex.Message }, (LogType)0);
			}
		}

		public void CloseMenu()
		{
			menuOpen = false;
			subMenuOpen = false;
		}
	}
	public class SkMenuItem
	{
		private string itemText;

		private Action itemClass;

		private Action<string> itemClassStr;

		private string itemTip;

		public string ItemText
		{
			get
			{
				return itemText;
			}
			set
			{
				itemText = value;
			}
		}

		public Action ItemClass
		{
			get
			{
				return itemClass;
			}
			set
			{
				itemClass = value;
			}
		}

		public string ItemTip
		{
			get
			{
				return itemTip;
			}
			set
			{
				itemTip = value;
			}
		}

		public Action<string> ItemClassStr
		{
			get
			{
				return itemClassStr;
			}
			set
			{
				itemClassStr = value;
			}
		}

		public SkMenuItem()
		{
		}

		public SkMenuItem(string itemText, Action itemClass, string itemTip = "")
		{
			ItemText = itemText;
			ItemClass = itemClass;
			ItemTip = itemTip;
		}

		public SkMenuItem(string itemText, Action<string> itemClassStr, string itemTip = "")
		{
			ItemText = itemText;
			ItemClassStr = itemClassStr;
			ItemTip = itemTip;
		}

		public bool Compare(object obj)
		{
			if (obj == null)
			{
				return false;
			}
			if (obj is SkMenuItem skMenuItem)
			{
				if (ItemText.Equals(skMenuItem?.ItemText))
				{
					return ItemClass.Equals(skMenuItem?.ItemClass);
				}
				return false;
			}
			return false;
		}
	}
	public class SkModuleController : MonoBehaviour
	{
		private static Version SkMainVersion = new Version(1, 1, 3);

		internal SkUtilities.Status SkMainStatus;

		private bool FirstLoad = true;

		private bool NeedLoadModules = true;

		private bool NeedRetry;

		private bool ErrorMonitor;

		private int RetryCount = 1;

		private int RetryCountMax = 3;

		private SkMenuController menuController;

		private ModConsoleOpt moduleConsole;

		private ModPlayers modulePlayers;

		private ModWorld moduleWorld;

		private ModLore moduleLore;

		private List<SkBaseModule> _menuOptions = new List<SkBaseModule>();

		public List<SkBaseModule> MenuOptions
		{
			get
			{
				return _menuOptions;
			}
			set
			{
				_menuOptions = value;
			}
		}

		private List<SkBaseModule> RetryModule { get; set; } = new List<SkBaseModule>();


		public void Start()
		{
			SkMainStatus = SkUtilities.Status.Loading;
			SkUtilities.Logz(new string[2] { "TOOLBOX", "NOTIFY" }, new string[2] { "LOADING...", "MODULES LOADING..." }, (LogType)3);
			BeginMainMenu();
			menuController = ((Component)this).GetComponent<SkMenuController>();
			if (MenuOptions.Count > 0 && (Object)(object)menuController != (Object)null)
			{
				SkMainStatus = SkUtilities.Status.Loading;
			}
			else
			{
				SkMainStatus = SkUtilities.Status.Error;
			}
			Init();
		}

		public void Update()
		{
			if (!FirstLoad)
			{
				if (SkMainStatus == SkUtilities.Status.Loading && NeedLoadModules && !NeedRetry)
				{
					foreach (SkBaseModule menuOption in MenuOptions)
					{
						SkUtilities.Logz(new string[3] { "TOOLBOX", "MODULE", "NOTIFY" }, new string[2]
						{
							"NAME: " + menuOption.ModuleName.ToUpper(),
							"STATUS: " + menuOption.ModuleStatus.ToString().ToUpper()
						}, (LogType)3);
						if (menuOption.ModuleStatus != SkUtilities.Status.Ready)
						{
							NeedRetry = true;
							RetryModule.Add(menuOption);
						}
					}
					if (!NeedRetry)
					{
						SkMainStatus = SkUtilities.Status.Ready;
						ErrorMonitor = true;
						RetryCount = 1;
					}
					if (SkMainStatus == SkUtilities.Status.Ready && MenuOptions.Count > 0)
					{
						NeedLoadModules = false;
						SkUtilities.Logz(new string[2] { "TOOLBOX", "NOTIFY" }, new string[2]
						{
							MenuOptions.Count + " MODULES LOADED",
							"TOOLBOX READY."
						}, (LogType)3);
					}
					else if (SkMainStatus == SkUtilities.Status.Error || MenuOptions.Count <= 0)
					{
						SkUtilities.Logz(new string[2] { "TOOLBOX", "NOTIFY" }, new string[2]
						{
							MenuOptions.Count + " MODULES LOADED",
							"TOOLBOX FAILED TO LOAD MODULES."
						}, (LogType)0);
					}
				}
				else if (SkMainStatus == SkUtilities.Status.Loading && NeedRetry)
				{
					if (RetryCount < RetryCountMax + 1)
					{
						for (int i = 0; i < RetryModule?.Count; i++)
						{
							SkUtilities.Logz(new string[4]
							{
								"TOOLBOX",
								"MODULE",
								"NOTIFY",
								"RECHECK " + RetryCount
							}, new string[2]
							{
								"NAME: " + RetryModule[i].ModuleName.ToUpper(),
								"STATUS: " + RetryModule[i].ModuleStatus.ToString().ToUpper()
							}, (LogType)3);
							if (RetryModule[i].ModuleStatus != SkUtilities.Status.Ready)
							{
								SkMainStatus = SkUtilities.Status.Loading;
								NeedRetry = true;
							}
							else if (RetryModule[i].ModuleStatus == SkUtilities.Status.Ready)
							{
								RetryModule.Remove(RetryModule[i]);
								if (RetryModule.Count == 0)
								{
									SkMainStatus = SkUtilities.Status.Ready;
									break;
								}
							}
						}
						RetryCount++;
					}
					if (MenuOptions.Count <= 0)
					{
						SkMainStatus = SkUtilities.Status.Error;
					}
					if (SkMainStatus == SkUtilities.Status.Ready)
					{
						ErrorMonitor = true;
						RetryCount = 1;
						SkUtilities.Logz(new string[2] { "TOOLBOX", "NOTIFY" }, new string[2]
						{
							MenuOptions.Count + " MODULES LOADED",
							"TOOLBOX READY."
						}, (LogType)3);
					}
					else if (RetryCount >= RetryCountMax + 1)
					{
						SkUtilities.Logz(new string[2] { "TOOLBOX", "NOTIFY" }, new string[2] { "MODULE NOT MOVING TO READY STATUS.", "UNLOADING THE MODULE(S)." }, (LogType)2);
						foreach (SkBaseModule item in RetryModule)
						{
							if (item.ModuleStatus != SkUtilities.Status.Ready)
							{
								item.RemoveModule();
								MenuOptions.Remove(item);
							}
						}
						RetryModule.Clear();
						NeedRetry = false;
						SkMainStatus = SkUtilities.Status.Loading;
						menuController.UpdateMenuOptions(MenuOptions);
					}
				}
			}
			else
			{
				FirstLoad = false;
			}
			if (ErrorMonitor)
			{
				for (int j = 0; j < MenuOptions?.Count; j++)
				{
					SkBaseModule skBaseModule = MenuOptions[j];
					if (skBaseModule != null && skBaseModule.ModuleStatus == SkUtilities.Status.Error && !RetryModule.Contains(MenuOptions[j]))
					{
						SkUtilities.Logz(new string[2] { "TOOLBOX", "NOTIFY" }, new string[2]
						{
							"MODULE IN ERROR STATUS.",
							"CHECKING MODULE: " + MenuOptions[j].ModuleName.ToUpper()
						}, (LogType)2);
						RetryModule.Add(MenuOptions[j]);
						continue;
					}
					SkBaseModule skBaseModule2 = MenuOptions[j];
					if (skBaseModule2 != null && skBaseModule2.ModuleStatus == SkUtilities.Status.Unload)
					{
						SkUtilities.Logz(new string[2] { "TOOLBOX", "NOTIFY" }, new string[1] { "MODULE READY TO UNLOAD. UNLOADING MODULE: " + MenuOptions[j].ModuleName.ToUpper() }, (LogType)2);
						MenuOptions[j].RemoveModule();
						MenuOptions.Remove(MenuOptions[j]);
						menuController.UpdateMenuOptions(MenuOptions);
					}
				}
				List<SkBaseModule> retryModule = RetryModule;
				if (retryModule != null && retryModule.Count > 0 && RetryCount < RetryCountMax + 1)
				{
					for (int k = 0; k < RetryModule.Count; k++)
					{
						if (RetryModule[k].ModuleStatus == SkUtilities.Status.Ready)
						{
							RetryModule.Remove(RetryModule[k]);
							SkUtilities.Logz(new string[2] { "TOOLBOX", "NOTIFY" }, new string[2]
							{
								"MODULE READY.",
								"MODULE: " + MenuOptions[k].ModuleName.ToUpper()
							}, (LogType)3);
							if (RetryModule.Count == 0)
							{
								break;
							}
						}
					}
					RetryCount++;
				}
				else
				{
					List<SkBaseModule> retryModule2 = RetryModule;
					if (retryModule2 != null && retryModule2.Count > 0 && RetryCount >= RetryCountMax + 1)
					{
						foreach (SkBaseModule item2 in RetryModule)
						{
							if (item2.ModuleStatus != SkUtilities.Status.Ready)
							{
								SkUtilities.Logz(new string[2] { "TOOLBOX", "NOTIFY" }, new string[2]
								{
									"COULD NOT RESOLVE ERROR.",
									"UNLOADING THE MODULE: " + item2.ModuleName.ToUpper()
								}, (LogType)2);
								item2.RemoveModule();
								MenuOptions.Remove(item2);
							}
						}
						RetryModule.Clear();
						RetryCount = 1;
						menuController.UpdateMenuOptions(MenuOptions);
						if (MenuOptions.Count == 0)
						{
							SkMainStatus = SkUtilities.Status.Error;
							SkUtilities.Logz(new string[2] { "TOOLBOX", "NOTIFY" }, new string[2] { "NO MODULES LOADED.", "TOOLBOX ENTERING ERROR STATE." }, (LogType)0);
						}
					}
				}
			}
			OnUpdate();
		}

		public List<SkBaseModule> GetOptions()
		{
			return MenuOptions;
		}

		public void BeginMainMenu()
		{
			moduleConsole = ((Component)this).gameObject.AddComponent<ModConsoleOpt>();
			modulePlayers = ((Component)this).gameObject.AddComponent<ModPlayers>();
			moduleWorld = ((Component)this).gameObject.AddComponent<ModWorld>();
			moduleLore = ((Component)this).gameObject.AddComponent<ModLore>();
			MenuOptions.Add(modulePlayers);
			MenuOptions.Add(moduleWorld);
			MenuOptions.Add(moduleLore);
			MenuOptions.Add(moduleConsole);
		}

		public static T ParseEnum<T>(string value)
		{
			return (T)Enum.Parse(typeof(T), value, ignoreCase: true);
		}

		private void Init()
		{
		}

		private void OnUpdate()
		{
		}

		public void OnGUI()
		{
		}

		public void AddModule(SkBaseModule module)
		{
			MenuOptions.Add(module);
			menuController.UpdateMenuOptions(MenuOptions);
		}
	}
}
namespace SkToolbox.Utility
{
	internal static class SkPatcher
	{
		[HarmonyPatch(/*Could not decode attribute arguments.*/)]
		public static class PatchIsDevelopment
		{
			[HarmonyPriority(0)]
			private static void Postfix(bool __result)
			{
				__result = bDevelopment;
			}
		}

		private static Harmony harmony;

		private static bool initComplete;

		internal static bool bDevelopment;

		public static Harmony Harmony
		{
			get
			{
				return harmony;
			}
			set
			{
				harmony = value;
			}
		}

		public static bool InitComplete
		{
			get
			{
				return initComplete;
			}
			set
			{
				initComplete = value;
			}
		}

		public static void InitPatch()
		{
			if (InitComplete)
			{
				return;
			}
			try
			{
				harmony = Harmony.CreateAndPatchAll(typeof(SkPatcher).Assembly, (string)null);
			}
			catch (Exception ex)
			{
				SkUtilities.Logz(new string[2] { "SkCommandPatcher", "PATCH" }, new string[3] { "PATCH => FAILED\n", ex.Message, ex.StackTrace }, (LogType)0);
			}
			finally
			{
				InitComplete = true;
			}
		}
	}
	public static class SkUtilities
	{
		public delegate object Command(params object[] args);

		public enum Status
		{
			Initialized,
			Loading,
			Ready,
			Error,
			Unload
		}

		public static bool ConvertInternalWarningsErrors = false;

		public static BindingFlags BindFlags = BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic;

		public static void GameobjectSetPrivateField(this string objName, string componentName, string fieldName, object value)
		{
			object component = GameObject.Find(objName).GetComponent(componentName);
			FieldInfo field = component.GetType().GetField(fieldName, BindFlags);
			try
			{
				object value2 = Convert.ChangeType(value, field.FieldType);
				field.SetValue(component, value2);
			}
			catch (ArgumentException)
			{
				float.TryParse(value.ToString(), out var result);
				field.SetValue(component, result);
			}
		}

		public static T GameobjectGetPrivateField<T>(this string objName, string componentName, string fieldName)
		{
			object component = GameObject.Find(objName).GetComponent(componentName);
			return (T)component.GetType().GetField(fieldName, BindFlags).GetValue(component);
		}

		public static void SetPrivateField(this object obj, string fieldName, object value)
		{
			obj.GetType().GetField(fieldName, BindFlags).SetValue(obj, value);
		}

		public static T GetPrivateField<T>(this object obj, string fieldName)
		{
			return (T)obj.GetType().GetField(fieldName, BindFlags).GetValue(obj);
		}

		public static void SetPrivateProperty(this object obj, string propertyName, object value)
		{
			obj.GetType().GetProperty(propertyName, BindFlags).SetValue(obj, value, null);
		}

		public static void InvokePrivateMethod(this object obj, string methodName, object[] methodParams)
		{
			obj.GetType().GetMethod(methodName, BindFlags).Invoke(obj, methodParams);
		}

		public static Component CopyComponent(Component original, Type originalType, Type overridingType, GameObject destination)
		{
			Component val = destination.AddComponent(overridingType);
			FieldInfo[] fields = originalType.GetFields(BindFlags);
			foreach (FieldInfo obj in fields)
			{
				object value = obj.GetValue(original);
				obj.SetValue(val, value);
			}
			return val;
		}

		public static T ParseEnum<T>(string value)
		{
			return (T)Enum.Parse(typeof(T), value, ignoreCase: true);
		}

		public static string GetAllProperiesOfObject(string thisObject, string componentName)
		{
			object component = GameObject.Find(thisObject).GetComponent(componentName);
			if (component == null)
			{
				return "Component not found. Check component name, character case matters.";
			}
			string result = string.Empty;
			try
			{
				FieldInfo[] fields = component.GetType().GetFields(BindFlags);
				Array.Sort(fields, (FieldInfo propertyInfo1, FieldInfo propertyInfo2) => propertyInfo1.Name.CompareTo(propertyInfo2.Name));
				StringBuilder stringBuilder = new StringBuilder();
				FieldInfo[] array = fields;
				foreach (FieldInfo fieldInfo in array)
				{
					stringBuilder.Append("\n");
					stringBuilder.AppendFormat("Name: {0} | Value: {1}", fieldInfo.Name, fieldInfo.GetValue(component));
				}
				result = stringBuilder.ToString();
			}
			catch (Exception)
			{
			}
			return result;
		}

		public static string GetAllComponentsOnGameobject(string thisObject)
		{
			Component[] components = GameObject.Find(thisObject).GetComponents(typeof(Component));
			StringBuilder stringBuilder = new StringBuilder();
			Component[] array = components;
			foreach (Component val in array)
			{
				stringBuilder.Append("\n");
				stringBuilder.AppendFormat("Component: {0}", ((object)val).GetType());
			}
			return stringBuilder.ToString();
		}

		public static void Logz(string[] categories, string[] messages, LogType logType = 3)
		{
			//IL_007e: 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_0083: Invalid comparison between Unknown and I4
			string text = string.Empty;
			if (categories != null)
			{
				string[] array = categories;
				foreach (string text2 in array)
				{
					text = text + " (" + text2 + ") → ";
				}
			}
			if (messages != null)
			{
				string[] array = messages;
				foreach (string text3 in array)
				{
					text = ((text3 == null) ? (text + "NULL | ") : (text + text3 + " | "));
				}
				text = text.Remove(text.Length - 2, 1);
			}
			if (!ConvertInternalWarningsErrors)
			{
				if ((int)logType != 0)
				{
					if ((int)logType == 2)
					{
						Debug.LogWarning((object)("(SkToolbox) → " + text));
					}
					else
					{
						Debug.Log((object)("(SkToolbox) → " + text));
					}
				}
				else
				{
					Debug.LogError((object)("(SkToolbox) → " + text));
				}
			}
			else
			{
				Debug.Log((object)("(SkToolbox) → " + text));
			}
		}

		public static string Logr(string[] categories, string[] messages)
		{
			string text = string.Empty;
			if (categories != null)
			{
				string[] array = categories;
				foreach (string text2 in array)
				{
					text = text + " (" + text2 + ") → ";
				}
			}
			if (messages != null)
			{
				string[] array = messages;
				foreach (string text3 in array)
				{
					text = ((text3 == null) ? (text + "NULL | ") : (text + text3 + " | "));
				}
				text = text.Remove(text.Length - 2, 1);
			}
			return "(SkToolbox) → " + text;
		}

		public static void Logz(string message)
		{
			string empty = string.Empty;
			empty += " (OUT) → ";
			empty = empty + message + " ";
			Debug.Log((object)("(SkToolbox) → " + empty));
		}

		public static void RectFilled(float x, float y, float width, float height, Texture2D text)
		{
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			GUI.DrawTexture(new Rect(x, y, width, height), (Texture)(object)text);
		}

		public static void RectOutlined(float x, float y, float width, float height, Texture2D text, float thickness = 1f)
		{
			RectFilled(x, y, thickness, height, text);
			RectFilled(x + width - thickness, y, thickness, height, text);
			RectFilled(x + thickness, y, width - thickness * 2f, thickness, text);
			RectFilled(x + thickness, y + height - thickness, width - thickness * 2f, thickness, text);
		}

		public static List<T> FindImplementationsByType<T>(Type type)
		{
			List<T> list = new List<T>();
			Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
			for (int i = 0; i < assemblies.Length; i++)
			{
				Type[] types = assemblies[i].GetTypes();
				foreach (Type type2 in types)
				{
					if (!type2.IsClass || !type2.IsPublic || type2.IsAbstract || type2.FullName == null)
					{
						continue;
					}
					Type typeFromHandle = Type.GetTypeFromHandle(type2.TypeHandle);
					if (type.IsAssignableFrom(typeFromHandle))
					{
						try
						{
							list.Add((T)Activator.CreateInstance(typeFromHandle));
						}
						catch (Exception innerException)
						{
							throw new Exception("Failed to instantiate type '" + type2.Name + "'.", innerException);
						}
					}
				}
			}
			return list;
		}

		public static void Box(float x, float y, float width, float height, Texture2D text, float thickness = 1f)
		{
			RectOutlined(x - width / 2f, y - height, width, height, text, thickness);
		}
	}
	public static class Dot
	{
		private static class d
		{
			public static Texture2D lineTex = new Texture2D(1, 1);

			public static Vector2 vectorA = Vector2.zero;

			public static Rect rectA = new Rect(0f, 0f, 0f, 0f);

			public static Color bColor;

			public static float tOffset = 0f;

			public static Texture2D patternTexture = new Texture2D(1, 1);

			public static Vector2 Crosshair2dCenter_sw = new Vector2((float)Screen.width / 2f - 2f, (float)Screen.height / 2f - 2f);

			public static Vector2 Crosshair2dCenter_ac = new Vector2((float)Screen.width / 2f - 1f, (float)Screen.height / 2f - 1f);

			public static Vector2 Crosshair2dVector = Vector2.zero;
		}

		public static void DrawCenterCrosshair()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			Draw(d.Crosshair2dCenter_sw, Color.black, 4f);
			Draw(d.Crosshair2dCenter_ac, Color.white, 2f);
		}

		public static void DrawVectorCrosshair(Vector3 vector)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: 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_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_0088: 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_000d: Unknown result type (might be due to invalid IL or missing references)
			if (vector.x != 0f || vector.y != 0f)
			{
				d.Crosshair2dVector.x = vector.x - 2f;
				d.Crosshair2dVector.y = (float)Screen.height - vector.y - 1f;
				Draw(d.Crosshair2dVector, Color.black, 4f);
				d.Crosshair2dVector.x += 1f;
				d.Crosshair2dVector.y += 1f;
				Draw(d.Crosshair2dVector, Color.white, 2f);
			}
		}

		public static void Draw(Vector2 Position, Color color, float thickness)
		{
			//IL_0027: 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_0036: 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_006d: 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_0082: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)d.lineTex))
			{
				d.lineTex = d.patternTexture;
			}
			d.tOffset = Mathf.Ceil(thickness / 2f);
			d.bColor = GUI.color;
			((Rect)(ref d.rectA)).x = Position.x;
			((Rect)(ref d.rectA)).y = Position.y - d.tOffset;
			((Rect)(ref d.rectA)).width = thickness;
			((Rect)(ref d.rectA)).height = thickness;
			GUI.color = color;
			GUI.DrawTexture(d.rectA, (Texture)(object)d.lineTex);
			GUI.color = d.bColor;
		}
	}
	public static class Text
	{
		private static class d
		{
			public static Vector2 vectorA = Vector2.zero;

			public static GUIStyle bStyle;

			public static GUIContent bContent = new GUIContent();

			public static GUIStyle cStyle = new GUIStyle();
		}

		public static void Draw(Rect rect, string content, Color txtColor, bool shadow = true)
		{
			//IL_0053: 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_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: 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_001d: Unknown result type (might be due to invalid IL or missing references)
			if (!shadow)
			{
				d.bStyle = d.cStyle;
				d.bStyle.normal.textColor = txtColor;
				GUI.Label(rect, content, d.bStyle);
			}
			else
			{
				d.bContent.text = content;
				d.vectorA.x = 1f;
				d.vectorA.y = 1f;
				DrawShadowed(rect, d.bContent, d.cStyle, txtColor, Color.black, d.vectorA);
			}
		}

		public static void DrawShadowed(Rect rect, GUIContent content, GUIStyle style, Color txtColor, Color shadowColor, Vector2 direction)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: 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_003d: 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_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			d.bStyle = style;
			style.normal.textColor = shadowColor;
			((Rect)(ref rect)).x = ((Rect)(ref rect)).x + direction.x;
			((Rect)(ref rect)).y = ((Rect)(ref rect)).y + direction.y;
			GUI.Label(rect, content, style);
			style.normal.textColor = txtColor;
			((Rect)(ref rect)).x = ((Rect)(ref rect)).x - direction.x;
			((Rect)(ref rect)).y = ((Rect)(ref rect)).y - direction.y;
			GUI.Label(rect, content, style);
			style = d.bStyle;
		}
	}
	public static class Line
	{
		private static class d
		{
			public static Texture2D lineTex = new Texture2D(1, 1);

			public static Texture2D patternTexture = new Texture2D(1, 1);

			public static Matrix4x4 i_M4x4 = Matrix4x4.zero;

			public static Vector2 vectorA = Vector2.zero;

			public static Vector2 vectorB = Vector2.zero;

			public static float Angle = 0f;

			public static Color bColor;

			public static Rect rectA = new Rect(0f, 0f, 0f, 0f);
		}

		public static void Draw(Rect rect, Color color, float width)
		{
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			d.vectorA.x = ((Rect)(ref rect)).x;
			d.vectorA.y = ((Rect)(ref rect)).y;
			d.vectorB.x = ((Rect)(ref rect)).x + ((Rect)(ref rect)).width;
			d.vectorB.y = ((Rect)(ref rect)).y + ((Rect)(ref rect)).height;
			Draw(d.vectorA, d.vectorB, color, width);
		}

		public static void Draw(Vector2 pointA, Vector2 pointB, 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_0002: Unknown result type (might be due to invalid IL or missing references)
			Draw(pointA, pointB, color, 1f);
		}

		public static void Draw(Vector2 pointA, Vector2 pointB, Color color, float width)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: 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_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_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_0037: 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_0050: 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_006e: 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_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: 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_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: 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_010b: 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_0124: Unknown result type (might be due to invalid IL or missing references)
			d.i_M4x4 = GUI.matrix;
			if (!Object.op_Implicit((Object)(object)d.lineTex))
			{
				d.lineTex = d.patternTexture;
			}
			d.bColor = GUI.color;
			GUI.color = color;
			d.Angle = Vector3.Angle(Vector2.op_Implicit(pointB - pointA), Vector2.op_Implicit(Vector2.right));
			if (pointA.y > pointB.y)
			{
				d.Angle = 0f - d.Angle;
			}
			Vector2 val = pointB - pointA;
			d.vectorA.x = ((Vector2)(ref val)).magnitude;
			d.vectorA.y = width;
			d.vectorB.x = pointA.x;
			d.vectorB.y = pointA.y + 0.5f;
			GUIUtility.ScaleAroundPivot(d.vectorA, d.vectorB);
			GUIUtility.RotateAroundPivot(d.Angle, pointA);
			((Rect)(ref d.rectA)).x = pointA.x;
			((Rect)(ref d.rectA)).y = pointA.y;
			((Rect)(ref d.rectA)).width = 1f;
			((Rect)(ref d.rectA)).height = 1f;
			GUI.DrawTexture(d.rectA, (Texture)(object)d.lineTex);
			GUI.matrix = d.i_M4x4;
			GUI.color = d.bColor;
		}
	}
	public static class Box
	{
		public static void RectFilled(float x, float y, float width, float height, Texture2D text)
		{
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			GUI.DrawTexture(new Rect(x, y, width, height), (Texture)(object)text);
		}

		public static void RectOutlined(float x, float y, float width, float height, Texture2D text, float thickness = 1f)
		{
			RectFilled(x, y, thickness, height, text);
			RectFilled(x + width - thickness, y, thickness, height, text);
			RectFilled(x + thickness, y, width - thickness * 2f, thickness, text);
			RectFilled(x + thickness, y + height - thickness, width - thickness * 2f, thickness, text);
		}

		public static void Draw(float x, float y, float width, float height, Texture2D text, float thickness = 1f)
		{
			RectOutlined(x - width / 2f, y - height, width, height, text, thickness);
		}
	}
	public static class Circle
	{
		private static class d
		{
			public static float[] cos = new float[13]
			{
				0.8711474f, 0.51779556f, 0.03100516f, -0.46377546f, -0.8390387f, -0.99807733f, -0.8999063f, -0.56982464f, -0.09289626f, 0.40797198f,
				0.8037037f, 0.99231684f, 0.92520475f
			};

			public static float[] sin = new float[13]
			{
				-0.4910216f, -0.8555044f, -0.9995192f, -0.8859528f, -0.5440717f, -0.061980512f, 0.43608338f, 0.8217663f, 0.9956758f, 0.91299444f,
				0.5950297f, 0.12372269f, -0.3794683f
			};

			public static Vector2 vectorA = Vector2.zero;

			public static Vector2 vectorB = Vector2.zero;
		}

		public static void Draw(int X, int Y, float radius, float thickness = 1f)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			Draw(X, Y, radius, Color.green, thickness);
		}

		public static void Draw(int X, int Y, float radius, Color color)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			Draw(X, Y, radius, color, 1f);
		}

		public static void Draw(int X, int Y, float radius, Color color, float thickness = 1f)
		{
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 0; i < 12; i++)
			{
				d.vectorA.x = (float)X + d.cos[i] * radius;
				d.vectorA.y = (float)Y + d.sin[i] * radius;
				d.vectorB.x = (float)X + d.cos[i + 1] * radius;
				d.vectorB.y = (float)Y + d.sin[i + 1] * radius;
				Line.Draw(d.vectorA, d.vectorB, color, thickness);
			}
		}
	}
	internal static class SkVersionChecker
	{
		private static readonly string VersionURL = "https://pastebin.com/raw/ubRAdqxz";

		internal static Version currentVersion = new Version("1.0.0.0");

		internal static Version latestVersion = new Version("0.0.0.0");

		public static bool VersionCurrent()
		{
			try
			{
				if (latestVersion == new Version("0.0.0.0"))
				{
					latestVersion = new Version(new WebClient
					{
						Headers = { "User-Agent: SkToolboxUser" + Random.Range(0, 999999) }
					}.DownloadString(VersionURL));
				}
				if (latestVersion > currentVersion)
				{
					return false;
				}
				return true;
			}
			catch (Exception)
			{
				return true;
			}
		}
	}
}
namespace SkToolbox.SkModules
{
	public interface IModule
	{
		void BeginMenu();

		void Start();
	}
	internal class ModConsoleOpt : SkBaseModule, IModule
	{
		internal bool conWriteToFile;

		public ModConsoleOpt()
		{
			ModuleName = "Console Controller";
			Loading();
		}

		public void Start()
		{
			base.CallerEntry = new SkMenuItem(" Console Menu\t►", (Action)delegate
			{
				SkMC.RequestSubMenu(FlushMenu());
			}, "");
			SkPatcher.InitPatch();
			BeginMenu();
			Ready();
		}

		public void BeginMenu()
		{
			SkMenu skMenu = new SkMenu();
			skMenu.AddItemToggle("Write to File", ref conWriteToFile, ToggleWriteFile, "Write log output to file?");
			skMenu.AddItem("Open Log Folder", OpenLogFolder);
			skMenu.AddItem("Reload Menu", ReloadMenu);
			skMenu.AddItem("Unload Toolbox", UnloadMenu);
			base.MenuOptions = skMenu;
		}

		public void ToggleWriteFile()
		{
			conWriteToFile = !conWriteToFile;
			SkConsole.writeToFile = conWriteToFile;
			BeginMenu();
		}

		public void ToggleDevelopment()
		{
			SkPatcher.bDevelopment = !SkPatcher.bDevelopment;
			BeginMenu();
		}

		public void OpenLogFolder()
		{
			SkUtilities.Logz(new string[2] { "CMD", "REQ" }, new string[1] { "Opening Log Directory" }, (LogType)3);
			Application.OpenURL(Application.persistentDataPath);
		}

		public void ReloadMenu()
		{
			SkUtilities.Logz(new string[3] { "BASE", "CMD", "REQ" }, new string[2] { "UNLOADING CONTROLLERS AND MODULES...", "SKTOOLBOX RELOAD REQUESTED." }, (LogType)3);
			SkLoader.Reload();
		}

		public void UnloadMenu()
		{
			SkUtilities.Logz(new string[3] { "BASE", "CMD", "REQ" }, new string[2] { "SKTOOLBOX UNLOAD REQUESTED.", "UNLOADING CONTROLLERS AND MODULES..." }, (LogType)3);
			SkLoader.Unload();
		}

		public void DumpRootObjects()
		{
			//IL_0005: 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)
			for (int i = 0; i < SceneManager.sceneCount; i++)
			{
				Scene sceneAt = SceneManager.GetSceneAt(i);
				GameObject[] rootGameObjects = ((Scene)(ref sceneAt)).GetRootGameObjects();
				foreach (GameObject val in rootGameObjects)
				{
					SkUtilities.Logz(new string[2] { "DUMP", "OBJ" }, new string[1] { ((Object)val).name }, (LogType)3);
				}
			}
		}
	}
	internal class ModLore : SkBaseModule, IModule
	{
		public ModLore()
		{
			ModuleName = "Lore Controller";
			Loading();
		}

		public void Start()
		{
			base.CallerEntry = new SkMenuItem(" Lore Menu\t►", (Action)delegate
			{
				SkMC.RequestSubMenu(FlushMenu());
			}, "");
			BeginMenu();
			Ready();
		}

		public void BeginMenu()
		{
			SkMenu skMenu = new SkMenu();
			skMenu.AddItem("Unlock All", LoreUnlockAll);
			skMenu.AddItem("Relock", LoreLockAll);
			skMenu.AddItem("Give 25 Lore", LoreGivePoints, "May not reflect change until Main Menu");
			skMenu.AddItem("Take 25 Lore", LoreTakePoints, "May not reflect change until Main Menu");
			base.MenuOptions = skMenu;
		}

		public void LoreUnlockAll()
		{
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			FTK_loreItem[] array = ((GEDataArray<FTK_loreItem>)(object)FTK_loreItemDB.GetDB()).m_Array;
			for (int i = 0; i < array.Length; i++)
			{
				FTK_statistic statistic = array[i].GetStatistic();
				if (statistic == null)
				{
					continue;
				}
				if (string.IsNullOrEmpty(statistic.m_RevealStat))
				{
					StatsAchievements.TryPlayerStatisticSetValue(((GEDataBase)statistic).m_ID, 0);
					continue;
				}
				FTK_statistic val = FTK_statisticDB.Get(FTK_statistic.GetEnum(statistic.m_RevealStat));
				if (val != null)
				{
					StatsAchievements.TryPlayerStatisticSetValue(((GEDataBase)val).m_ID, 1);
				}
			}
		}

		public void LoreLockAll()
		{
			LorePersistence.Instance.UnrevealAll(true);
		}

		public void LoreGivePoints()
		{
			LorePersistence instance = LorePersistence.Instance;
			instance.m_PendingLorePoints += 25;
			LorePersistence.Instance.CommitPendingLores();
		}

		public void LoreTakePoints()
		{
			LorePersistence instance = LorePersistence.Instance;
			instance.m_PendingLorePoints -= 25;
			LorePersistence.Instance.CommitPendingLores();
		}
	}
	internal class ModPlayers : SkBaseModule, IModule
	{
		private List<CharacterOverworld> playerList = new List<CharacterOverworld>();

		public CharacterOverworld SelectedPlayer;

		public ModPlayers()
		{
			ModuleName = "Player Controller";
			Loading();
		}

		public void Start()
		{
			base.CallerEntry = new SkMenuItem(" Player Menu\t►", (Action)delegate
			{
				SkMC.RequestSubMenu(FlushMenu());
			}, "");
			BeginMenu();
			Ready();
		}

		public void BeginMenu()
		{
			SkMenu skMenu = new SkMenu();
			skMenu.AddItem("Select Player Menu\t►", BeginSelectPlayer);
			skMenu.AddItem("Full HP/FP All", FullHeal, "Heal all to full");
			skMenu.AddItem("Give Health", IncreaseHealth, "Full health");
			skMenu.AddItem("Give AP", IncreaseActionPoints, "Add 1 action point");
			skMenu.AddItem("Give Gold", IncreaseGold, "Give 100 gold");
			skMenu.AddItem("Give Herb", BeginGiveHerb, "Give any herb");
			skMenu.AddItem("Give Scroll", BeginGiveScroll, "Give any scroll");
			skMenu.AddItem("Increase Level", LevelUp, "Advance to next xp level");
			skMenu.AddItem("Give Item", BeginGiveItem, "Give any item");
			skMenu.AddItem("Give TP Scrolls", AddTPScrolls, "Give teleport scrolls");
			skMenu.AddItem("Give All Spells", AddAllSpells, "Add the book of all spells");
			skMenu.AddItem("Give All Keys", GiveKeys, "Add all keys to backpack");
			skMenu.AddItem("Give All Items", AddAllItems, "Add all items into backpack");
			skMenu.AddItem("Give Lore Book", BeginGiveLore, "Give book of lore");
			base.MenuOptions = skMenu;
		}

		public void BeginSelectPlayer()
		{
			FindPlayers();
			SkMenu skMenu = new SkMenu();
			skMenu.AddItem("All Players", SelectPlayer, "NOTE: You must select player again if you enter a new/different game!");
			try
			{
				skMenu.AddItem("1) " + playerList[0].m_CharacterStats.m_CharacterName, SelectPlayer, "NOTE: You must select player again if you enter a new/different game!");
				skMenu.AddItem("2) " + playerList[1].m_CharacterStats.m_CharacterName, SelectPlayer, "NOTE: You must select player again if you enter a new/different game!");
				skMenu.AddItem("3) " + playerList[2].m_CharacterStats.m_CharacterName, SelectPlayer, "NOTE: You must select player again if you enter a new/different game!");
			}
			catch (Exception)
			{
				SkUtilities.Logz(new string[1] { "FIND" }, new string[1] { "Player not found (" + playerList.Count + ")" }, (LogType)3);
			}
			RequestMenu(skMenu);
		}

		public void SelectPlayer(string ln = "")
		{
			FindPlayers();
			if (ln.Equals("All Players"))
			{
				SelectedPlayer = null;
			}
			else
			{
				foreach (CharacterOverworld player in playerList)
				{
					if (player.m_CharacterStats.m_CharacterName.Equals(ln.TrimStart(' ', '1', '2', '3', ')')))
					{
						SelectedPlayer = player;
					}
				}
			}
			if ((Object)(object)SelectedPlayer == (Object)null)
			{
				SkUtilities.Logz(new string[1] { "SELECT" }, new string[1] { "All players selected" }, (LogType)3);
			}
			else
			{
				SkUtilities.Logz(new string[1] { "SELECT" }, new string[1] { "Player selected: " + SelectedPlayer.m_CharacterStats.m_CharacterName }, (LogType)3);
			}
			BeginMenu();
		}

		public void FindPlayers()
		{
			playerList.Clear();
			if (!((Object)(object)FTKHub.Instance != (Object)null))
			{
				return;
			}
			foreach (CharacterOverworld characterOverworld in FTKHub.Instance.m_CharacterOverworlds)
			{
				if (!string.IsNullOrEmpty(characterOverworld.m_CharacterStats.m_CharacterName))
				{
					playerList.Add(characterOverworld);
				}
			}
		}

		public void IncreaseHealth(string ln = "")
		{
			int.TryParse(ln, out var result);
			if (result == 0)
			{
				result = 20;
			}
			if ((Object)(object)SelectedPlayer == (Object)null)
			{
				SkUtilities.Logz(new string[1] { "Player" }, new string[1] { "Giving health to all players" }, (LogType)3);
			}
			else
			{
				SkUtilities.Logz(new string[1] { "Player" }, new string[1] { "Giving health to " + ((Object)SelectedPlayer).name }, (LogType)3);
			}
			if ((Object)(object)SelectedPlayer == (Object)null)
			{
				foreach (CharacterOverworld player in playerList)
				{
					player.m_CharacterStats.GainSpecificHealth(result, true, true);
				}
				return;
			}
			SelectedPlayer.m_CharacterStats.GainSpecificHealth(result, true, true);
		}

		public void FullHeal()
		{
			SkUtilities.Logz(new string[1] { "Player" }, new string[1] { "Full heal all" }, (LogType)3);
			foreach (CharacterOverworld player in playerList)
			{
				((Component)player).GetComponent<CharacterStats>().PlayerFullHeal4(true);
			}
		}

		public void IncreaseActionPoints(string ln = "")
		{
			int.TryParse(ln, out var result);
			if (result == 0)
			{
				result = 1;
			}
			if ((Object)(object)SelectedPlayer == (Object)null)
			{
				SkUtilities.Logz(new string[1] { "Player" }, new string[1] { "Increasing action points for all players" }, (LogType)3);
			}
			else
			{
				SkUtilities.Logz(new string[1] { "Player" }, new string[1] { "Increasing action points for " + ((Object)SelectedPlayer).name }, (LogType)3);
			}
			if ((Object)(object)SelectedPlayer == (Object)null)
			{
				foreach (CharacterOverworld player in playerList)
				{
					player.m_CharacterStats.m_ActionPoints = ((Component)player).GetComponent<CharacterStats>().m_ActionPoints + result;
				}
				return;
			}
			SelectedPlayer.m_CharacterStats.m_ActionPoints = SelectedPlayer.m_CharacterStats.m_ActionPoints + result;
		}

		public void IncreaseGold(string ln = "")
		{
			int.TryParse(ln, out var result);
			if (result == 0)
			{
				result = 99;
			}
			if ((Object)(object)SelectedPlayer == (Object)null)
			{
				SkUtilities.Logz(new string[1] { "Player" }, new string[1] { "Giving " + result + " Gold to all players" }, (LogType)3);
			}
			else
			{
				SkUtilities.Logz(new string[1] { "Player" }, new string[1] { "Giving " + result + " Gold to " + ((Object)SelectedPlayer).name }, (LogType)3);
			}
			if ((Object)(object)SelectedPlayer == (Object)null)
			{
				foreach (CharacterOverworld player in playerList)
				{
					CharacterStats characterStats = player.m_CharacterStats;
					characterStats.m_Gold += result;
				}
				return;
			}
			CharacterStats characterStats2 = SelectedPlayer.m_CharacterStats;
			characterStats2.m_Gold += result;
		}

		public void AddAllItems()
		{
			if ((Object)(object)SelectedPlayer == (Object)null)
			{
				SkUtilities.Logz(new string[1] { "Player" }, new string[1] { "All Items to all players" }, (LogType)3);
			}
			else
			{
				SkUtilities.Logz(new string[1] { "Player" }, new string[1] { "All Items to " + ((Object)SelectedPlayer).name }, (LogType)3);
			}
			if ((Object)(object)SelectedPlayer == (Object)null)
			{
				foreach (CharacterOverworld player in playerList)
				{
					player.m_CharacterStats.m_CharacterOverworld.AddAllItemsToBackpack();
				}
				return;
			}
			SelectedPlayer.m_CharacterStats.m_CharacterOverworld.AddAllItemsToBackpack();
		}

		public void AddTPScrolls()
		{
			if ((Object)(object)SelectedPlayer == (Object)null)
			{
				SkUtilities.Logz(new string[1] { "Player" }, new string[1] { "Giving TP Scrolls to all players" }, (LogType)3);
			}
			else
			{
				SkUtilities.Logz(new string[1] { "Player" }, new string[1] { "Giving TP Scrolls to " + ((Object)SelectedPlayer).name }, (LogType)3);
			}
			if ((Object)(object)SelectedPlayer == (Object)null)
			{
				foreach (CharacterOverworld player in playerList)
				{
					player.m_CharacterStats.m_CharacterOverworld.AddItemToBackpack((ID)14, false);
					player.m_CharacterStats.m_CharacterOverworld.AddItemToBackpack((ID)298, false);
				}
				return;
			}
			SelectedPlayer.m_CharacterStats.m_CharacterOverworld.AddItemToBackpack((ID)14, false);
			SelectedPlayer.m_CharacterStats.m_CharacterOverworld.AddItemToBackpack((ID)298, false);
		}

		public void AddAllSpells()
		{
			if ((Object)(object)SelectedPlayer == (Object)null)
			{
				SkUtilities.Logz(new string[1] { "Player" }, new string[1] { "Giving All Spells to all players" }, (LogType)3);
			}
			else
			{
				SkUtilities.Logz(new string[1] { "Player" }, new string[1] { "Giving All Spells to " + ((Object)SelectedPlayer).name }, (LogType)3);
			}
			if ((Object)(object)SelectedPlayer == (Object)null)
			{
				foreach (CharacterOverworld player in playerList)
				{
					player.m_CharacterStats.m_CharacterOverworld.AddItemToBackpack((ID)100090, false);
				}
				return;
			}
			SelectedPlayer.m_CharacterStats.m_CharacterOverworld.AddItemToBackpack((ID)100090, false);
		}

		public void GiveKeys()
		{
			if ((Object)(object)SelectedPlayer == (Object)null)
			{
				SkUtilities.Logz(new string[1] { "Player" }, new string[1] { "Giving All Keys to all players" }, (LogType)3);
			}
			else
			{
				SkUtilities.Logz(new string[1] { "Player" }, new string[1] { "Giving All Keys to " + ((Object)SelectedPlayer).name }, (LogType)3);
			}
			if ((Object)(object)SelectedPlayer == (Object)null)
			{
				foreach (CharacterOverworld player in playerList)
				{
					player.m_CharacterStats.m_CharacterOverworld.AddItemToBackpack((ID)24, false);
					player.m_CharacterStats.m_CharacterOverworld.AddItemToBackpack((ID)25, false);
					player.m_CharacterStats.m_CharacterOverworld.AddItemToBackpack((ID)26, false);
					player.m_CharacterStats.m_CharacterOverworld.AddItemToBackpack((ID)27, false);
					player.m_CharacterStats.m_CharacterOverworld.AddItemToBackpack((ID)28, false);
					player.m_CharacterStats.m_CharacterOverworld.AddItemToBackpack((ID)29, false);
					player.m_CharacterStats.m_CharacterOverworld.AddItemToBackpack((ID)30, false);
					player.m_CharacterStats.m_CharacterOverworld.AddItemToBackpack((ID)31, false);
					player.m_CharacterStats.m_CharacterOverworld.AddItemToBackpack((ID)33, false);
					player.m_CharacterStats.m_CharacterOverworld.AddItemToBackpack((ID)34, false);
					player.m_CharacterStats.m_CharacterOverworld.AddItemToBackpack((ID)35, false);
					player.m_CharacterStats.m_CharacterOverworld.AddItemToBackpack((ID)36, false);
					player.m_CharacterStats.m_CharacterOverworld.AddItemToBackpack((ID)37, false);
					player.m_CharacterStats.m_CharacterOverworld.AddItemToBackpack((ID)38, false);
					player.m_CharacterStats.m_CharacterOverworld.AddItemToBackpack((ID)39, false);
					player.m_CharacterStats.m_CharacterOverworld.AddItemToBackpack((ID)40, false);
					player.m_CharacterStats.m_CharacterOverworld.AddItemToBackpack((ID)41, false);
					player.m_CharacterStats.m_CharacterOverworld.AddItemToBackpack((ID)42, false);
					player.m_CharacterStats.m_CharacterOverworld.AddItemToBackpack((ID)335, false);
				}
				return;
			}
			SelectedPlayer.m_CharacterStats.m_CharacterOverworld.AddItemToBackpack((ID)24, false);
			SelectedPlayer.m_CharacterStats.m_CharacterOverworld.AddItemToBackpack((ID)25, false);
			SelectedPlayer.m_CharacterStats.m_CharacterOverworld.AddItemToBackpack((ID)26, false);
			SelectedPlayer.m_CharacterStats.m_CharacterOverworld.AddItemToBackpack((ID)27, false);
			SelectedPlayer.m_CharacterStats.m_CharacterOverworld.AddItemToBackpack((ID)28, false);
			SelectedPlayer.m_CharacterStats.m_CharacterOverworld.AddItemToBackpack((ID)29, false);
			SelectedPlayer.m_CharacterStats.m_CharacterOverworld.AddItemToBackpack((ID)30, false);
			SelectedPlayer.m_CharacterStats.m_CharacterOverworld.AddItemToBackpack((ID)31, false);
			SelectedPlayer.m_CharacterStats.m_CharacterOverworld.AddItemToBackpack((ID)33, false);
			SelectedPlayer.m_CharacterStats.m_CharacterOverworld.AddItemToBackpack((ID)34, false);
			SelectedPlayer.m_CharacterStats.m_CharacterOverworld.AddItemToBackpack((ID)35, false);
			SelectedPlayer.m_CharacterStats.m_CharacterOverworld.AddItemToBackpack((ID)36, false);
			SelectedPlayer.m_CharacterStats.m_CharacterOverworld.AddItemToBackpack((ID)37, false);
			SelectedPlayer.m_CharacterStats.m_CharacterOverworld.AddItemToBackpack((ID)38, false);
			SelectedPlayer.m_CharacterStats.m_CharacterOverworld.AddItemToBackpack((ID)39, false);
			SelectedPlayer.m_CharacterStats.m_CharacterOverworld.AddItemToBackpack((ID)40, false);
			SelectedPlayer.m_CharacterStats.m_CharacterOverworld.AddItemToBackpack((ID)41, false);
			SelectedPlayer.m_CharacterStats.m_CharacterOverworld.AddItemToBackpack((ID)42, false);
			SelectedPlayer.m_CharacterStats.m_CharacterOverworld.AddItemToBackpack((ID)335, false);
		}

		public void LevelUp()
		{
			if ((Object)(object)SelectedPlayer == (Object)null)
			{
				SkUtilities.Logz(new string[1] { "Player" }, new string[1] { "Level up all players" }, (LogType)3);
			}
			else
			{
				SkUtilities.Logz(new string[1] { "Player" }, new string[1] { "Levelling up " + ((Object)SelectedPlayer).name }, (LogType)3);
			}
			if ((Object)(object)SelectedPlayer == (Object)null)
			{
				foreach (CharacterOverworld player in playerList)
				{
					player.m_CharacterStats.UpdateXP(player.m_CharacterStats.GetXpTillNextPlayerLevel() + 1, true, true);
				}
				return;
			}
			SelectedPlayer.m_CharacterStats.UpdateXP(SelectedPlayer.m_CharacterStats.GetXpTillNextPlayerLevel() + 1, true, true);
		}

		public void GiveXP(string ln = "")
		{
			int.TryParse(ln, out var result);
			if (result == 0)
			{
				result = 99;
			}
			if ((Object)(object)SelectedPlayer == (Object)null)
			{
				SkUtilities.Logz(new string[1] { "Player" }, new string[1] { "Giving XP to all players" }, (LogType)3);
			}
			else
			{
				SkUtilities.Logz(new string[1] { "Player" }, new string[1] { "Giving XP to " + ((Object)SelectedPlayer).name }, (LogType)3);
			}
			if ((Object)(object)SelectedPlayer == (Object)null)
			{
				foreach (CharacterOverworld player in playerList)
				{
					player.m_CharacterStats.UpdateXP(result, true, true);
				}
				return;
			}
			SelectedPlayer.m_CharacterStats.UpdateXP(result, true, true);
		}

		public void BeginGiveItem()
		{
			SkUtilities.Logz(new string[1] { "Give item" }, new string[1] { "Start" }, (LogType)3);
			SkMenu skMenu = new SkMenu();
			foreach (object value in Enum.GetValues(typeof(ID)))
			{
				skMenu.AddItem(value.ToString(), GiveItem, value.ToString());
			}
			SkUtilities.Logz(new string[1] { "Give item" }, new string[1] { "Done" }, (LogType)3);
			RequestMenu(skMenu);
		}

		public void GiveItem(string ln)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			ID val = (ID)Enum.Parse(typeof(ID), ln);
			if ((Object)(object)SelectedPlayer == (Object)null)
			{
				SkUtilities.Logz(new string[1] { "Player" }, new string[1] { "Giving Item " + ln + " to all players" }, (LogType)3);
			}
			else
			{
				SkUtilities.Logz(new string[1] { "Player" }, new string[1] { "Giving Item " + ln + " to " + ((Object)SelectedPlayer).name }, (LogType)3);
			}
			if ((Object)(object)SelectedPlayer == (Object)null)
			{
				foreach (CharacterOverworld player in playerList)
				{
					player.m_CharacterStats.m_CharacterOverworld.AddItemToBackpack(val, true);
				}
				return;
			}
			((Component)SelectedPlayer).GetComponent<CharacterStats>().m_CharacterOverworld.AddItemToBackpack(val, true);
		}

		public void BeginGiveHerb()
		{
			SkUtilities.Logz(new string[1] { "Give herb" }, new string[1] { "Start" }, (LogType)3);
			SkMenu skMenu = new SkMenu();
			foreach (object value in Enum.GetValues(typeof(ID)))
			{
				if (value.ToString().Contains("herb"))
				{
					skMenu.AddItem(value.ToString(), GiveItem, value.ToString());
				}
			}
			SkUtilities.Logz(new string[1] { "Give herb" }, new string[1] { "Done" }, (LogType)3);
			RequestMenu(skMenu);
		}

		public void BeginGiveScroll()
		{
			SkUtilities.Logz(new string[1] { "Give Scroll" }, new string[1] { "Start" }, (LogType)3);
			SkMenu skMenu = new SkMenu();
			foreach (object value in Enum.GetValues(typeof(ID)))
			{
				if (value.ToString().Contains("scroll"))
				{
					skMenu.AddItem(value.ToString(), GiveItem, value.ToString());
				}
			}
			SkUtilities.Logz(new string[1] { "Give Scroll" }, new string[1] { "Done" }, (LogType)3);
			RequestMenu(skMenu);
		}

		public void BeginGiveLore()
		{
			SkUtilities.Logz(new string[1] { "Give Lore" }, new string[1] { "Start" }, (LogType)3);
			SkMenu skMenu = new SkMenu();
			foreach (object value in Enum.GetValues(typeof(ID)))
			{
				if (value.ToString().Contains("lore"))
				{
					skMenu.AddItem(value.ToString(), GiveItem, value.ToString());
				}
			}
			SkUtilities.Logz(new string[1] { "Give Lore" }, new string[1] { "Done" }, (LogType)3);
			RequestMenu(skMenu);
		}
	}
	internal class ModWorld : SkBaseModule, IModule
	{
		public ModWorld()
		{
			ModuleName = "World Controller";
			Loading();
		}

		public void Start()
		{
			base.CallerEntry = new SkMenuItem(" World Menu\t►", (Action)delegate
			{
				SkMC.RequestSubMenu(FlushMenu());
			}, "");
			BeginMenu();
			Ready();
		}

		public void BeginMenu()
		{
			SkMenu skMenu = new SkMenu();
			skMenu.AddItem("Reveal Map", RevealMap);
			skMenu.AddItem("Reduce Chaos", ReduceChaos);
			skMenu.AddItem("Remove Scourge", RemoveScourge);
			skMenu.AddItem("Max Life Pool", SetLifePool);
			base.MenuOptions = skMenu;
		}

		public void RevealMap()
		{
			GameLogic.Instance.RevealMap();
		}

		public void ReduceChaos()
		{
			GameFlow.Instance.ReduceChaos(1);
		}

		public void RemoveScourge()
		{
			GameFlow.Instance.RemoveScourge();
		}

		public void SetLifePool()
		{
			SkUtilities.Logz(new string[1] { "SET" }, new string[1] { "Max Life Pool" }, (LogType)3);
			GameFlow.Instance.SetLifePool(GameFlow.Instance.MaxLifePool);
		}
	}
	public class SkBaseModule : MonoBehaviour
	{
		internal SkMenuController SkMC;

		public string ModuleName = "UNNAMED";