Decompiled source of ScheduleToolbox v2.1.5

ScheduleToolbox-IL2CPP.dll

Decompiled 2 days ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using HarmonyLib;
using Il2CppFishNet;
using Il2CppFishNet.Connection;
using Il2CppInterop.Runtime;
using Il2CppInterop.Runtime.Injection;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppScheduleOne;
using Il2CppScheduleOne.Cartel;
using Il2CppScheduleOne.Core.Items.Framework;
using Il2CppScheduleOne.DevUtilities;
using Il2CppScheduleOne.Economy;
using Il2CppScheduleOne.ItemFramework;
using Il2CppScheduleOne.Map;
using Il2CppScheduleOne.NPCs;
using Il2CppScheduleOne.Persistence;
using Il2CppScheduleOne.PlayerScripts;
using Il2CppScheduleOne.Product;
using Il2CppScheduleOne.Storage;
using Il2CppScheduleOne.UI;
using Il2CppScheduleOne.UI.MainMenu;
using Il2CppSystem;
using Il2CppSystem.Collections.Generic;
using Il2CppSystem.Globalization;
using MelonLoader;
using MelonLoader.Preferences;
using MelonLoader.Utils;
using Microsoft.CodeAnalysis;
using Newtonsoft.Json;
using ScheduleToolbox;
using ScheduleToolbox.Commands;
using ScheduleToolbox.Helpers;
using ScheduleToolbox.Models;
using UnityEngine;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: MelonInfo(typeof(global::ScheduleToolbox.ScheduleToolbox), "ScheduleToolbox", "2.1.5", "k073l", null)]
[assembly: MelonColor(1, 255, 0, 0)]
[assembly: MelonGame("TVGS", "Schedule I")]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("ScheduleToolbox-IL2CPP")]
[assembly: AssemblyConfiguration("Release IL2CPP")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+a041d2978dcd999861ace7bb09ce0fec2ce6d765")]
[assembly: AssemblyProduct("ScheduleToolbox-IL2CPP")]
[assembly: AssemblyTitle("ScheduleToolbox-IL2CPP")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

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

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

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace ScheduleToolbox
{
	public static class BuildInfo
	{
		public const string Name = "ScheduleToolbox";

		public const string Description = "Testing tools for Schedule I";

		public const string Author = "k073l";

		public const string Version = "2.1.5";
	}
	public class ScheduleToolbox : MelonMod
	{
		private static Instance Logger;

		private bool _addedCommands = false;

		public override void OnInitializeMelon()
		{
			Logger = ((MelonBase)this).LoggerInstance;
			Logger.Msg("ScheduleToolbox initialized");
			ToolboxData data = PersistenceManager.Data;
			ConsoleManager.Initialize();
		}

		public override void OnSceneWasLoaded(int buildIndex, string sceneName)
		{
			if (sceneName == "Menu")
			{
				HoldToLoadManager.Instance.Reset();
				ConsoleManager.Instance.StopTimewarp();
			}
			if (sceneName == "Main")
			{
				ConsoleManager.Instance.SetConsoleUI(Object.FindObjectOfType<ConsoleUI>());
				Logger.Msg("Main scene loaded, starting console commands coroutine");
				MelonCoroutines.Start(Utils.WaitForSingleton<Console>(ConsoleCoro()));
			}
		}

		public override void OnUpdate()
		{
			ConsoleManager.Instance.Update();
			HoldToLoadManager.Instance.Update();
		}

		private IEnumerator ConsoleCoro()
		{
			if (_addedCommands)
			{
				Logger.Msg("Console commands already added, skipping.");
				yield break;
			}
			yield return (object)new WaitForSeconds(1f);
			List<ConsoleCommand> commands = new List<ConsoleCommand>
			{
				(ConsoleCommand)(object)new FlyCommand(),
				(ConsoleCommand)(object)new TeleportCommand(),
				(ConsoleCommand)(object)new SavePosCommand(),
				(ConsoleCommand)(object)new PosCommand(),
				(ConsoleCommand)(object)new TimeWarpCommand(),
				(ConsoleCommand)(object)new ForceCartelDealCommand(),
				(ConsoleCommand)(object)new SetCartelInfluenceCommand(),
				(ConsoleCommand)(object)new ForceDealCommand(),
				(ConsoleCommand)(object)new CopyCommand(),
				(ConsoleCommand)(object)new PasteCommand(),
				(ConsoleCommand)(object)new ListItemsCommand(),
				(ConsoleCommand)(object)new ListNPCsCommand()
			};
			foreach (ConsoleCommand command in commands)
			{
				string commandWord = command.CommandWord;
				Console.commands.Add(commandWord, command);
				Console.Commands.Add(command);
				Logger.Msg("Registered command: " + commandWord);
			}
			_addedCommands = true;
		}

		public override void OnGUI()
		{
			PosCommand.OnGUI();
			SavePosCommand.OnGUI();
			TimeWarpCommand.OnGUI();
		}
	}
}
namespace ScheduleToolbox.Patches
{
	[HarmonyPatch(typeof(ConsoleUI), "UpdateCommandHistory")]
	public class DisableNativeCommandHistory
	{
		public static bool Prefix(ConsoleUI __instance)
		{
			return false;
		}
	}
	[HarmonyPatch(typeof(Disclaimer), "Awake")]
	public class DisclaimerSkip
	{
		public static bool Prefix(MonoBehaviour __instance)
		{
			((Component)__instance).gameObject.SetActive(false);
			return false;
		}
	}
	[HarmonyPatch(typeof(PlayerCamera), "Exit")]
	public class FlyEscFunctionality
	{
		private static bool Prefix(PlayerCamera __instance, ExitAction action)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Invalid comparison between Unknown and I4
			if (action.Used)
			{
				return true;
			}
			if (!__instance.FreeCamEnabled || (int)action.Type > 0)
			{
				return true;
			}
			action.Used = true;
			FlyCommand.TeleportToCameraPos();
			__instance.SetFreeCam(false, true);
			return false;
		}
	}
	[HarmonyPatch(typeof(ConsoleCommand), "Execute")]
	public static class Il2CppConsolePatch
	{
		public static bool Prefix(ConsoleCommand __instance, List<string> args)
		{
			__instance.Execute(args);
			return false;
		}
	}
	[HarmonyPatch(typeof(Console))]
	public class LogCommands
	{
		[HarmonyPatch("SubmitCommand", new Type[] { typeof(List<string>) })]
		[HarmonyPrefix]
		public static bool LogConsoleCommands(Console __instance, List<string> args)
		{
			if (args.Count == 0 || (!InstanceFinder.IsHost && !Debug.isDebugBuild && !Application.isEditor))
			{
				return true;
			}
			for (int i = 0; i < args.Count; i++)
			{
				args._items[i] = args._items[i].ToLower();
			}
			string text = args.AsEnumerable<string>().ElementAt(0);
			ConsoleCommand val = default(ConsoleCommand);
			if (!Console.commands.TryGetValue(text, ref val))
			{
				Console.LogWarning(Object.op_Implicit("Command " + text + " not found."), (Object)null);
				return false;
			}
			args.RemoveAt(0);
			val.Execute(args);
			string text2 = "";
			for (int j = 0; j < args.Count; j++)
			{
				text2 += args.AsEnumerable<string>().ElementAt(j);
				if (j < args.Count - 1)
				{
					text2 += " ";
				}
			}
			MelonLogger.Msg("Executed command: " + text + " " + text2);
			string path = Path.Combine(MelonEnvironment.UserDataDirectory, "ScheduleToolbox", "history.log");
			Directory.CreateDirectory(Path.GetDirectoryName(path));
			File.AppendAllText(path, text + " " + text2 + "\n");
			List<string> list = File.ReadAllLines(path).ToList();
			if (ConsoleManager.MaxBufferLines.Value > 0 && list.Count > ConsoleManager.MaxBufferLines.Value)
			{
				list = list.Skip(list.Count - ConsoleManager.MaxBufferLines.Value).ToList();
				File.WriteAllLines(path, list);
			}
			return false;
		}
	}
	[HarmonyPatch(typeof(Bind), "Execute")]
	internal static class Console_AddBinding
	{
		public static bool Prefix(Bind __instance, List<string> args)
		{
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			if (args.Count > 1)
			{
				string text = args[0].ToLower();
				if (!Enum.TryParse<KeyCode>(text, ignoreCase: true, out KeyCode result))
				{
					Console.LogCommandError("Unrecognized keycode '" + text + "'");
				}
				string command = string.Join(" ", Il2CppArrayBase<string>.op_Implicit(args.ToArray())).Substring(text.Length + 1);
				AddBinding(result, command);
			}
			else
			{
				Console.LogUnrecognizedFormat(Il2CppStringArray.op_Implicit(new string[1] { ((ConsoleCommand)__instance).ExampleUsage }));
			}
			return false;
		}

		private static void AddBinding(KeyCode key, string command)
		{
			//IL_0001: 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)
			command = PersistKeybindings.SaveBinding(key, command);
			PersistenceManager.SaveKeybind(key, command);
		}
	}
	[HarmonyPatch(typeof(Unbind), "Execute")]
	internal static class Console_RemoveBinding
	{
		public static bool Prefix(Unbind __instance, List<string> args)
		{
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			if (args.Count > 0)
			{
				string text = args[0].ToLower();
				if (!Enum.TryParse<KeyCode>(text, ignoreCase: true, out KeyCode result))
				{
					Console.LogCommandError("Unrecognized keycode '" + text + "'");
				}
				RemoveBinding(result);
			}
			else
			{
				Console.LogUnrecognizedFormat(Il2CppStringArray.op_Implicit(new string[1] { ((ConsoleCommand)__instance).ExampleUsage }));
			}
			return false;
		}

		private static void RemoveBinding(KeyCode key)
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			Console.Log(Object.op_Implicit($"Unbinding {key}"), (Object)null);
			Singleton<Console>.Instance.keyBindings.Remove(key);
			PersistenceManager.RemoveKeybind(key);
		}
	}
	[HarmonyPatch(typeof(ClearBinds), "Execute")]
	internal static class Console_ClearBindings
	{
		public static bool Prefix(ClearBinds __instance, List<string> args)
		{
			Console.Log(Object.op_Implicit("Clearing all key bindings"), (Object)null);
			Singleton<Console>.Instance.keyBindings.Clear();
			PersistenceManager.Data.Keybindings.Clear();
			PersistenceManager.Save();
			return false;
		}
	}
	[HarmonyPatch(typeof(Console))]
	public class PersistKeybindings
	{
		public unsafe static string SaveBinding(KeyCode key, string command)
		{
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			command = StripOuterSingleQuotes(command);
			Console.Log(Object.op_Implicit("Binding " + ((object)(*(KeyCode*)(&key))/*cast due to .constrained prefix*/).ToString() + " to " + command), (Object)null);
			Singleton<Console>.Instance.keyBindings[key] = command;
			return command;
		}

		[HarmonyPatch("Awake")]
		[HarmonyPostfix]
		public static void LoadBindings(Console __instance)
		{
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			foreach (KeyValuePair<string, string> keybinding in PersistenceManager.Data.Keybindings)
			{
				Melon<ScheduleToolbox>.Logger.Msg("Restoring keybind: " + keybinding.Key + " -> " + keybinding.Value);
				if (!Enum.TryParse<KeyCode>(keybinding.Key, ignoreCase: true, out KeyCode result))
				{
					Melon<ScheduleToolbox>.Logger.Warning("Unknown keycode '" + keybinding.Key + "'");
				}
				else
				{
					SaveBinding(result, keybinding.Value);
				}
			}
		}

		private static string StripOuterSingleQuotes(string s)
		{
			if (string.IsNullOrEmpty(s))
			{
				return s;
			}
			if (s.Length >= 2 && s[0] == '\'')
			{
				if (s[s.Length - 1] == '\'')
				{
					return s.Substring(1, s.Length - 1 - 1);
				}
			}
			return s;
		}
	}
	[HarmonyPatch(typeof(Settings), "GetDefaultUnitTypeForPlayer")]
	public class SettingsDefaultUnit
	{
		public static bool Prefix(ref EUnitType __result)
		{
			if (!object.Equals(CultureInfo.CurrentCulture, CultureInfo.InvariantCulture))
			{
				return true;
			}
			__result = (EUnitType)0;
			return false;
		}
	}
}
namespace ScheduleToolbox.Models
{
	[Serializable]
	public class SavedPosition
	{
		public SerializableVector3 position;

		public SerializableQuaternion rotation;
	}
	[Serializable]
	public class SavedPositionsData
	{
		public Dictionary<string, SavedPosition> Positions = new Dictionary<string, SavedPosition>();
	}
	[Serializable]
	public class SerializableQuaternion
	{
		public float x;

		public float y;

		public float z;

		public float w;

		public SerializableQuaternion()
		{
		}

		public SerializableQuaternion(Quaternion q)
		{
			//IL_0009: 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_0021: 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)
			x = q.x;
			y = q.y;
			z = q.z;
			w = q.w;
		}

		public Quaternion ToUnity()
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			return new Quaternion(x, y, z, w);
		}
	}
	[Serializable]
	public class SerializableVector3
	{
		public float x;

		public float y;

		public float z;

		public SerializableVector3()
		{
		}

		public SerializableVector3(Vector3 v)
		{
			//IL_0009: 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_0021: Unknown result type (might be due to invalid IL or missing references)
			x = v.x;
			y = v.y;
			z = v.z;
		}

		public Vector3 ToUnity()
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			return new Vector3(x, y, z);
		}
	}
	[Serializable]
	public class ToolboxData
	{
		public Dictionary<string, string> Keybindings = new Dictionary<string, string>();

		public Dictionary<string, SavedPosition> Positions = new Dictionary<string, SavedPosition>();
	}
}
namespace ScheduleToolbox.Helpers
{
	public class ConsoleManager
	{
		private static readonly Instance Logger = new Instance("ScheduleToolbox-ConsoleManager");

		private static ConsoleManager _instance;

		private ConsoleUI _consoleUI;

		private int currentBufferLine = -1;

		private List<string> autocompleteMatches = new List<string>();

		private int autocompleteIndex = -1;

		private string lastInputText = string.Empty;

		private string autocompletePrefix = string.Empty;

		private bool autocompleteActive = false;

		internal static MelonPreferences_Entry<int> MaxBufferLines;

		private MelonPreferences_Entry<KeyCode> _timewarpToggleKey;

		private MelonPreferences_Entry<KeyCode> _timewarpSpeedUpKey;

		private MelonPreferences_Entry<KeyCode> _timewarpSlowDownKey;

		private MelonPreferences_Entry<float> _timewarpDefaultSpeed;

		private MelonPreferences_Entry<float> _timewarpSpeedStep;

		private MelonPreferences_Entry<float> _timewarpMinSpeed;

		private MelonPreferences_Entry<float> _timewarpMaxSpeed;

		private float _currentTimewarpSpeed;

		public static ConsoleManager Instance => _instance ?? (_instance = new ConsoleManager());

		public bool IsConsoleOpen => (Object)(object)_consoleUI != (Object)null && (Object)(object)_consoleUI.canvas != (Object)null && ((Behaviour)_consoleUI.canvas).enabled;

		public static void Initialize()
		{
			MelonPreferences_Category val = MelonPreferences.CreateCategory("ScheduleToolbox-Settings", "Schedule Toolbox Settings");
			MaxBufferLines = val.CreateEntry<int>("MaxConsoleBufferLines", 0, "Max Console Buffer Lines", "Maximum number of lines to keep in the console history file. Set to 0 for unlimited.", false, false, (ValueValidator)null, (string)null);
			Instance._timewarpToggleKey = val.CreateEntry<KeyCode>("TimewarpToggleKey", (KeyCode)268, "Timewarp Toggle Key", "Key to toggle timewarp on/off.", false, false, (ValueValidator)null, (string)null);
			Instance._timewarpSpeedUpKey = val.CreateEntry<KeyCode>("TimewarpSpeedUpKey", (KeyCode)270, "Timewarp Speed Up Key", "Key to increase timewarp speed.", false, false, (ValueValidator)null, (string)null);
			Instance._timewarpSlowDownKey = val.CreateEntry<KeyCode>("TimewarpSlowDownKey", (KeyCode)269, "Timewarp Slow Down Key", "Key to decrease timewarp speed.", false, false, (ValueValidator)null, (string)null);
			Instance._timewarpDefaultSpeed = val.CreateEntry<float>("TimewarpDefaultSpeed", 5f, "Timewarp Default Speed", "Default timewarp speed multiplier.", false, false, (ValueValidator)(object)new ValueRange<float>(1f, 100f), (string)null);
			Instance._timewarpSpeedStep = val.CreateEntry<float>("TimewarpSpeedStep", 1f, "Timewarp Speed Step", "Amount to increase/decrease speed per key press.", false, false, (ValueValidator)(object)new ValueRange<float>(0.1f, 50f), (string)null);
			Instance._timewarpMinSpeed = val.CreateEntry<float>("TimewarpMinSpeed", 2f, "Timewarp Min Speed", "Minimum timewarp speed.", false, false, (ValueValidator)(object)new ValueRange<float>(1f, 100f), (string)null);
			Instance._timewarpMaxSpeed = val.CreateEntry<float>("TimewarpMaxSpeed", 20f, "Timewarp Max Speed", "Maximum timewarp speed.", false, false, (ValueValidator)(object)new ValueRange<float>(1f, 100f), (string)null);
			Instance._currentTimewarpSpeed = Instance._timewarpDefaultSpeed.Value;
		}

		public void SetConsoleUI(ConsoleUI ui)
		{
			_consoleUI = ui;
		}

		public void StopTimewarp()
		{
			if (TimeWarpCommand.IsActive)
			{
				TimeWarpCommand.Stop();
			}
		}

		public void Update()
		{
			UpdateConsoleInput();
			HandleTimewarpKeybinds();
		}

		private void UpdateConsoleInput()
		{
			if ((Object)(object)_consoleUI == (Object)null || (Object)(object)_consoleUI.canvas == (Object)null)
			{
				return;
			}
			if (((Behaviour)_consoleUI.canvas).enabled)
			{
				string[] array;
				try
				{
					array = File.ReadAllLines(Path.Combine(MelonEnvironment.UserDataDirectory, "ScheduleToolbox", "history.log"));
				}
				catch (Exception ex)
				{
					Exception ex2 = ex;
					Exception ex3 = ex2;
					if (!(ex3 is DirectoryNotFoundException) && !(ex3 is FileNotFoundException))
					{
						Logger.Error($"Error reading history file: {ex}");
					}
					return;
				}
				if (Input.GetKeyDown((KeyCode)273))
				{
					if (array.Length != 0)
					{
						currentBufferLine = Mathf.Clamp(currentBufferLine + 1, 0, array.Length - 1);
						_consoleUI.InputField.SetTextWithoutNotify(array[^(currentBufferLine + 1)]);
					}
				}
				else if (Input.GetKeyDown((KeyCode)274))
				{
					if (array.Length != 0)
					{
						currentBufferLine = Mathf.Clamp(currentBufferLine - 1, -1, array.Length - 1);
						_consoleUI.InputField.SetTextWithoutNotify((currentBufferLine == -1) ? "" : array[^(currentBufferLine + 1)]);
					}
				}
				else if (Input.GetKeyDown((KeyCode)9))
				{
					string text = _consoleUI.InputField.text.Trim();
					if (!autocompleteActive)
					{
						autocompletePrefix = text;
						autocompleteActive = true;
						List<string> list = new List<string>();
						Enumerator<string, ConsoleCommand> enumerator = Console.commands.GetEnumerator();
						while (enumerator.MoveNext())
						{
							KeyValuePair<string, ConsoleCommand> current = enumerator.Current;
							list.Add(current.Key);
						}
						autocompleteMatches = (from cmd in list
							where cmd.StartsWith(autocompletePrefix, StringComparison.OrdinalIgnoreCase)
							orderby cmd
							select cmd).ToList();
						autocompleteIndex = 0;
					}
					else if (autocompleteMatches.Count > 0)
					{
						autocompleteIndex = (autocompleteIndex + 1) % autocompleteMatches.Count;
					}
					if (autocompleteMatches.Count > 0)
					{
						string text2 = autocompleteMatches[autocompleteIndex];
						_consoleUI.InputField.SetTextWithoutNotify(text2);
						_consoleUI.InputField.caretPosition = text2.Length;
						lastInputText = text2;
					}
				}
				else
				{
					string a = _consoleUI.InputField.text.Trim();
					if (!string.Equals(a, lastInputText, StringComparison.OrdinalIgnoreCase))
					{
						autocompleteMatches.Clear();
						autocompleteIndex = -1;
						autocompletePrefix = string.Empty;
						autocompleteActive = false;
						lastInputText = a;
					}
				}
			}
			else
			{
				currentBufferLine = -1;
			}
		}

		private void HandleTimewarpKeybinds()
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			if (IsConsoleOpen)
			{
				return;
			}
			if (Input.GetKeyDown(_timewarpToggleKey.Value))
			{
				if (TimeWarpCommand.IsActive)
				{
					TimeWarpCommand.Stop();
				}
				else
				{
					_currentTimewarpSpeed = _timewarpDefaultSpeed.Value;
					TimeWarpCommand.Toggle(_currentTimewarpSpeed);
				}
			}
			if (Input.GetKeyDown(_timewarpSpeedUpKey.Value))
			{
				_currentTimewarpSpeed = Mathf.Clamp(_currentTimewarpSpeed + _timewarpSpeedStep.Value, _timewarpMinSpeed.Value, _timewarpMaxSpeed.Value);
				if (TimeWarpCommand.IsActive)
				{
					TimeWarpCommand.SetSpeed(_currentTimewarpSpeed);
				}
			}
			if (Input.GetKeyDown(_timewarpSlowDownKey.Value))
			{
				_currentTimewarpSpeed = Mathf.Clamp(_currentTimewarpSpeed - _timewarpSpeedStep.Value, _timewarpMinSpeed.Value, _timewarpMaxSpeed.Value);
				if (TimeWarpCommand.IsActive)
				{
					TimeWarpCommand.SetSpeed(_currentTimewarpSpeed);
				}
			}
		}
	}
	public class HoldToLoadManager
	{
		private static readonly Instance Logger = new Instance("ScheduleToolbox-HoldToLoad");

		private static HoldToLoadManager _instance;

		private readonly Dictionary<KeyCode, float> holdTimers = new Dictionary<KeyCode, float>
		{
			{
				(KeyCode)49,
				0f
			},
			{
				(KeyCode)50,
				0f
			},
			{
				(KeyCode)51,
				0f
			},
			{
				(KeyCode)52,
				0f
			},
			{
				(KeyCode)53,
				0f
			}
		};

		private bool _shouldResetTimers;

		public static HoldToLoadManager Instance => _instance ?? (_instance = new HoldToLoadManager());

		public void Reset()
		{
			_shouldResetTimers = true;
		}

		public void Update()
		{
			//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)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: 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_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: 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_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Expected I4, but got Unknown
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			if (_shouldResetTimers)
			{
				_shouldResetTimers = false;
				List<KeyCode> list = new List<KeyCode>(holdTimers.Keys);
				foreach (KeyCode item in list)
				{
					holdTimers[item] = 0f;
				}
			}
			Scene activeScene = SceneManager.GetActiveScene();
			if (((Scene)(ref activeScene)).name != "Menu")
			{
				return;
			}
			List<KeyCode> list2 = new List<KeyCode>(holdTimers.Keys);
			foreach (KeyCode item2 in list2)
			{
				if (Input.GetKey(item2))
				{
					holdTimers[item2] += Time.deltaTime;
					if (holdTimers[item2] >= 0.5f)
					{
						int num = item2 - 48;
						Logger.Msg($"Trying to load save in slot: {num}");
						holdTimers[item2] = -999f;
						if (num <= ((Il2CppArrayBase<SaveInfo>)(object)LoadManager.SaveGames).Length)
						{
							Singleton<LoadManager>.Instance.StartGame(((Il2CppArrayBase<SaveInfo>)(object)LoadManager.SaveGames)[num - 1], false, true);
							continue;
						}
						Logger.Warning($"Save slot {num} doesn't exist.");
					}
				}
				else if (holdTimers[item2] >= 0f)
				{
					holdTimers[item2] = 0f;
				}
			}
		}
	}
	public static class MelonLoggerExtensions
	{
		public static void Debug(this Instance logger, string message, bool stacktrace = true)
		{
		}

		private static string GetLoggerName(Instance logger)
		{
			return typeof(Instance).GetField("Name", BindingFlags.Instance | BindingFlags.NonPublic)?.GetValue(logger) as string;
		}

		private static void InvokeNativeMsg(Color namesectionColor, Color textColor, string nameSection, string message)
		{
			typeof(MelonLogger).GetMethod("NativeMsg", BindingFlags.Static | BindingFlags.NonPublic)?.Invoke(null, new object[5]
			{
				namesectionColor,
				textColor,
				nameSection,
				message ?? "null",
				false
			});
		}

		private static string GetCallerInfo()
		{
			StackTrace stackTrace = new StackTrace();
			for (int i = 2; i < stackTrace.FrameCount; i++)
			{
				StackFrame frame = stackTrace.GetFrame(i);
				MethodBase method = frame.GetMethod();
				if (!(method?.DeclaringType == null))
				{
					return method.DeclaringType.FullName + "." + method.Name;
				}
			}
			return "unknown";
		}
	}
	public static class PersistenceManager
	{
		private static readonly string SaveFilePath;

		private static readonly Instance Logger;

		public static ToolboxData Data { get; private set; }

		static PersistenceManager()
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Expected O, but got Unknown
			SaveFilePath = Path.Combine(MelonEnvironment.UserDataDirectory, "ScheduleToolbox", "ScheduleToolbox.json");
			Logger = new Instance("ScheduleToolbox-PositionManager");
			Load();
		}

		public static void SavePosition(string name, Vector3 position, Quaternion rotation)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			Data.Positions[name] = new SavedPosition
			{
				position = new SerializableVector3(position),
				rotation = new SerializableQuaternion(rotation)
			};
			Save();
		}

		public static bool TryGetPosition(string name, out Vector3 position, out Quaternion rotation)
		{
			//IL_003f: 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_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			if (Data.Positions.TryGetValue(name, out var value))
			{
				position = value.position.ToUnity();
				rotation = value.rotation.ToUnity();
				return true;
			}
			position = default(Vector3);
			rotation = default(Quaternion);
			return false;
		}

		public unsafe static void SaveKeybind(KeyCode key, string command)
		{
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			if (Data.Keybindings.TryGetValue(((object)(*(KeyCode*)(&key))/*cast due to .constrained prefix*/).ToString(), out var value) && value != command)
			{
				Logger.Msg($"Overwriting keybind for {key}: '{value}' -> '{command}'");
			}
			Data.Keybindings[((object)(*(KeyCode*)(&key))/*cast due to .constrained prefix*/).ToString()] = command;
			Save();
		}

		public unsafe static void RemoveKeybind(KeyCode key)
		{
			Data.Keybindings.Remove(((object)(*(KeyCode*)(&key))/*cast due to .constrained prefix*/).ToString());
			Save();
		}

		public static void Save()
		{
			try
			{
				string contents = JsonConvert.SerializeObject((object)Data, (Formatting)1);
				Directory.CreateDirectory(Path.GetDirectoryName(SaveFilePath));
				File.WriteAllText(SaveFilePath, contents);
				Logger.Debug($"Saved {Data.Positions.Count} positions to: {SaveFilePath}");
			}
			catch (Exception value)
			{
				Logger.Error($"Save failed: {value}");
			}
		}

		public static void Load()
		{
			try
			{
				if (File.Exists(SaveFilePath))
				{
					string text = File.ReadAllText(SaveFilePath);
					Data = JsonConvert.DeserializeObject<ToolboxData>(text) ?? new ToolboxData();
					Logger.Debug($"Loaded {Data.Positions.Count} positions.");
				}
				else
				{
					Logger.Debug("Save file not found. Starting fresh.");
					Data = new ToolboxData();
				}
			}
			catch (Exception value)
			{
				Logger.Error($"Load failed: {value}");
				Data = new ToolboxData();
			}
		}
	}
	public static class Il2CppListExtensions
	{
		public static IEnumerable<T> AsEnumerable<T>(this List<T> list)
		{
			return list ?? new List<T>();
		}

		public static List<T> ToIl2CppList<T>(this IEnumerable<T> source)
		{
			List<T> val = new List<T>();
			foreach (T item in source)
			{
				val.Add(item);
			}
			return val;
		}

		public static List<T> ConvertToList<T>(List<T> il2CppList)
		{
			List<T> list = new List<T>();
			T[] collection = Il2CppArrayBase<T>.op_Implicit(il2CppList.ToArray());
			list.AddRange(collection);
			return list;
		}

		public static IEnumerable<T> AsEnumerable<T>(this List<T> list)
		{
			IEnumerable<T> result;
			if (list != null)
			{
				result = ((IEnumerable<T>)list._items).Take(list._size);
			}
			else
			{
				IEnumerable<T> enumerable = Array.Empty<T>();
				result = enumerable;
			}
			return result;
		}
	}
	public static class Utils
	{
		private static readonly Instance Logger = new Instance("ScheduleToolbox-Utils");

		public static T FindObjectByName<T>(string objectName) where T : Object
		{
			try
			{
				foreach (T item in Resources.FindObjectsOfTypeAll<T>())
				{
					if (((Object)item).name != objectName)
					{
						continue;
					}
					Logger.Debug($"Found {typeof(T).Name} '{objectName}' directly in loaded objects");
					return item;
				}
				return default(T);
			}
			catch (Exception ex)
			{
				Logger.Error($"Error finding {typeof(T).Name} '{objectName}': {ex.Message}");
				return default(T);
			}
		}

		public static List<T> GetAllComponentsInChildrenRecursive<T>(GameObject obj) where T : Component
		{
			List<T> list = new List<T>();
			if ((Object)(object)obj == (Object)null)
			{
				return list;
			}
			T[] array = Il2CppArrayBase<T>.op_Implicit(obj.GetComponents<T>());
			if (array.Length != 0)
			{
				list.AddRange(array);
			}
			for (int i = 0; i < obj.transform.childCount; i++)
			{
				Transform child = obj.transform.GetChild(i);
				list.AddRange(GetAllComponentsInChildrenRecursive<T>(((Component)child).gameObject));
			}
			return list;
		}

		public static bool Is<T>(object obj, out T result) where T : Object
		{
			Object val = (Object)((obj is Object) ? obj : null);
			if (val != null)
			{
				Type val2 = Il2CppType.Of<T>();
				Type il2CppType = val.GetIl2CppType();
				if (val2.IsAssignableFrom(il2CppType))
				{
					result = ((Il2CppObjectBase)val).TryCast<T>();
					return result != null;
				}
			}
			result = default(T);
			return false;
		}

		public static List<StorableItemDefinition> GetAllStorableItemDefinitions()
		{
			List<ItemRegister> list = Il2CppListExtensions.ConvertToList<ItemRegister>(Singleton<Registry>.Instance.ItemRegistry);
			List<StorableItemDefinition> list2 = new List<StorableItemDefinition>();
			foreach (ItemRegister item in list)
			{
				if (Utils.Is<StorableItemDefinition>((object)item.Definition, out StorableItemDefinition result))
				{
					list2.Add(result);
				}
				else
				{
					Logger.Warning("Definition " + ((object)item.Definition)?.GetType().FullName + " is not a StorableItemDefinition");
				}
			}
			return list2.ToList();
		}

		public static IEnumerator WaitForPlayer(IEnumerator routine)
		{
			while ((Object)(object)Player.Local == (Object)null || (Object)(object)((Component)Player.Local).gameObject == (Object)null)
			{
				yield return null;
			}
			MelonCoroutines.Start(routine);
		}

		public static IEnumerator WaitForNetwork(IEnumerator routine)
		{
			while (!InstanceFinder.IsServer && !InstanceFinder.IsClient)
			{
				yield return null;
			}
			MelonCoroutines.Start(routine);
		}

		public static IEnumerator WaitForNotNull(object? obj, float timeout = float.NaN, Action onTimeout = null, Action onFinish = null)
		{
			float startTime = Time.time;
			while (obj == null)
			{
				if (!float.IsNaN(timeout) && Time.time - startTime > timeout)
				{
					onTimeout?.Invoke();
					yield break;
				}
				yield return null;
			}
			onFinish?.Invoke();
		}

		public static IEnumerator WaitForNetworkSingleton<T>(IEnumerator coroutine) where T : NetworkSingleton<T>
		{
			while (!NetworkSingleton<T>.InstanceExists)
			{
				yield return null;
			}
			yield return coroutine;
		}

		public static IEnumerator WaitForSingleton<T>(IEnumerator coroutine) where T : Singleton<T>
		{
			while (!Singleton<T>.InstanceExists)
			{
				yield return null;
			}
			yield return coroutine;
		}
	}
}
namespace ScheduleToolbox.Commands
{
	[RegisterTypeInIl2Cpp]
	public class CopyCommand : ConsoleCommand
	{
		public override string CommandWord => "copyhand";

		public override string CommandDescription => "Copies the item held in hand";

		public override string ExampleUsage => "copyhand";

		internal static ItemInstance EquippedItem { get; set; }

		public CopyCommand(IntPtr ptr)
			: base(ptr)
		{
		}

		public CopyCommand()
			: base(ClassInjector.DerivedConstructorPointer<CopyCommand>())
		{
			ClassInjector.DerivedConstructorBody((Il2CppObjectBase)(object)this);
		}

		public override void Execute(List<string> args)
		{
			if (!PlayerSingleton<PlayerInventory>.Instance.isAnythingEquipped)
			{
				Melon<ScheduleToolbox>.Logger.Warning("Copy command executed while nothing is held in hand!");
				return;
			}
			ItemInstance equippedItem = PlayerSingleton<PlayerInventory>.Instance.EquippedItem;
			QualityItemInstance result2;
			WaterContainerInstance result3;
			CashInstance result4;
			IntegerItemInstance result5;
			StorableItemInstance result6;
			if (Utils.Is<ProductItemInstance>((object)equippedItem, out ProductItemInstance result))
			{
				EquippedItem = ((ItemInstance)result).GetCopy(-1);
				Melon<ScheduleToolbox>.Logger.Msg("Copied ProductItem " + ((BaseItemInstance)result).ID);
			}
			else if (Utils.Is<QualityItemInstance>((object)equippedItem, out result2))
			{
				EquippedItem = ((ItemInstance)result2).GetCopy(-1);
				Melon<ScheduleToolbox>.Logger.Msg("Copied QualityItem " + ((BaseItemInstance)result2).ID);
			}
			else if (Utils.Is<WaterContainerInstance>((object)equippedItem, out result3))
			{
				EquippedItem = ((ItemInstance)result3).GetCopy(-1);
				Melon<ScheduleToolbox>.Logger.Msg("Copied WaterContainer " + ((BaseItemInstance)result3).ID);
			}
			else if (Utils.Is<CashInstance>((object)equippedItem, out result4))
			{
				EquippedItem = ((ItemInstance)result4).GetCopy(-1);
				Melon<ScheduleToolbox>.Logger.Msg("Copied CashInstance " + ((BaseItemInstance)result4).ID);
			}
			else if (Utils.Is<IntegerItemInstance>((object)equippedItem, out result5))
			{
				EquippedItem = ((ItemInstance)result5).GetCopy(-1);
				Melon<ScheduleToolbox>.Logger.Msg("Copied IntegerItem " + ((BaseItemInstance)result5).ID);
			}
			else if (Utils.Is<StorableItemInstance>((object)equippedItem, out result6))
			{
				EquippedItem = ((ItemInstance)result6).GetCopy(-1);
				Melon<ScheduleToolbox>.Logger.Msg("Copied StorageItem " + ((BaseItemInstance)result6).ID);
			}
			else
			{
				EquippedItem = equippedItem.GetCopy(-1);
			}
		}
	}
	[RegisterTypeInIl2Cpp]
	public class FlyCommand : ConsoleCommand
	{
		public override string CommandWord => "fly";

		public override string CommandDescription => "Toggles fly mode (enhanced freecam)";

		public override string ExampleUsage => "fly";

		public FlyCommand(IntPtr ptr)
			: base(ptr)
		{
		}

		public FlyCommand()
			: base(ClassInjector.DerivedConstructorPointer<FlyCommand>())
		{
			ClassInjector.DerivedConstructorBody((Il2CppObjectBase)(object)this);
		}

		public override void Execute(List<string> args)
		{
			if (PlayerSingleton<PlayerCamera>.Instance.FreeCamEnabled)
			{
				TeleportToCameraPos();
				PlayerSingleton<PlayerCamera>.Instance.SetFreeCam(false, true);
			}
			else
			{
				PlayerSingleton<PlayerCamera>.Instance.SetFreeCam(true, true);
			}
		}

		public static void TeleportToCameraPos()
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: 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_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			Vector3 position = ((Component)PlayerSingleton<PlayerCamera>.Instance).transform.position;
			Quaternion rotation = ((Component)PlayerSingleton<PlayerCamera>.Instance).transform.rotation;
			PlayerSingleton<PlayerCamera>.Instance.SetFreeCam(false, true);
			PlayerSingleton<PlayerMovement>.Instance.Teleport(position, false);
			((Component)Player.Local).transform.rotation = rotation;
			((Component)Player.Local).transform.forward = Vector3.forward;
			PlayerSingleton<PlayerMovement>.Instance.SetResidualVelocity(Vector3.zero, 0f, 0f);
		}
	}
	[RegisterTypeInIl2Cpp]
	public class ForceCartelDealCommand : ConsoleCommand
	{
		public override string CommandWord => "forcecarteldeal";

		public override string CommandDescription => "Forces a cartel deal, nullifying the existent deal";

		public override string ExampleUsage => "forcecarteldeal";

		public ForceCartelDealCommand(IntPtr ptr)
			: base(ptr)
		{
		}

		public ForceCartelDealCommand()
			: base(ClassInjector.DerivedConstructorPointer<ForceCartelDealCommand>())
		{
			ClassInjector.DerivedConstructorBody((Il2CppObjectBase)(object)this);
		}

		public override void Execute(List<string> args)
		{
			CartelDealManager val = Object.FindObjectOfType<CartelDealManager>();
			if ((Object)(object)val == (Object)null)
			{
				MelonLogger.Error("CartelDealManager not found in the scene.");
			}
			else
			{
				val.StartDeal();
			}
		}
	}
	[RegisterTypeInIl2Cpp]
	public class ForceDealCommand : ConsoleCommand
	{
		private static readonly Instance Logger = new Instance("ScheduleToolbox-ForceDeal");

		public override string CommandWord => "forcedeal";

		public override string CommandDescription => "Forces a customer deal to occur.";

		public override string ExampleUsage => "forcedeal kyle_cooley";

		public ForceDealCommand(IntPtr ptr)
			: base(ptr)
		{
		}

		public ForceDealCommand()
			: base(ClassInjector.DerivedConstructorPointer<ForceDealCommand>())
		{
			ClassInjector.DerivedConstructorBody((Il2CppObjectBase)(object)this);
		}

		public override void Execute(List<string> args)
		{
			if (args.Count != 1)
			{
				Logger.Warning("Usage: forcedeal <customer_name>");
				return;
			}
			string text = args.AsEnumerable<string>().ElementAt(0);
			Logger.Msg("Forcing deal with customer: " + text);
			NPC nPC = NPCManager.GetNPC(text);
			if ((Object)(object)nPC == (Object)null)
			{
				Logger.Error("Customer '" + text + "' not found.");
				return;
			}
			Customer component = ((Component)((Component)nPC).transform).GetComponent<Customer>();
			if ((Object)(object)component == (Object)null)
			{
				Logger.Error("Customer component not found on NPC '" + text + "'.");
				return;
			}
			component.ForceDealOffer();
			Logger.Msg("Forced deal with customer: " + text);
		}
	}
	[RegisterTypeInIl2Cpp]
	public class ListItemsCommand : ConsoleCommand
	{
		private static readonly Instance Logger = new Instance("ScheduleToolbox-ListItems");

		public override string CommandWord => "listitems";

		public override string CommandDescription => "Lists all item definitions with optional filter";

		public override string ExampleUsage => "listitems [filter]";

		public ListItemsCommand(IntPtr ptr)
			: base(ptr)
		{
		}

		public ListItemsCommand()
			: base(ClassInjector.DerivedConstructorPointer<ListItemsCommand>())
		{
			ClassInjector.DerivedConstructorBody((Il2CppObjectBase)(object)this);
		}

		public override void Execute(List<string> args)
		{
			string text = ((args.Count > 0) ? args.AsEnumerable<string>().ElementAt(0) : null);
			List<StorableItemDefinition> allStorableItemDefinitions = Utils.GetAllStorableItemDefinitions();
			int num = 0;
			foreach (StorableItemDefinition item in allStorableItemDefinitions)
			{
				string iD = ((BaseItemDefinition)item).ID;
				string name = ((BaseItemDefinition)item).Name;
				if (text == null || (name.Contains(text, StringComparison.OrdinalIgnoreCase) && iD.Contains(text, StringComparison.OrdinalIgnoreCase)))
				{
					Logger.Msg($"  [{name}] ({iD})");
					num++;
				}
			}
			Logger.Msg($"Matched {num} item definitions{((text != null) ? (" for '" + text + "'") : "")} ({allStorableItemDefinitions.Count} total)");
		}
	}
	[RegisterTypeInIl2Cpp]
	public class ListNPCsCommand : ConsoleCommand
	{
		private static readonly Instance Logger = new Instance("ScheduleToolbox-ListNPCs");

		public override string CommandWord => "listnpcs";

		public override string CommandDescription => "Lists all loaded NPCs with optional filter";

		public override string ExampleUsage => "listnpcs [filter]";

		public ListNPCsCommand(IntPtr ptr)
			: base(ptr)
		{
		}

		public ListNPCsCommand()
			: base(ClassInjector.DerivedConstructorPointer<ListNPCsCommand>())
		{
			ClassInjector.DerivedConstructorBody((Il2CppObjectBase)(object)this);
		}

		public override void Execute(List<string> args)
		{
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: 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)
			string text = ((args.Count > 0) ? args.AsEnumerable<string>().ElementAt(0) : null);
			int num = 0;
			Enumerator<NPC> enumerator = NPCManager.NPCRegistry.GetEnumerator();
			while (enumerator.MoveNext())
			{
				NPC current = enumerator.Current;
				string fullName = current.FullName;
				string iD = current.ID;
				Vector3 footPosition = current.Movement.FootPosition;
				if (text == null || (fullName.Contains(text, StringComparison.OrdinalIgnoreCase) && iD.Contains(text, StringComparison.OrdinalIgnoreCase)))
				{
					Logger.Msg($"  {fullName} ({iD}) at ({footPosition.x:F1}, {footPosition.y:F1}, {footPosition.z:F1})");
					num++;
				}
			}
			Logger.Msg($"Matched {num} NPCs{((text != null) ? (" for '" + text + "'") : "")} (total: {NPCManager.NPCRegistry.Count})");
		}
	}
	[RegisterTypeInIl2Cpp]
	public class PasteCommand : ConsoleCommand
	{
		public override string CommandWord => "pastehand";

		public override string CommandDescription => "Gives the copied item with all its properties";

		public override string ExampleUsage => "pastehand";

		public PasteCommand(IntPtr ptr)
			: base(ptr)
		{
		}

		public PasteCommand()
			: base(ClassInjector.DerivedConstructorPointer<PasteCommand>())
		{
			ClassInjector.DerivedConstructorBody((Il2CppObjectBase)(object)this);
		}

		public override void Execute(List<string> args)
		{
			if (CopyCommand.EquippedItem == null)
			{
				Melon<ScheduleToolbox>.Logger.Warning("Copied item is null!");
				return;
			}
			ItemInstance copy = CopyCommand.EquippedItem.GetCopy(-1);
			if (!PlayerSingleton<PlayerInventory>.Instance.CanItemFitInInventory(copy, 1))
			{
				Melon<ScheduleToolbox>.Logger.Warning("Insufficient inventory space");
			}
			if (!PlayerSingleton<PlayerInventory>.Instance.isAnythingEquipped)
			{
				HotbarSlot equippedSlot = PlayerSingleton<PlayerInventory>.Instance.equippedSlot;
				((ItemSlot)equippedSlot).InsertItem(copy);
				Melon<ScheduleToolbox>.Logger.Msg("Pasted in " + ((BaseItemInstance)copy).ID + " into equipped slot");
			}
			else
			{
				PlayerSingleton<PlayerInventory>.Instance.AddItemToInventory(copy);
			}
		}
	}
	[RegisterTypeInIl2Cpp]
	public class PosCommand : ConsoleCommand
	{
		private static readonly Instance Logger = new Instance("ScheduleToolbox-PosCommand");

		private static string _guiMessage = "";

		private static float _guiMessageEndTime = 5f;

		public override string CommandWord => "pos";

		public override string CommandDescription => "Logs the player's current position and rotation";

		public override string ExampleUsage => "pos";

		public PosCommand(IntPtr ptr)
			: base(ptr)
		{
		}

		public PosCommand()
			: base(ClassInjector.DerivedConstructorPointer<PosCommand>())
		{
			ClassInjector.DerivedConstructorBody((Il2CppObjectBase)(object)this);
		}

		public override void Execute(List<string> args)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: 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_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: 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)
			Vector3 position = ((Component)PlayerSingleton<PlayerCamera>.Instance).transform.position;
			Quaternion rotation = ((Component)PlayerSingleton<PlayerCamera>.Instance).transform.rotation;
			string text = $"Pos: ({position.x:F2}, {position.y:F2}, {position.z:F2}); Rot: ({((Quaternion)(ref rotation)).eulerAngles.x:F1}, {((Quaternion)(ref rotation)).eulerAngles.y:F1}, {((Quaternion)(ref rotation)).eulerAngles.z:F1})";
			Logger.Msg(text);
			_guiMessage = text;
			_guiMessageEndTime = Time.time + 3f;
		}

		public static void OnGUI()
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_003c: Expected O, but got Unknown
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			if (Time.time < _guiMessageEndTime)
			{
				GUIStyle val = new GUIStyle(GUI.skin.label)
				{
					fontSize = 14
				};
				val.normal.textColor = Color.white;
				GUIStyle val2 = val;
				GUI.Label(new Rect(10f, (float)(Screen.height - 30), (float)(Screen.width - 20), 25f), _guiMessage, val2);
			}
		}
	}
	[RegisterTypeInIl2Cpp]
	public class SavePosCommand : ConsoleCommand
	{
		private static readonly Instance Logger = new Instance("ScheduleToolbox-SavePosCommand");

		private static string _guiMessage = "";

		private static float _guiMessageEndTime;

		public override string CommandWord => "savepos";

		public override string CommandDescription => "Saves the player's current position and rotation to a named location.";

		public override string ExampleUsage => "savepos home";

		public SavePosCommand(IntPtr ptr)
			: base(ptr)
		{
		}

		public SavePosCommand()
			: base(ClassInjector.DerivedConstructorPointer<SavePosCommand>())
		{
			ClassInjector.DerivedConstructorBody((Il2CppObjectBase)(object)this);
		}

		public override void Execute(List<string> args)
		{
			//IL_003e: 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_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_0055: 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_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0196: Unknown result type (might be due to invalid IL or missing references)
			if (args.Count != 1)
			{
				Logger.Warning("Usage: savepos <name>");
				return;
			}
			string text = args.AsEnumerable<string>().ElementAt(0);
			Vector3 position = ((Component)PlayerSingleton<PlayerCamera>.Instance).transform.position;
			Quaternion rotation = ((Component)PlayerSingleton<PlayerCamera>.Instance).transform.rotation;
			PersistenceManager.SavePosition(text, position, rotation);
			Logger.Msg($"Saved position '{text}': {position.x},{position.y},{position.z} | {rotation.x},{rotation.y},{rotation.z}");
			_guiMessage = $"Saved '{text}' at {position.x}, {position.y}, {position.z}!";
			_guiMessageEndTime = Time.time + 3f;
		}

		public static void OnGUI()
		{
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			if (!string.IsNullOrEmpty(_guiMessage) && Time.time < _guiMessageEndTime)
			{
				GUI.Label(new Rect(10f, (float)(Screen.height - 60), 300f, 45f), _guiMessage);
			}
		}
	}
	[RegisterTypeInIl2Cpp]
	public class SetCartelInfluenceCommand : ConsoleCommand
	{
		public override string CommandWord => "setcartelinfluence";

		public override string CommandDescription => "Sets the cartel influence level for the region.";

		public override string ExampleUsage => "setcartelinfluence westville 1";

		public SetCartelInfluenceCommand(IntPtr ptr)
			: base(ptr)
		{
		}

		public SetCartelInfluenceCommand()
			: base(ClassInjector.DerivedConstructorPointer<SetCartelInfluenceCommand>())
		{
			ClassInjector.DerivedConstructorBody((Il2CppObjectBase)(object)this);
		}

		public override void Execute(List<string> args)
		{
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			if (args.Count != 2)
			{
				MelonLogger.Warning("Usage: setcartelinfluence <region> <influence>");
				return;
			}
			string text = args.AsEnumerable<string>().ElementAt(0);
			if (!Enum.TryParse<EMapRegion>(text, ignoreCase: true, out EMapRegion result))
			{
				MelonLogger.Warning("Invalid region name '" + text + "'. Valid regions are: " + string.Join(", ", Enum.GetNames(typeof(EMapRegion))));
				return;
			}
			if (!float.TryParse(args.AsEnumerable<string>().ElementAt(1), out var result2))
			{
				MelonLogger.Warning("Invalid influence value. Please provide a valid number.");
				return;
			}
			CartelInfluence val = Object.FindObjectOfType<CartelInfluence>();
			if ((Object)(object)val == (Object)null)
			{
				MelonLogger.Error("CartelInfluence not found in the scene.");
				return;
			}
			val.SetInfluence((NetworkConnection)null, result, result2);
			MelonLogger.Msg($"Set cartel influence for {text} to {result2}.");
		}
	}
	[RegisterTypeInIl2Cpp]
	public class TeleportCommand : ConsoleCommand
	{
		private static readonly Instance Logger = new Instance("ScheduleToolbox-TeleportCommand");

		public override string CommandWord => "tp";

		public override string CommandDescription => "Teleports the player to a specified location.";

		public override string ExampleUsage => "(tp <x> [y] <z>) or (tp location)";

		public TeleportCommand(IntPtr ptr)
			: base(ptr)
		{
		}

		public TeleportCommand()
			: base(ClassInjector.DerivedConstructorPointer<TeleportCommand>())
		{
			ClassInjector.DerivedConstructorBody((Il2CppObjectBase)(object)this);
		}

		public override void Execute(List<string> args)
		{
			//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fe: 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)
			//IL_0207: Unknown result type (might be due to invalid IL or missing references)
			//IL_020c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			switch (args.Count)
			{
			case 1:
			{
				string text = args.AsEnumerable<string>().ElementAt(0);
				if (text.Trim() == "players")
				{
					IEnumerable<PlayerMovement> source = ((IEnumerable<PlayerMovement>)Resources.FindObjectsOfTypeAll<PlayerMovement>()).AsEnumerable();
					IEnumerable<PlayerMovement> enumerable = source.Where((PlayerMovement pm) => pm != null && pm.Player.IsLocalPlayer);
					if (!enumerable.Any())
					{
						break;
					}
					Vector3 cameraPosition = Player.Local.CameraPosition;
					foreach (PlayerMovement item in enumerable)
					{
						item.Teleport(cameraPosition, false);
					}
				}
				if (PersistenceManager.TryGetPosition(text, out var position, out var rotation))
				{
					PlayerSingleton<PlayerMovement>.Instance.Teleport(position, false);
					((Component)Player.Local).transform.rotation = rotation;
					((Component)Player.Local).transform.forward = Vector3.forward;
					Logger.Msg($"Teleported to '{text}' at {position}");
				}
				else
				{
					ConsoleCommand val4 = Console.commands["teleport"];
					val4.Execute(args);
				}
				break;
			}
			case 2:
			{
				float result4;
				bool flag4 = float.TryParse(args.AsEnumerable<string>().ElementAt(0), out result4);
				float result5;
				bool flag5 = float.TryParse(args.AsEnumerable<string>().ElementAt(1), out result5);
				if (flag4 && flag5)
				{
					Vector3 val = default(Vector3);
					((Vector3)(ref val))..ctor(result4, 1000f, result5);
					Ray val2 = default(Ray);
					((Ray)(ref val2))..ctor(val, Vector3.down);
					RaycastHit val3 = default(RaycastHit);
					if (Physics.Raycast(val2, ref val3, float.PositiveInfinity))
					{
						Vector3 point = ((RaycastHit)(ref val3)).point;
						PlayerSingleton<PlayerMovement>.Instance.Teleport(point + Vector3.up, false);
					}
					else
					{
						Logger.Error("Could not find ground below given X/Z coordinates.");
					}
				}
				else
				{
					Logger.Error("Invalid coordinates. Please provide valid numbers.");
				}
				break;
			}
			case 3:
			{
				float result;
				bool flag = float.TryParse(args.AsEnumerable<string>().ElementAt(0), out result);
				float result2;
				bool flag2 = float.TryParse(args.AsEnumerable<string>().ElementAt(1), out result2);
				float result3;
				bool flag3 = float.TryParse(args.AsEnumerable<string>().ElementAt(2), out result3);
				if (flag && flag2 && flag3)
				{
					PlayerSingleton<PlayerMovement>.Instance.Teleport(new Vector3(result, result2, result3), false);
				}
				else
				{
					Logger.Error("Invalid coordinates. Please provide valid numbers.");
				}
				break;
			}
			default:
				Logger.Warning("Invalid usage. Use: tp <x> [y] <z> or tp <location>");
				break;
			}
		}
	}
	[RegisterTypeInIl2Cpp]
	public class TimeWarpCommand : ConsoleCommand
	{
		private readonly ConsoleCommand _timeScaleCommand = Console.commands["settimescale"];

		private static List<string> _timeScaleDefault = new string[1] { "5" }.ToIl2CppList();

		private static List<string> _warpDefault = new string[1] { "10" }.ToIl2CppList();

		private static List<string> _warpStop = new string[1] { "1" }.ToIl2CppList();

		private static GUIStyle _hudStyle;

		private static GUIStyle _hudBgStyle;

		public override string CommandWord => "timewarp";

		public override string CommandDescription => "Temporarily speeds up time in the game world.";

		public override string ExampleUsage => "timewarp [seconds] [timescale] | timewarp stop";

		public static bool IsActive { get; private set; }

		public static float CurrentSpeed { get; private set; }

		public TimeWarpCommand(IntPtr ptr)
			: base(ptr)
		{
		}

		public TimeWarpCommand()
			: base(ClassInjector.DerivedConstructorPointer<TimeWarpCommand>())
		{
			ClassInjector.DerivedConstructorBody((Il2CppObjectBase)(object)this);
		}

		public static void Toggle(float speed)
		{
			if (IsActive)
			{
				Stop();
				return;
			}
			SetSpeed(speed);
			IsActive = true;
			MelonLogger.Msg($"Timewarp toggled ON at {CurrentSpeed}x.");
		}

		public static void Stop()
		{
			if (IsActive)
			{
				ConsoleCommand val = Console.commands["settimescale"];
				val.Execute(new string[1] { "1" }.ToIl2CppList());
				IsActive = false;
				MelonLogger.Msg("Timewarp toggled OFF.");
			}
		}

		public static void SetSpeed(float speed)
		{
			CurrentSpeed = speed;
			ConsoleCommand val = Console.commands["settimescale"];
			val.Execute(new string[1] { speed.ToString("F1") }.ToIl2CppList());
			if (IsActive)
			{
				MelonLogger.Msg($"Timewarp speed changed to {CurrentSpeed}x.");
			}
		}

		public static void OnGUI()
		{
			//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_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Expected O, but got Unknown
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Expected O, but got Unknown
			if (IsActive)
			{
				if (_hudStyle == null)
				{
					GUIStyle val = new GUIStyle(GUI.skin.label)
					{
						fontSize = 18,
						fontStyle = (FontStyle)1,
						alignment = (TextAnchor)4
					};
					val.normal.textColor = new Color(1f, 0.85f, 0.2f);
					_hudStyle = val;
				}
				if (_hudBgStyle == null)
				{
					_hudBgStyle = new GUIStyle(GUI.skin.box)
					{
						alignment = (TextAnchor)4
					};
				}
				string text = $"TIMEWARP: {CurrentSpeed}x";
				float num = 200f;
				float num2 = 30f;
				Rect val2 = default(Rect);
				((Rect)(ref val2))..ctor(((float)Screen.width - num) / 2f, 10f, num, num2);
				GUI.Box(val2, "", _hudBgStyle);
				GUI.Label(val2, text, _hudStyle);
			}
		}

		public override void Execute(List<string> args)
		{
			switch (args.Count)
			{
			case 0:
				MelonLogger.Msg("No duration specified. Defaulting to 10 seconds.");
				((ConsoleCommand)this).Execute(_warpDefault);
				break;
			case 1:
			{
				float result2;
				if (args.AsEnumerable<string>().ElementAt(0) == "stop")
				{
					MelonCoroutines.Start(ResetTimeWarp(0f));
				}
				else if (float.TryParse(args.AsEnumerable<string>().ElementAt(0), out result2))
				{
					if (result2 <= 0f)
					{
						MelonLogger.Warning("Time warp duration must be a positive number.");
						break;
					}
					_timeScaleCommand.Execute(_timeScaleDefault);
					MelonLogger.Msg($"Time warp started for {result2} seconds. Timescale set to 5.");
					MelonCoroutines.Start(ResetTimeWarp(result2));
				}
				else
				{
					MelonLogger.Warning("Invalid argument. Use 'timewarp stop' to stop or 'timewarp <seconds>' to start.");
				}
				break;
			}
			case 2:
			{
				if (!float.TryParse(args.AsEnumerable<string>().ElementAt(0), out var result))
				{
					MelonLogger.Warning("Invalid time value. Please provide a valid number of seconds.");
				}
				if (result <= 0f)
				{
					MelonLogger.Warning("Time warp duration must be a positive number.");
					break;
				}
				string text = args.AsEnumerable<string>().ElementAt(1);
				List<string> val = new string[1] { text }.ToIl2CppList();
				_timeScaleCommand.Execute(val);
				MelonLogger.Msg($"Time warp started for {result} seconds. Time scale set to {text}.");
				MelonCoroutines.Start(ResetTimeWarp(result));
				break;
			}
			default:
				MelonLogger.Warning("Usage: timewarp [seconds] | timewarp stop");
				break;
			}
		}

		private IEnumerator ResetTimeWarp(float seconds)
		{
			yield return (object)new WaitForSecondsRealtime(seconds);
			_timeScaleCommand.Execute(_warpStop);
			MelonLogger.Msg("Time warp " + ((seconds > 0f) ? "ended" : "stopped") + ". Time scale reset to 1.");
		}
	}
}

ScheduleToolbox-Mono.dll

Decompiled 2 days ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using FishNet;
using FishNet.Connection;
using HarmonyLib;
using MelonLoader;
using MelonLoader.Preferences;
using MelonLoader.Utils;
using Microsoft.CodeAnalysis;
using Newtonsoft.Json;
using ScheduleOne;
using ScheduleOne.Cartel;
using ScheduleOne.Core.Items.Framework;
using ScheduleOne.DevUtilities;
using ScheduleOne.Economy;
using ScheduleOne.ItemFramework;
using ScheduleOne.Map;
using ScheduleOne.NPCs;
using ScheduleOne.Persistence;
using ScheduleOne.PlayerScripts;
using ScheduleOne.Product;
using ScheduleOne.Storage;
using ScheduleOne.UI;
using ScheduleOne.UI.MainMenu;
using ScheduleToolbox;
using ScheduleToolbox.Commands;
using ScheduleToolbox.Helpers;
using ScheduleToolbox.Models;
using UnityEngine;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: MelonInfo(typeof(global::ScheduleToolbox.ScheduleToolbox), "ScheduleToolbox", "2.1.5", "k073l", null)]
[assembly: MelonColor(1, 255, 0, 0)]
[assembly: MelonGame("TVGS", "Schedule I")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("ScheduleToolbox-Mono")]
[assembly: AssemblyConfiguration("Release Mono")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+a041d2978dcd999861ace7bb09ce0fec2ce6d765")]
[assembly: AssemblyProduct("ScheduleToolbox-Mono")]
[assembly: AssemblyTitle("ScheduleToolbox-Mono")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

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

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

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace ScheduleToolbox
{
	public static class BuildInfo
	{
		public const string Name = "ScheduleToolbox";

		public const string Description = "Testing tools for Schedule I";

		public const string Author = "k073l";

		public const string Version = "2.1.5";
	}
	public class ScheduleToolbox : MelonMod
	{
		private static Instance Logger;

		private bool _addedCommands = false;

		public override void OnInitializeMelon()
		{
			Logger = ((MelonBase)this).LoggerInstance;
			Logger.Msg("ScheduleToolbox initialized");
			ToolboxData data = PersistenceManager.Data;
			ConsoleManager.Initialize();
		}

		public override void OnSceneWasLoaded(int buildIndex, string sceneName)
		{
			if (sceneName == "Menu")
			{
				HoldToLoadManager.Instance.Reset();
				ConsoleManager.Instance.StopTimewarp();
			}
			if (sceneName == "Main")
			{
				ConsoleManager.Instance.SetConsoleUI(Object.FindObjectOfType<ConsoleUI>());
				Logger.Msg("Main scene loaded, starting console commands coroutine");
				MelonCoroutines.Start(Utils.WaitForSingleton<Console>(ConsoleCoro()));
			}
		}

		public override void OnUpdate()
		{
			ConsoleManager.Instance.Update();
			HoldToLoadManager.Instance.Update();
		}

		private IEnumerator ConsoleCoro()
		{
			if (_addedCommands)
			{
				Logger.Msg("Console commands already added, skipping.");
				yield break;
			}
			yield return (object)new WaitForSeconds(1f);
			List<ConsoleCommand> commands = new List<ConsoleCommand>
			{
				(ConsoleCommand)(object)new FlyCommand(),
				(ConsoleCommand)(object)new TeleportCommand(),
				(ConsoleCommand)(object)new SavePosCommand(),
				(ConsoleCommand)(object)new PosCommand(),
				(ConsoleCommand)(object)new TimeWarpCommand(),
				(ConsoleCommand)(object)new ForceCartelDealCommand(),
				(ConsoleCommand)(object)new SetCartelInfluenceCommand(),
				(ConsoleCommand)(object)new ForceDealCommand(),
				(ConsoleCommand)(object)new CopyCommand(),
				(ConsoleCommand)(object)new PasteCommand(),
				(ConsoleCommand)(object)new ListItemsCommand(),
				(ConsoleCommand)(object)new ListNPCsCommand()
			};
			foreach (ConsoleCommand command in commands)
			{
				string commandWord = command.CommandWord;
				Console.commands.Add(commandWord, command);
				Console.Commands.Add(command);
				Logger.Msg("Registered command: " + commandWord);
			}
			_addedCommands = true;
		}

		public override void OnGUI()
		{
			PosCommand.OnGUI();
			SavePosCommand.OnGUI();
			TimeWarpCommand.OnGUI();
		}
	}
}
namespace ScheduleToolbox.Patches
{
	[HarmonyPatch(typeof(ConsoleUI), "UpdateCommandHistory")]
	public class DisableNativeCommandHistory
	{
		public static bool Prefix(ConsoleUI __instance)
		{
			return false;
		}
	}
	[HarmonyPatch(typeof(Disclaimer), "Awake")]
	public class DisclaimerSkip
	{
		public static bool Prefix(MonoBehaviour __instance)
		{
			((Component)__instance).gameObject.SetActive(false);
			return false;
		}
	}
	[HarmonyPatch(typeof(PlayerCamera), "Exit")]
	public class FlyEscFunctionality
	{
		private static bool Prefix(PlayerCamera __instance, ExitAction action)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Invalid comparison between Unknown and I4
			if (action.Used)
			{
				return true;
			}
			if (!__instance.FreeCamEnabled || (int)action.Type > 0)
			{
				return true;
			}
			action.Used = true;
			FlyCommand.TeleportToCameraPos();
			__instance.SetFreeCam(false, true);
			return false;
		}
	}
	[HarmonyPatch(typeof(Console))]
	public class LogCommands
	{
		[HarmonyPatch("SubmitCommand", new Type[] { typeof(List<string>) })]
		[HarmonyPrefix]
		public static bool LogConsoleCommands(Console __instance, List<string> args)
		{
			if (args.Count == 0 || (!InstanceFinder.IsHost && !Debug.isDebugBuild && !Application.isEditor))
			{
				return true;
			}
			for (int i = 0; i < args.Count; i++)
			{
				args[i] = args[i].ToLower();
			}
			string text = args.AsEnumerable().ElementAt(0);
			if (!Console.commands.TryGetValue(text, out var value))
			{
				Console.LogWarning((object)("Command " + text + " not found."), (Object)null);
				return false;
			}
			args.RemoveAt(0);
			value.Execute(args);
			string text2 = "";
			for (int j = 0; j < args.Count; j++)
			{
				text2 += args.AsEnumerable().ElementAt(j);
				if (j < args.Count - 1)
				{
					text2 += " ";
				}
			}
			MelonLogger.Msg("Executed command: " + text + " " + text2);
			string path = Path.Combine(MelonEnvironment.UserDataDirectory, "ScheduleToolbox", "history.log");
			Directory.CreateDirectory(Path.GetDirectoryName(path));
			File.AppendAllText(path, text + " " + text2 + "\n");
			List<string> list = File.ReadAllLines(path).ToList();
			if (ConsoleManager.MaxBufferLines.Value > 0 && list.Count > ConsoleManager.MaxBufferLines.Value)
			{
				list = list.Skip(list.Count - ConsoleManager.MaxBufferLines.Value).ToList();
				File.WriteAllLines(path, list);
			}
			return false;
		}
	}
	[HarmonyPatch(typeof(Bind), "Execute")]
	internal static class Console_AddBinding
	{
		public static bool Prefix(Bind __instance, List<string> args)
		{
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			if (args.Count > 1)
			{
				string text = args[0].ToLower();
				if (!Enum.TryParse<KeyCode>(text, ignoreCase: true, out KeyCode result))
				{
					Console.LogCommandError("Unrecognized keycode '" + text + "'");
				}
				string command = string.Join(" ", args.ToArray()).Substring(text.Length + 1);
				AddBinding(result, command);
			}
			else
			{
				Console.LogUnrecognizedFormat(new string[1] { ((ConsoleCommand)__instance).ExampleUsage });
			}
			return false;
		}

		private static void AddBinding(KeyCode key, string command)
		{
			//IL_0001: 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)
			command = PersistKeybindings.SaveBinding(key, command);
			PersistenceManager.SaveKeybind(key, command);
		}
	}
	[HarmonyPatch(typeof(Unbind), "Execute")]
	internal static class Console_RemoveBinding
	{
		public static bool Prefix(Unbind __instance, List<string> args)
		{
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			if (args.Count > 0)
			{
				string text = args[0].ToLower();
				if (!Enum.TryParse<KeyCode>(text, ignoreCase: true, out KeyCode result))
				{
					Console.LogCommandError("Unrecognized keycode '" + text + "'");
				}
				RemoveBinding(result);
			}
			else
			{
				Console.LogUnrecognizedFormat(new string[1] { ((ConsoleCommand)__instance).ExampleUsage });
			}
			return false;
		}

		private static void RemoveBinding(KeyCode key)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			Console.Log((object)$"Unbinding {key}", (Object)null);
			Singleton<Console>.Instance.keyBindings.Remove(key);
			PersistenceManager.RemoveKeybind(key);
		}
	}
	[HarmonyPatch(typeof(ClearBinds), "Execute")]
	internal static class Console_ClearBindings
	{
		public static bool Prefix(ClearBinds __instance, List<string> args)
		{
			Console.Log((object)"Clearing all key bindings", (Object)null);
			Singleton<Console>.Instance.keyBindings.Clear();
			PersistenceManager.Data.Keybindings.Clear();
			PersistenceManager.Save();
			return false;
		}
	}
	[HarmonyPatch(typeof(Console))]
	public class PersistKeybindings
	{
		public unsafe static string SaveBinding(KeyCode key, string command)
		{
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			command = StripOuterSingleQuotes(command);
			Console.Log((object)("Binding " + ((object)(*(KeyCode*)(&key))/*cast due to .constrained prefix*/).ToString() + " to " + command), (Object)null);
			Singleton<Console>.Instance.keyBindings[key] = command;
			return command;
		}

		[HarmonyPatch("Awake")]
		[HarmonyPostfix]
		public static void LoadBindings(Console __instance)
		{
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			foreach (KeyValuePair<string, string> keybinding in PersistenceManager.Data.Keybindings)
			{
				Melon<ScheduleToolbox>.Logger.Msg("Restoring keybind: " + keybinding.Key + " -> " + keybinding.Value);
				if (!Enum.TryParse<KeyCode>(keybinding.Key, ignoreCase: true, out KeyCode result))
				{
					Melon<ScheduleToolbox>.Logger.Warning("Unknown keycode '" + keybinding.Key + "'");
				}
				else
				{
					SaveBinding(result, keybinding.Value);
				}
			}
		}

		private static string StripOuterSingleQuotes(string s)
		{
			if (string.IsNullOrEmpty(s))
			{
				return s;
			}
			if (s.Length >= 2 && s[0] == '\'')
			{
				if (s[s.Length - 1] == '\'')
				{
					return s.Substring(1, s.Length - 1 - 1);
				}
			}
			return s;
		}
	}
	[HarmonyPatch(typeof(Settings), "GetDefaultUnitTypeForPlayer")]
	public class SettingsDefaultUnit
	{
		public static bool Prefix(ref EUnitType __result)
		{
			if (!object.Equals(CultureInfo.CurrentCulture, CultureInfo.InvariantCulture))
			{
				return true;
			}
			__result = (EUnitType)0;
			return false;
		}
	}
}
namespace ScheduleToolbox.Models
{
	[Serializable]
	public class SavedPosition
	{
		public SerializableVector3 position;

		public SerializableQuaternion rotation;
	}
	[Serializable]
	public class SavedPositionsData
	{
		public Dictionary<string, SavedPosition> Positions = new Dictionary<string, SavedPosition>();
	}
	[Serializable]
	public class SerializableQuaternion
	{
		public float x;

		public float y;

		public float z;

		public float w;

		public SerializableQuaternion()
		{
		}

		public SerializableQuaternion(Quaternion q)
		{
			//IL_0009: 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_0021: 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)
			x = q.x;
			y = q.y;
			z = q.z;
			w = q.w;
		}

		public Quaternion ToUnity()
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			return new Quaternion(x, y, z, w);
		}
	}
	[Serializable]
	public class SerializableVector3
	{
		public float x;

		public float y;

		public float z;

		public SerializableVector3()
		{
		}

		public SerializableVector3(Vector3 v)
		{
			//IL_0009: 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_0021: Unknown result type (might be due to invalid IL or missing references)
			x = v.x;
			y = v.y;
			z = v.z;
		}

		public Vector3 ToUnity()
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			return new Vector3(x, y, z);
		}
	}
	[Serializable]
	public class ToolboxData
	{
		public Dictionary<string, string> Keybindings = new Dictionary<string, string>();

		public Dictionary<string, SavedPosition> Positions = new Dictionary<string, SavedPosition>();
	}
}
namespace ScheduleToolbox.Helpers
{
	public class ConsoleManager
	{
		private static readonly Instance Logger = new Instance("ScheduleToolbox-ConsoleManager");

		private static ConsoleManager _instance;

		private ConsoleUI _consoleUI;

		private int currentBufferLine = -1;

		private List<string> autocompleteMatches = new List<string>();

		private int autocompleteIndex = -1;

		private string lastInputText = string.Empty;

		private string autocompletePrefix = string.Empty;

		private bool autocompleteActive = false;

		internal static MelonPreferences_Entry<int> MaxBufferLines;

		private MelonPreferences_Entry<KeyCode> _timewarpToggleKey;

		private MelonPreferences_Entry<KeyCode> _timewarpSpeedUpKey;

		private MelonPreferences_Entry<KeyCode> _timewarpSlowDownKey;

		private MelonPreferences_Entry<float> _timewarpDefaultSpeed;

		private MelonPreferences_Entry<float> _timewarpSpeedStep;

		private MelonPreferences_Entry<float> _timewarpMinSpeed;

		private MelonPreferences_Entry<float> _timewarpMaxSpeed;

		private float _currentTimewarpSpeed;

		public static ConsoleManager Instance => _instance ?? (_instance = new ConsoleManager());

		public bool IsConsoleOpen => (Object)(object)_consoleUI != (Object)null && (Object)(object)_consoleUI.canvas != (Object)null && ((Behaviour)_consoleUI.canvas).enabled;

		public static void Initialize()
		{
			MelonPreferences_Category val = MelonPreferences.CreateCategory("ScheduleToolbox-Settings", "Schedule Toolbox Settings");
			MaxBufferLines = val.CreateEntry<int>("MaxConsoleBufferLines", 0, "Max Console Buffer Lines", "Maximum number of lines to keep in the console history file. Set to 0 for unlimited.", false, false, (ValueValidator)null, (string)null);
			Instance._timewarpToggleKey = val.CreateEntry<KeyCode>("TimewarpToggleKey", (KeyCode)268, "Timewarp Toggle Key", "Key to toggle timewarp on/off.", false, false, (ValueValidator)null, (string)null);
			Instance._timewarpSpeedUpKey = val.CreateEntry<KeyCode>("TimewarpSpeedUpKey", (KeyCode)270, "Timewarp Speed Up Key", "Key to increase timewarp speed.", false, false, (ValueValidator)null, (string)null);
			Instance._timewarpSlowDownKey = val.CreateEntry<KeyCode>("TimewarpSlowDownKey", (KeyCode)269, "Timewarp Slow Down Key", "Key to decrease timewarp speed.", false, false, (ValueValidator)null, (string)null);
			Instance._timewarpDefaultSpeed = val.CreateEntry<float>("TimewarpDefaultSpeed", 5f, "Timewarp Default Speed", "Default timewarp speed multiplier.", false, false, (ValueValidator)(object)new ValueRange<float>(1f, 100f), (string)null);
			Instance._timewarpSpeedStep = val.CreateEntry<float>("TimewarpSpeedStep", 1f, "Timewarp Speed Step", "Amount to increase/decrease speed per key press.", false, false, (ValueValidator)(object)new ValueRange<float>(0.1f, 50f), (string)null);
			Instance._timewarpMinSpeed = val.CreateEntry<float>("TimewarpMinSpeed", 2f, "Timewarp Min Speed", "Minimum timewarp speed.", false, false, (ValueValidator)(object)new ValueRange<float>(1f, 100f), (string)null);
			Instance._timewarpMaxSpeed = val.CreateEntry<float>("TimewarpMaxSpeed", 20f, "Timewarp Max Speed", "Maximum timewarp speed.", false, false, (ValueValidator)(object)new ValueRange<float>(1f, 100f), (string)null);
			Instance._currentTimewarpSpeed = Instance._timewarpDefaultSpeed.Value;
		}

		public void SetConsoleUI(ConsoleUI ui)
		{
			_consoleUI = ui;
		}

		public void StopTimewarp()
		{
			if (TimeWarpCommand.IsActive)
			{
				TimeWarpCommand.Stop();
			}
		}

		public void Update()
		{
			UpdateConsoleInput();
			HandleTimewarpKeybinds();
		}

		private void UpdateConsoleInput()
		{
			if ((Object)(object)_consoleUI == (Object)null || (Object)(object)_consoleUI.canvas == (Object)null)
			{
				return;
			}
			if (((Behaviour)_consoleUI.canvas).enabled)
			{
				string[] array;
				try
				{
					array = File.ReadAllLines(Path.Combine(MelonEnvironment.UserDataDirectory, "ScheduleToolbox", "history.log"));
				}
				catch (Exception ex)
				{
					Exception ex2 = ex;
					Exception ex3 = ex2;
					if (!(ex3 is DirectoryNotFoundException) && !(ex3 is FileNotFoundException))
					{
						Logger.Error($"Error reading history file: {ex}");
					}
					return;
				}
				if (Input.GetKeyDown((KeyCode)273))
				{
					if (array.Length != 0)
					{
						currentBufferLine = Mathf.Clamp(currentBufferLine + 1, 0, array.Length - 1);
						_consoleUI.InputField.SetTextWithoutNotify(array[^(currentBufferLine + 1)]);
					}
				}
				else if (Input.GetKeyDown((KeyCode)274))
				{
					if (array.Length != 0)
					{
						currentBufferLine = Mathf.Clamp(currentBufferLine - 1, -1, array.Length - 1);
						_consoleUI.InputField.SetTextWithoutNotify((currentBufferLine == -1) ? "" : array[^(currentBufferLine + 1)]);
					}
				}
				else if (Input.GetKeyDown((KeyCode)9))
				{
					string text = _consoleUI.InputField.text.Trim();
					if (!autocompleteActive)
					{
						autocompletePrefix = text;
						autocompleteActive = true;
						autocompleteMatches = (from cmd in Console.commands.Keys
							where cmd.StartsWith(autocompletePrefix, StringComparison.OrdinalIgnoreCase)
							orderby cmd
							select cmd).ToList();
						autocompleteIndex = 0;
					}
					else if (autocompleteMatches.Count > 0)
					{
						autocompleteIndex = (autocompleteIndex + 1) % autocompleteMatches.Count;
					}
					if (autocompleteMatches.Count > 0)
					{
						string text2 = autocompleteMatches[autocompleteIndex];
						_consoleUI.InputField.SetTextWithoutNotify(text2);
						_consoleUI.InputField.caretPosition = text2.Length;
						lastInputText = text2;
					}
				}
				else
				{
					string a = _consoleUI.InputField.text.Trim();
					if (!string.Equals(a, lastInputText, StringComparison.OrdinalIgnoreCase))
					{
						autocompleteMatches.Clear();
						autocompleteIndex = -1;
						autocompletePrefix = string.Empty;
						autocompleteActive = false;
						lastInputText = a;
					}
				}
			}
			else
			{
				currentBufferLine = -1;
			}
		}

		private void HandleTimewarpKeybinds()
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			if (IsConsoleOpen)
			{
				return;
			}
			if (Input.GetKeyDown(_timewarpToggleKey.Value))
			{
				if (TimeWarpCommand.IsActive)
				{
					TimeWarpCommand.Stop();
				}
				else
				{
					_currentTimewarpSpeed = _timewarpDefaultSpeed.Value;
					TimeWarpCommand.Toggle(_currentTimewarpSpeed);
				}
			}
			if (Input.GetKeyDown(_timewarpSpeedUpKey.Value))
			{
				_currentTimewarpSpeed = Mathf.Clamp(_currentTimewarpSpeed + _timewarpSpeedStep.Value, _timewarpMinSpeed.Value, _timewarpMaxSpeed.Value);
				if (TimeWarpCommand.IsActive)
				{
					TimeWarpCommand.SetSpeed(_currentTimewarpSpeed);
				}
			}
			if (Input.GetKeyDown(_timewarpSlowDownKey.Value))
			{
				_currentTimewarpSpeed = Mathf.Clamp(_currentTimewarpSpeed - _timewarpSpeedStep.Value, _timewarpMinSpeed.Value, _timewarpMaxSpeed.Value);
				if (TimeWarpCommand.IsActive)
				{
					TimeWarpCommand.SetSpeed(_currentTimewarpSpeed);
				}
			}
		}
	}
	public class HoldToLoadManager
	{
		private static readonly Instance Logger = new Instance("ScheduleToolbox-HoldToLoad");

		private static HoldToLoadManager _instance;

		private readonly Dictionary<KeyCode, float> holdTimers = new Dictionary<KeyCode, float>
		{
			{
				(KeyCode)49,
				0f
			},
			{
				(KeyCode)50,
				0f
			},
			{
				(KeyCode)51,
				0f
			},
			{
				(KeyCode)52,
				0f
			},
			{
				(KeyCode)53,
				0f
			}
		};

		private bool _shouldResetTimers;

		public static HoldToLoadManager Instance => _instance ?? (_instance = new HoldToLoadManager());

		public void Reset()
		{
			_shouldResetTimers = true;
		}

		public void Update()
		{
			//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)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: 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_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_018e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: 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_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Expected I4, but got Unknown
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			if (_shouldResetTimers)
			{
				_shouldResetTimers = false;
				List<KeyCode> list = new List<KeyCode>(holdTimers.Keys);
				foreach (KeyCode item in list)
				{
					holdTimers[item] = 0f;
				}
			}
			Scene activeScene = SceneManager.GetActiveScene();
			if (((Scene)(ref activeScene)).name != "Menu")
			{
				return;
			}
			List<KeyCode> list2 = new List<KeyCode>(holdTimers.Keys);
			foreach (KeyCode item2 in list2)
			{
				if (Input.GetKey(item2))
				{
					holdTimers[item2] += Time.deltaTime;
					if (holdTimers[item2] >= 0.5f)
					{
						int num = item2 - 48;
						Logger.Msg($"Trying to load save in slot: {num}");
						holdTimers[item2] = -999f;
						if (num <= LoadManager.SaveGames.Length)
						{
							Singleton<LoadManager>.Instance.StartGame(LoadManager.SaveGames[num - 1], false, true);
						}
						else
						{
							Logger.Warning($"Save slot {num} doesn't exist.");
						}
					}
				}
				else if (holdTimers[item2] >= 0f)
				{
					holdTimers[item2] = 0f;
				}
			}
		}
	}
	public static class MelonLoggerExtensions
	{
		public static void Debug(this Instance logger, string message, bool stacktrace = true)
		{
		}

		private static string GetLoggerName(Instance logger)
		{
			return typeof(Instance).GetField("Name", BindingFlags.Instance | BindingFlags.NonPublic)?.GetValue(logger) as string;
		}

		private static void InvokeNativeMsg(Color namesectionColor, Color textColor, string nameSection, string message)
		{
			typeof(MelonLogger).GetMethod("NativeMsg", BindingFlags.Static | BindingFlags.NonPublic)?.Invoke(null, new object[5]
			{
				namesectionColor,
				textColor,
				nameSection,
				message ?? "null",
				false
			});
		}

		private static string GetCallerInfo()
		{
			StackTrace stackTrace = new StackTrace();
			for (int i = 2; i < stackTrace.FrameCount; i++)
			{
				StackFrame frame = stackTrace.GetFrame(i);
				MethodBase method = frame.GetMethod();
				if (!(method?.DeclaringType == null))
				{
					return method.DeclaringType.FullName + "." + method.Name;
				}
			}
			return "unknown";
		}
	}
	public static class PersistenceManager
	{
		private static readonly string SaveFilePath;

		private static readonly Instance Logger;

		public static ToolboxData Data { get; private set; }

		static PersistenceManager()
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Expected O, but got Unknown
			SaveFilePath = Path.Combine(MelonEnvironment.UserDataDirectory, "ScheduleToolbox", "ScheduleToolbox.json");
			Logger = new Instance("ScheduleToolbox-PositionManager");
			Load();
		}

		public static void SavePosition(string name, Vector3 position, Quaternion rotation)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			Data.Positions[name] = new SavedPosition
			{
				position = new SerializableVector3(position),
				rotation = new SerializableQuaternion(rotation)
			};
			Save();
		}

		public static bool TryGetPosition(string name, out Vector3 position, out Quaternion rotation)
		{
			//IL_003f: 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_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			if (Data.Positions.TryGetValue(name, out var value))
			{
				position = value.position.ToUnity();
				rotation = value.rotation.ToUnity();
				return true;
			}
			position = default(Vector3);
			rotation = default(Quaternion);
			return false;
		}

		public unsafe static void SaveKeybind(KeyCode key, string command)
		{
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			if (Data.Keybindings.TryGetValue(((object)(*(KeyCode*)(&key))/*cast due to .constrained prefix*/).ToString(), out var value) && value != command)
			{
				Logger.Msg($"Overwriting keybind for {key}: '{value}' -> '{command}'");
			}
			Data.Keybindings[((object)(*(KeyCode*)(&key))/*cast due to .constrained prefix*/).ToString()] = command;
			Save();
		}

		public unsafe static void RemoveKeybind(KeyCode key)
		{
			Data.Keybindings.Remove(((object)(*(KeyCode*)(&key))/*cast due to .constrained prefix*/).ToString());
			Save();
		}

		public static void Save()
		{
			try
			{
				string contents = JsonConvert.SerializeObject((object)Data, (Formatting)1);
				Directory.CreateDirectory(Path.GetDirectoryName(SaveFilePath));
				File.WriteAllText(SaveFilePath, contents);
				Logger.Debug($"Saved {Data.Positions.Count} positions to: {SaveFilePath}");
			}
			catch (Exception arg)
			{
				Logger.Error($"Save failed: {arg}");
			}
		}

		public static void Load()
		{
			try
			{
				if (File.Exists(SaveFilePath))
				{
					string text = File.ReadAllText(SaveFilePath);
					Data = JsonConvert.DeserializeObject<ToolboxData>(text) ?? new ToolboxData();
					Logger.Debug($"Loaded {Data.Positions.Count} positions.");
				}
				else
				{
					Logger.Debug("Save file not found. Starting fresh.");
					Data = new ToolboxData();
				}
			}
			catch (Exception arg)
			{
				Logger.Error($"Load failed: {arg}");
				Data = new ToolboxData();
			}
		}
	}
	public static class Il2CppListExtensions
	{
		public static IEnumerable<T> AsEnumerable<T>(this List<T> list)
		{
			return list ?? new List<T>();
		}
	}
	public static class Utils
	{
		private static readonly Instance Logger = new Instance("ScheduleToolbox-Utils");

		public static T FindObjectByName<T>(string objectName) where T : Object
		{
			try
			{
				T[] array = Resources.FindObjectsOfTypeAll<T>();
				foreach (T val in array)
				{
					if (!(((Object)val).name != objectName))
					{
						Logger.Debug("Found " + typeof(T).Name + " '" + objectName + "' directly in loaded objects");
						return val;
					}
				}
				return default(T);
			}
			catch (Exception ex)
			{
				Logger.Error("Error finding " + typeof(T).Name + " '" + objectName + "': " + ex.Message);
				return default(T);
			}
		}

		public static List<T> GetAllComponentsInChildrenRecursive<T>(GameObject obj) where T : Component
		{
			List<T> list = new List<T>();
			if ((Object)(object)obj == (Object)null)
			{
				return list;
			}
			T[] components = obj.GetComponents<T>();
			if (components.Length != 0)
			{
				list.AddRange(components);
			}
			for (int i = 0; i < obj.transform.childCount; i++)
			{
				Transform child = obj.transform.GetChild(i);
				list.AddRange(GetAllComponentsInChildrenRecursive<T>(((Component)child).gameObject));
			}
			return list;
		}

		public static bool Is<T>(object obj, out T result) where T : class
		{
			if (obj is T val)
			{
				result = val;
				return true;
			}
			result = null;
			return false;
		}

		public static List<StorableItemDefinition> GetAllStorableItemDefinitions()
		{
			List<ItemRegister> list = Singleton<Registry>.Instance.ItemRegistry.ToList();
			List<StorableItemDefinition> list2 = new List<StorableItemDefinition>();
			foreach (ItemRegister item in list)
			{
				if (Is<StorableItemDefinition>(item.Definition, out var result))
				{
					list2.Add(result);
				}
				else
				{
					Logger.Warning("Definition " + ((object)item.Definition)?.GetType().FullName + " is not a StorableItemDefinition");
				}
			}
			return list2.ToList();
		}

		public static IEnumerator WaitForPlayer(IEnumerator routine)
		{
			while ((Object)(object)Player.Local == (Object)null || (Object)(object)((Component)Player.Local).gameObject == (Object)null)
			{
				yield return null;
			}
			MelonCoroutines.Start(routine);
		}

		public static IEnumerator WaitForNetwork(IEnumerator routine)
		{
			while (!InstanceFinder.IsServer && !InstanceFinder.IsClient)
			{
				yield return null;
			}
			MelonCoroutines.Start(routine);
		}

		public static IEnumerator WaitForNotNull(object? obj, float timeout = float.NaN, Action onTimeout = null, Action onFinish = null)
		{
			float startTime = Time.time;
			while (obj == null)
			{
				if (!float.IsNaN(timeout) && Time.time - startTime > timeout)
				{
					onTimeout?.Invoke();
					yield break;
				}
				yield return null;
			}
			onFinish?.Invoke();
		}

		public static IEnumerator WaitForNetworkSingleton<T>(IEnumerator coroutine) where T : NetworkSingleton<T>
		{
			while (!NetworkSingleton<T>.InstanceExists)
			{
				yield return null;
			}
			yield return coroutine;
		}

		public static IEnumerator WaitForSingleton<T>(IEnumerator coroutine) where T : Singleton<T>
		{
			while (!Singleton<T>.InstanceExists)
			{
				yield return null;
			}
			yield return coroutine;
		}
	}
}
namespace ScheduleToolbox.Commands
{
	[RegisterTypeInIl2Cpp]
	public class CopyCommand : ConsoleCommand
	{
		public override string CommandWord => "copyhand";

		public override string CommandDescription => "Copies the item held in hand";

		public override string ExampleUsage => "copyhand";

		internal static ItemInstance EquippedItem { get; set; }

		public override void Execute(List<string> args)
		{
			if (!PlayerSingleton<PlayerInventory>.Instance.isAnythingEquipped)
			{
				Melon<ScheduleToolbox>.Logger.Warning("Copy command executed while nothing is held in hand!");
				return;
			}
			ItemInstance equippedItem = PlayerSingleton<PlayerInventory>.Instance.EquippedItem;
			QualityItemInstance result2;
			WaterContainerInstance result3;
			CashInstance result4;
			IntegerItemInstance result5;
			StorableItemInstance result6;
			if (Utils.Is<ProductItemInstance>(equippedItem, out var result))
			{
				EquippedItem = ((ItemInstance)result).GetCopy(-1);
				Melon<ScheduleToolbox>.Logger.Msg("Copied ProductItem " + ((BaseItemInstance)result).ID);
			}
			else if (Utils.Is<QualityItemInstance>(equippedItem, out result2))
			{
				EquippedItem = ((ItemInstance)result2).GetCopy(-1);
				Melon<ScheduleToolbox>.Logger.Msg("Copied QualityItem " + ((BaseItemInstance)result2).ID);
			}
			else if (Utils.Is<WaterContainerInstance>(equippedItem, out result3))
			{
				EquippedItem = ((ItemInstance)result3).GetCopy(-1);
				Melon<ScheduleToolbox>.Logger.Msg("Copied WaterContainer " + ((BaseItemInstance)result3).ID);
			}
			else if (Utils.Is<CashInstance>(equippedItem, out result4))
			{
				EquippedItem = ((ItemInstance)result4).GetCopy(-1);
				Melon<ScheduleToolbox>.Logger.Msg("Copied CashInstance " + ((BaseItemInstance)result4).ID);
			}
			else if (Utils.Is<IntegerItemInstance>(equippedItem, out result5))
			{
				EquippedItem = ((ItemInstance)result5).GetCopy(-1);
				Melon<ScheduleToolbox>.Logger.Msg("Copied IntegerItem " + ((BaseItemInstance)result5).ID);
			}
			else if (Utils.Is<StorableItemInstance>(equippedItem, out result6))
			{
				EquippedItem = ((ItemInstance)result6).GetCopy(-1);
				Melon<ScheduleToolbox>.Logger.Msg("Copied StorageItem " + ((BaseItemInstance)result6).ID);
			}
			else
			{
				EquippedItem = equippedItem.GetCopy(-1);
			}
		}
	}
	[RegisterTypeInIl2Cpp]
	public class FlyCommand : ConsoleCommand
	{
		public override string CommandWord => "fly";

		public override string CommandDescription => "Toggles fly mode (enhanced freecam)";

		public override string ExampleUsage => "fly";

		public override void Execute(List<string> args)
		{
			if (PlayerSingleton<PlayerCamera>.Instance.FreeCamEnabled)
			{
				TeleportToCameraPos();
				PlayerSingleton<PlayerCamera>.Instance.SetFreeCam(false, true);
			}
			else
			{
				PlayerSingleton<PlayerCamera>.Instance.SetFreeCam(true, true);
			}
		}

		public static void TeleportToCameraPos()
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: 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_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			Vector3 position = ((Component)PlayerSingleton<PlayerCamera>.Instance).transform.position;
			Quaternion rotation = ((Component)PlayerSingleton<PlayerCamera>.Instance).transform.rotation;
			PlayerSingleton<PlayerCamera>.Instance.SetFreeCam(false, true);
			PlayerSingleton<PlayerMovement>.Instance.Teleport(position, false);
			((Component)Player.Local).transform.rotation = rotation;
			((Component)Player.Local).transform.forward = Vector3.forward;
			PlayerSingleton<PlayerMovement>.Instance.SetResidualVelocity(Vector3.zero, 0f, 0f);
		}
	}
	[RegisterTypeInIl2Cpp]
	public class ForceCartelDealCommand : ConsoleCommand
	{
		public override string CommandWord => "forcecarteldeal";

		public override string CommandDescription => "Forces a cartel deal, nullifying the existent deal";

		public override string ExampleUsage => "forcecarteldeal";

		public override void Execute(List<string> args)
		{
			CartelDealManager val = Object.FindObjectOfType<CartelDealManager>();
			if ((Object)(object)val == (Object)null)
			{
				MelonLogger.Error("CartelDealManager not found in the scene.");
			}
			else
			{
				val.StartDeal();
			}
		}
	}
	[RegisterTypeInIl2Cpp]
	public class ForceDealCommand : ConsoleCommand
	{
		private static readonly Instance Logger = new Instance("ScheduleToolbox-ForceDeal");

		public override string CommandWord => "forcedeal";

		public override string CommandDescription => "Forces a customer deal to occur.";

		public override string ExampleUsage => "forcedeal kyle_cooley";

		public override void Execute(List<string> args)
		{
			if (args.Count != 1)
			{
				Logger.Warning("Usage: forcedeal <customer_name>");
				return;
			}
			string text = args.AsEnumerable().ElementAt(0);
			Logger.Msg("Forcing deal with customer: " + text);
			NPC nPC = NPCManager.GetNPC(text);
			if ((Object)(object)nPC == (Object)null)
			{
				Logger.Error("Customer '" + text + "' not found.");
				return;
			}
			Customer component = ((Component)((Component)nPC).transform).GetComponent<Customer>();
			if ((Object)(object)component == (Object)null)
			{
				Logger.Error("Customer component not found on NPC '" + text + "'.");
				return;
			}
			component.ForceDealOffer();
			Logger.Msg("Forced deal with customer: " + text);
		}
	}
	[RegisterTypeInIl2Cpp]
	public class ListItemsCommand : ConsoleCommand
	{
		private static readonly Instance Logger = new Instance("ScheduleToolbox-ListItems");

		public override string CommandWord => "listitems";

		public override string CommandDescription => "Lists all item definitions with optional filter";

		public override string ExampleUsage => "listitems [filter]";

		public override void Execute(List<string> args)
		{
			string text = ((args.Count > 0) ? args.AsEnumerable().ElementAt(0) : null);
			List<StorableItemDefinition> allStorableItemDefinitions = Utils.GetAllStorableItemDefinitions();
			int num = 0;
			foreach (StorableItemDefinition item in allStorableItemDefinitions)
			{
				string iD = ((BaseItemDefinition)item).ID;
				string name = ((BaseItemDefinition)item).Name;
				if (text == null || (name.Contains(text, StringComparison.OrdinalIgnoreCase) && iD.Contains(text, StringComparison.OrdinalIgnoreCase)))
				{
					Logger.Msg("  [" + name + "] (" + iD + ")");
					num++;
				}
			}
			Logger.Msg(string.Format("Matched {0} item definitions{1} ({2} total)", num, (text != null) ? (" for '" + text + "'") : "", allStorableItemDefinitions.Count));
		}
	}
	[RegisterTypeInIl2Cpp]
	public class ListNPCsCommand : ConsoleCommand
	{
		private static readonly Instance Logger = new Instance("ScheduleToolbox-ListNPCs");

		public override string CommandWord => "listnpcs";

		public override string CommandDescription => "Lists all loaded NPCs with optional filter";

		public override string ExampleUsage => "listnpcs [filter]";

		public override void Execute(List<string> args)
		{
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: 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)
			string text = ((args.Count > 0) ? args.AsEnumerable().ElementAt(0) : null);
			int num = 0;
			foreach (NPC item in NPCManager.NPCRegistry)
			{
				string fullName = item.FullName;
				string iD = item.ID;
				Vector3 footPosition = item.Movement.FootPosition;
				if (text == null || (fullName.Contains(text, StringComparison.OrdinalIgnoreCase) && iD.Contains(text, StringComparison.OrdinalIgnoreCase)))
				{
					Logger.Msg($"  {fullName} ({iD}) at ({footPosition.x:F1}, {footPosition.y:F1}, {footPosition.z:F1})");
					num++;
				}
			}
			Logger.Msg(string.Format("Matched {0} NPCs{1} (total: {2})", num, (text != null) ? (" for '" + text + "'") : "", NPCManager.NPCRegistry.Count));
		}
	}
	[RegisterTypeInIl2Cpp]
	public class PasteCommand : ConsoleCommand
	{
		public override string CommandWord => "pastehand";

		public override string CommandDescription => "Gives the copied item with all its properties";

		public override string ExampleUsage => "pastehand";

		public override void Execute(List<string> args)
		{
			if (CopyCommand.EquippedItem == null)
			{
				Melon<ScheduleToolbox>.Logger.Warning("Copied item is null!");
				return;
			}
			ItemInstance copy = CopyCommand.EquippedItem.GetCopy(-1);
			if (!PlayerSingleton<PlayerInventory>.Instance.CanItemFitInInventory(copy, 1))
			{
				Melon<ScheduleToolbox>.Logger.Warning("Insufficient inventory space");
			}
			if (!PlayerSingleton<PlayerInventory>.Instance.isAnythingEquipped)
			{
				HotbarSlot equippedSlot = PlayerSingleton<PlayerInventory>.Instance.equippedSlot;
				((ItemSlot)equippedSlot).InsertItem(copy);
				Melon<ScheduleToolbox>.Logger.Msg("Pasted in " + ((BaseItemInstance)copy).ID + " into equipped slot");
			}
			else
			{
				PlayerSingleton<PlayerInventory>.Instance.AddItemToInventory(copy);
			}
		}
	}
	[RegisterTypeInIl2Cpp]
	public class PosCommand : ConsoleCommand
	{
		private static readonly Instance Logger = new Instance("ScheduleToolbox-PosCommand");

		private static string _guiMessage = "";

		private static float _guiMessageEndTime = 5f;

		public override string CommandWord => "pos";

		public override string CommandDescription => "Logs the player's current position and rotation";

		public override string ExampleUsage => "pos";

		public override void Execute(List<string> args)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: 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_002e: 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_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: 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_0082: Unknown result type (might be due to invalid IL or missing references)
			Vector3 position = ((Component)PlayerSingleton<PlayerCamera>.Instance).transform.position;
			Quaternion rotation = ((Component)PlayerSingleton<PlayerCamera>.Instance).transform.rotation;
			string text = $"Pos: ({position.x:F2}, {position.y:F2}, {position.z:F2}); Rot: ({((Quaternion)(ref rotation)).eulerAngles.x:F1}, {((Quaternion)(ref rotation)).eulerAngles.y:F1}, {((Quaternion)(ref rotation)).eulerAngles.z:F1})";
			Logger.Msg(text);
			_guiMessage = text;
			_guiMessageEndTime = Time.time + 3f;
		}

		public static void OnGUI()
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_003c: Expected O, but got Unknown
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			if (Time.time < _guiMessageEndTime)
			{
				GUIStyle val = new GUIStyle(GUI.skin.label)
				{
					fontSize = 14
				};
				val.normal.textColor = Color.white;
				GUIStyle val2 = val;
				GUI.Label(new Rect(10f, (float)(Screen.height - 30), (float)(Screen.width - 20), 25f), _guiMessage, val2);
			}
		}
	}
	[RegisterTypeInIl2Cpp]
	public class SavePosCommand : ConsoleCommand
	{
		private static readonly Instance Logger = new Instance("ScheduleToolbox-SavePosCommand");

		private static string _guiMessage = "";

		private static float _guiMessageEndTime;

		public override string CommandWord => "savepos";

		public override string CommandDescription => "Saves the player's current position and rotation to a named location.";

		public override string ExampleUsage => "savepos home";

		public override void Execute(List<string> args)
		{
			//IL_003e: 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_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_0055: 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_0073: 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_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: 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_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			if (args.Count != 1)
			{
				Logger.Warning("Usage: savepos <name>");
				return;
			}
			string text = args.AsEnumerable().ElementAt(0);
			Vector3 position = ((Component)PlayerSingleton<PlayerCamera>.Instance).transform.position;
			Quaternion rotation = ((Component)PlayerSingleton<PlayerCamera>.Instance).transform.rotation;
			PersistenceManager.SavePosition(text, position, rotation);
			Logger.Msg($"Saved position '{text}': {position.x},{position.y},{position.z} | {rotation.x},{rotation.y},{rotation.z}");
			_guiMessage = $"Saved '{text}' at {position.x}, {position.y}, {position.z}!";
			_guiMessageEndTime = Time.time + 3f;
		}

		public static void OnGUI()
		{
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			if (!string.IsNullOrEmpty(_guiMessage) && Time.time < _guiMessageEndTime)
			{
				GUI.Label(new Rect(10f, (float)(Screen.height - 60), 300f, 45f), _guiMessage);
			}
		}
	}
	[RegisterTypeInIl2Cpp]
	public class SetCartelInfluenceCommand : ConsoleCommand
	{
		public override string CommandWord => "setcartelinfluence";

		public override string CommandDescription => "Sets the cartel influence level for the region.";

		public override string ExampleUsage => "setcartelinfluence westville 1";

		public override void Execute(List<string> args)
		{
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			if (args.Count != 2)
			{
				MelonLogger.Warning("Usage: setcartelinfluence <region> <influence>");
				return;
			}
			string text = args.AsEnumerable().ElementAt(0);
			if (!Enum.TryParse<EMapRegion>(text, ignoreCase: true, out EMapRegion result))
			{
				MelonLogger.Warning("Invalid region name '" + text + "'. Valid regions are: " + string.Join(", ", Enum.GetNames(typeof(EMapRegion))));
				return;
			}
			if (!float.TryParse(args.AsEnumerable().ElementAt(1), out var result2))
			{
				MelonLogger.Warning("Invalid influence value. Please provide a valid number.");
				return;
			}
			CartelInfluence val = Object.FindObjectOfType<CartelInfluence>();
			if ((Object)(object)val == (Object)null)
			{
				MelonLogger.Error("CartelInfluence not found in the scene.");
				return;
			}
			val.SetInfluence((NetworkConnection)null, result, result2);
			MelonLogger.Msg($"Set cartel influence for {text} to {result2}.");
		}
	}
	[RegisterTypeInIl2Cpp]
	public class TeleportCommand : ConsoleCommand
	{
		private static readonly Instance Logger = new Instance("ScheduleToolbox-TeleportCommand");

		public override string CommandWord => "tp";

		public override string CommandDescription => "Teleports the player to a specified location.";

		public override string ExampleUsage => "(tp <x> [y] <z>) or (tp location)";

		public override void Execute(List<string> args)
		{
			//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0272: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			switch (args.Count)
			{
			case 1:
			{
				string text = args.AsEnumerable().ElementAt(0);
				if (text.Trim() == "players")
				{
					IEnumerable<PlayerMovement> source = Resources.FindObjectsOfTypeAll<PlayerMovement>().AsEnumerable();
					IEnumerable<PlayerMovement> enumerable = source.Where((PlayerMovement pm) => pm != null && pm.Player.IsLocalPlayer);
					if (!enumerable.Any())
					{
						break;
					}
					Vector3 cameraPosition = Player.Local.CameraPosition;
					foreach (PlayerMovement item in enumerable)
					{
						item.Teleport(cameraPosition, false);
					}
				}
				if (PersistenceManager.TryGetPosition(text, out var position, out var rotation))
				{
					PlayerSingleton<PlayerMovement>.Instance.Teleport(position, false);
					((Component)Player.Local).transform.rotation = rotation;
					((Component)Player.Local).transform.forward = Vector3.forward;
					Logger.Msg($"Teleported to '{text}' at {position}");
				}
				else
				{
					ConsoleCommand val4 = Console.commands["teleport"];
					val4.Execute(args);
				}
				break;
			}
			case 2:
			{
				float result4;
				bool flag4 = float.TryParse(args.AsEnumerable().ElementAt(0), out result4);
				float result5;
				bool flag5 = float.TryParse(args.AsEnumerable().ElementAt(1), out result5);
				if (flag4 && flag5)
				{
					Vector3 val = default(Vector3);
					((Vector3)(ref val))..ctor(result4, 1000f, result5);
					Ray val2 = default(Ray);
					((Ray)(ref val2))..ctor(val, Vector3.down);
					RaycastHit val3 = default(RaycastHit);
					if (Physics.Raycast(val2, ref val3, float.PositiveInfinity))
					{
						Vector3 point = ((RaycastHit)(ref val3)).point;
						PlayerSingleton<PlayerMovement>.Instance.Teleport(point + Vector3.up, false);
					}
					else
					{
						Logger.Error("Could not find ground below given X/Z coordinates.");
					}
				}
				else
				{
					Logger.Error("Invalid coordinates. Please provide valid numbers.");
				}
				break;
			}
			case 3:
			{
				float result;
				bool flag = float.TryParse(args.AsEnumerable().ElementAt(0), out result);
				float result2;
				bool flag2 = float.TryParse(args.AsEnumerable().ElementAt(1), out result2);
				float result3;
				bool flag3 = float.TryParse(args.AsEnumerable().ElementAt(2), out result3);
				if (flag && flag2 && flag3)
				{
					PlayerSingleton<PlayerMovement>.Instance.Teleport(new Vector3(result, result2, result3), false);
				}
				else
				{
					Logger.Error("Invalid coordinates. Please provide valid numbers.");
				}
				break;
			}
			default:
				Logger.Warning("Invalid usage. Use: tp <x> [y] <z> or tp <location>");
				break;
			}
		}
	}
	[RegisterTypeInIl2Cpp]
	public class TimeWarpCommand : ConsoleCommand
	{
		private readonly ConsoleCommand _timeScaleCommand = Console.commands["settimescale"];

		private static List<string> _timeScaleDefault = new List<string>(1) { "5" };

		private static List<string> _warpDefault = new List<string>(1) { "10" };

		private static List<string> _warpStop = new List<string>(1) { "1" };

		private static GUIStyle _hudStyle;

		private static GUIStyle _hudBgStyle;

		public override string CommandWord => "timewarp";

		public override string CommandDescription => "Temporarily speeds up time in the game world.";

		public override string ExampleUsage => "timewarp [seconds] [timescale] | timewarp stop";

		public static bool IsActive { get; private set; }

		public static float CurrentSpeed { get; private set; }

		public static void Toggle(float speed)
		{
			if (IsActive)
			{
				Stop();
				return;
			}
			SetSpeed(speed);
			IsActive = true;
			MelonLogger.Msg($"Timewarp toggled ON at {CurrentSpeed}x.");
		}

		public static void Stop()
		{
			if (IsActive)
			{
				ConsoleCommand val = Console.commands["settimescale"];
				val.Execute(new List<string> { "1" });
				IsActive = false;
				MelonLogger.Msg("Timewarp toggled OFF.");
			}
		}

		public static void SetSpeed(float speed)
		{
			CurrentSpeed = speed;
			ConsoleCommand val = Console.commands["settimescale"];
			val.Execute(new List<string> { speed.ToString("F1") });
			if (IsActive)
			{
				MelonLogger.Msg($"Timewarp speed changed to {CurrentSpeed}x.");
			}
		}

		public static void OnGUI()
		{
			//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_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Expected O, but got Unknown
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Expected O, but got Unknown
			if (IsActive)
			{
				if (_hudStyle == null)
				{
					GUIStyle val = new GUIStyle(GUI.skin.label)
					{
						fontSize = 18,
						fontStyle = (FontStyle)1,
						alignment = (TextAnchor)4
					};
					val.normal.textColor = new Color(1f, 0.85f, 0.2f);
					_hudStyle = val;
				}
				if (_hudBgStyle == null)
				{
					_hudBgStyle = new GUIStyle(GUI.skin.box)
					{
						alignment = (TextAnchor)4
					};
				}
				string text = $"TIMEWARP: {CurrentSpeed}x";
				float num = 200f;
				float num2 = 30f;
				Rect val2 = default(Rect);
				((Rect)(ref val2))..ctor(((float)Screen.width - num) / 2f, 10f, num, num2);
				GUI.Box(val2, "", _hudBgStyle);
				GUI.Label(val2, text, _hudStyle);
			}
		}

		public override void Execute(List<string> args)
		{
			switch (args.Count)
			{
			case 0:
				MelonLogger.Msg("No duration specified. Defaulting to 10 seconds.");
				((ConsoleCommand)this).Execute(_warpDefault);
				break;
			case 1:
			{
				float result2;
				if (args.AsEnumerable().ElementAt(0) == "stop")
				{
					MelonCoroutines.Start(ResetTimeWarp(0f));
				}
				else if (float.TryParse(args.AsEnumerable().ElementAt(0), out result2))
				{
					if (result2 <= 0f)
					{
						MelonLogger.Warning("Time warp duration must be a positive number.");
						break;
					}
					_timeScaleCommand.Execute(_timeScaleDefault);
					MelonLogger.Msg($"Time warp started for {result2} seconds. Timescale set to 5.");
					MelonCoroutines.Start(ResetTimeWarp(result2));
				}
				else
				{
					MelonLogger.Warning("Invalid argument. Use 'timewarp stop' to stop or 'timewarp <seconds>' to start.");
				}
				break;
			}
			case 2:
			{
				if (!float.TryParse(args.AsEnumerable().ElementAt(0), out var result))
				{
					MelonLogger.Warning("Invalid time value. Please provide a valid number of seconds.");
				}
				if (result <= 0f)
				{
					MelonLogger.Warning("Time warp duration must be a positive number.");
					break;
				}
				string text = args.AsEnumerable().ElementAt(1);
				List<string> list = new List<string> { text };
				_timeScaleCommand.Execute(list);
				MelonLogger.Msg($"Time warp started for {result} seconds. Time scale set to {text}.");
				MelonCoroutines.Start(ResetTimeWarp(result));
				break;
			}
			default:
				MelonLogger.Warning("Usage: timewarp [seconds] | timewarp stop");
				break;
			}
		}

		private IEnumerator ResetTimeWarp(float seconds)
		{
			yield return (object)new WaitForSecondsRealtime(seconds);
			_timeScaleCommand.Execute(_warpStop);
			MelonLogger.Msg("Time warp " + ((seconds > 0f) ? "ended" : "stopped") + ". Time scale reset to 1.");
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}