

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.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.4", "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+99e3f7daed23429bdc9aa42885098e1725e32220")]
[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]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.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]
[Microsoft.CodeAnalysis.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]
[Microsoft.CodeAnalysis.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.4";
}
public class ScheduleToolbox : MelonMod
{
[CompilerGenerated]
private sealed class <ConsoleCoro>d__25 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public ScheduleToolbox <>4__this;
private List<ConsoleCommand> <commands>5__1;
private List<ConsoleCommand>.Enumerator <>s__2;
private ConsoleCommand <command>5__3;
private string <commandWord>5__4;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <ConsoleCoro>d__25(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<commands>5__1 = null;
<>s__2 = default(List<ConsoleCommand>.Enumerator);
<command>5__3 = null;
<commandWord>5__4 = null;
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_0052: Expected O, but got Unknown
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
if (<>4__this._addedCommands)
{
Logger.Msg("Console commands already added, skipping.");
return false;
}
<>2__current = (object)new WaitForSeconds(1f);
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
<commands>5__1 = 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()
};
<>s__2 = <commands>5__1.GetEnumerator();
try
{
while (<>s__2.MoveNext())
{
<command>5__3 = <>s__2.Current;
<commandWord>5__4 = <command>5__3.CommandWord;
Console.commands.Add(<commandWord>5__4, <command>5__3);
Console.Commands.Add(<command>5__3);
Logger.Msg("Registered command: " + <commandWord>5__4);
<commandWord>5__4 = null;
<command>5__3 = null;
}
}
finally
{
((IDisposable)<>s__2).Dispose();
}
<>s__2 = default(List<ConsoleCommand>.Enumerator);
<>4__this._addedCommands = true;
return false;
}
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
private static Instance Logger;
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 = false;
private bool _addedCommands = false;
private ConsoleUI _consoleUI;
private int currentBufferLine = -1;
private static List<string> autocompleteMatches = new List<string>();
private static int autocompleteIndex = -1;
private static string lastInputText = string.Empty;
private static string autocompletePrefix = string.Empty;
private static bool autocompleteActive = false;
private static MelonPreferences_Category _settingsCategory;
internal static MelonPreferences_Entry<int> MaxBufferLines;
private static MelonPreferences_Entry<KeyCode> _timewarpToggleKey;
private static MelonPreferences_Entry<KeyCode> _timewarpSpeedUpKey;
private static MelonPreferences_Entry<KeyCode> _timewarpSlowDownKey;
private static MelonPreferences_Entry<float> _timewarpDefaultSpeed;
private static MelonPreferences_Entry<float> _timewarpSpeedStep;
private static MelonPreferences_Entry<float> _timewarpMinSpeed;
private static MelonPreferences_Entry<float> _timewarpMaxSpeed;
private float _currentTimewarpSpeed;
public override void OnInitializeMelon()
{
Logger = ((MelonBase)this).LoggerInstance;
Logger.Msg("ScheduleToolbox initialized");
ToolboxData data = PersistenceManager.Data;
_settingsCategory = MelonPreferences.CreateCategory("ScheduleToolbox-Settings", "Schedule Toolbox Settings");
MaxBufferLines = _settingsCategory.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);
_timewarpToggleKey = _settingsCategory.CreateEntry<KeyCode>("TimewarpToggleKey", (KeyCode)268, "Timewarp Toggle Key", "Key to toggle timewarp on/off.", false, false, (ValueValidator)null, (string)null);
_timewarpSpeedUpKey = _settingsCategory.CreateEntry<KeyCode>("TimewarpSpeedUpKey", (KeyCode)270, "Timewarp Speed Up Key", "Key to increase timewarp speed.", false, false, (ValueValidator)null, (string)null);
_timewarpSlowDownKey = _settingsCategory.CreateEntry<KeyCode>("TimewarpSlowDownKey", (KeyCode)269, "Timewarp Slow Down Key", "Key to decrease timewarp speed.", false, false, (ValueValidator)null, (string)null);
_timewarpDefaultSpeed = _settingsCategory.CreateEntry<float>("TimewarpDefaultSpeed", 5f, "Timewarp Default Speed", "Default timewarp speed multiplier.", false, false, (ValueValidator)(object)new ValueRange<float>(1f, 100f), (string)null);
_timewarpSpeedStep = _settingsCategory.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);
_timewarpMinSpeed = _settingsCategory.CreateEntry<float>("TimewarpMinSpeed", 2f, "Timewarp Min Speed", "Minimum timewarp speed.", false, false, (ValueValidator)(object)new ValueRange<float>(1f, 100f), (string)null);
_timewarpMaxSpeed = _settingsCategory.CreateEntry<float>("TimewarpMaxSpeed", 20f, "Timewarp Max Speed", "Maximum timewarp speed.", false, false, (ValueValidator)(object)new ValueRange<float>(1f, 100f), (string)null);
_currentTimewarpSpeed = _timewarpDefaultSpeed.Value;
}
public override void OnSceneWasLoaded(int buildIndex, string sceneName)
{
if (sceneName == "Menu")
{
_shouldResetTimers = true;
TimeWarpCommand.Stop();
}
if (sceneName == "Main")
{
if ((Object)(object)_consoleUI == (Object)null)
{
_consoleUI = Object.FindObjectOfType<ConsoleUI>();
}
Logger.Msg("Main scene loaded, starting console commands coroutine");
MelonCoroutines.Start(Utils.WaitForSingleton<Console>(ConsoleCoro()));
}
}
public override void OnUpdate()
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
//IL_01da: Unknown result type (might be due to invalid IL or missing references)
//IL_006b: Unknown result type (might be due to invalid IL or missing references)
//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
//IL_0218: Unknown result type (might be due to invalid IL or missing references)
//IL_021d: Unknown result type (might be due to invalid IL or missing references)
//IL_0220: Unknown result type (might be due to invalid IL or missing references)
//IL_0111: Unknown result type (might be due to invalid IL or missing references)
//IL_033f: Unknown result type (might be due to invalid IL or missing references)
//IL_0239: Unknown result type (might be due to invalid IL or missing references)
//IL_023b: Unknown result type (might be due to invalid IL or missing references)
//IL_023f: Unknown result type (might be due to invalid IL or missing references)
//IL_0243: Unknown result type (might be due to invalid IL or missing references)
//IL_025c: Unknown result type (might be due to invalid IL or missing references)
//IL_035d: Unknown result type (might be due to invalid IL or missing references)
//IL_0275: Unknown result type (might be due to invalid IL or missing references)
//IL_0279: Unknown result type (might be due to invalid IL or missing references)
//IL_027c: Expected I4, but got Unknown
//IL_02b5: Unknown result type (might be due to invalid IL or missing references)
Scene activeScene = SceneManager.GetActiveScene();
if (((Scene)(ref activeScene)).name == "Main")
{
ConsoleImprovements();
if ((Object)(object)_consoleUI == (Object)null || (Object)(object)_consoleUI.canvas == (Object)null || !((Behaviour)_consoleUI.canvas).enabled)
{
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);
}
}
}
}
if (_shouldResetTimers)
{
_shouldResetTimers = false;
List<KeyCode> list = new List<KeyCode>(holdTimers.Keys);
foreach (KeyCode item in list)
{
holdTimers[item] = 0f;
}
}
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;
}
}
}
private void ConsoleImprovements()
{
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;
}
}
[IteratorStateMachine(typeof(<ConsoleCoro>d__25))]
private IEnumerator ConsoleCoro()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <ConsoleCoro>d__25(0)
{
<>4__this = this
};
}
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.exitType != 1)
{
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 (ScheduleToolbox.MaxBufferLines.Value > 0 && list.Count > ScheduleToolbox.MaxBufferLines.Value)
{
list = list.Skip(list.Count - ScheduleToolbox.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 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)(ref key)).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 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 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)(ref key)).ToString(), out var value) && value != command)
{
Logger.Msg($"Overwriting keybind for {key}: '{value}' -> '{command}'");
}
Data.Keybindings[((object)(KeyCode)(ref key)).ToString()] = command;
Save();
}
public static void RemoveKeybind(KeyCode key)
{
Data.Keybindings.Remove(((object)(KeyCode)(ref key)).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
{
[CompilerGenerated]
private sealed class <WaitForNetwork>d__6 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public IEnumerator routine;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <WaitForNetwork>d__6(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
break;
case 1:
<>1__state = -1;
break;
}
if (!InstanceFinder.IsServer && !InstanceFinder.IsClient)
{
<>2__current = null;
<>1__state = 1;
return true;
}
MelonCoroutines.Start(routine);
return false;
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
[CompilerGenerated]
private sealed class <WaitForNetworkSingleton>d__8<T> : IEnumerator<object>, IEnumerator, IDisposable where T : notnull, NetworkSingleton<T>
{
private int <>1__state;
private object <>2__current;
public IEnumerator coroutine;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <WaitForNetworkSingleton>d__8(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
goto IL_0044;
case 1:
<>1__state = -1;
goto IL_0044;
case 2:
{
<>1__state = -1;
return false;
}
IL_0044:
if (!NetworkSingleton<T>.InstanceExists)
{
<>2__current = null;
<>1__state = 1;
return true;
}
<>2__current = coroutine;
<>1__state = 2;
return true;
}
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
[CompilerGenerated]
private sealed class <WaitForNotNull>d__7 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public object obj;
public float timeout;
public Action onTimeout;
public Action onFinish;
private float <startTime>5__1;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <WaitForNotNull>d__7(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<startTime>5__1 = Time.time;
break;
case 1:
<>1__state = -1;
break;
}
if (obj == null)
{
if (!float.IsNaN(timeout) && Time.time - <startTime>5__1 > timeout)
{
onTimeout?.Invoke();
return false;
}
<>2__current = null;
<>1__state = 1;
return true;
}
onFinish?.Invoke();
return false;
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
[CompilerGenerated]
private sealed class <WaitForPlayer>d__5 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public IEnumerator routine;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <WaitForPlayer>d__5(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
break;
case 1:
<>1__state = -1;
break;
}
if ((Object)(object)Player.Local == (Object)null || (Object)(object)((Component)Player.Local).gameObject == (Object)null)
{
<>2__current = null;
<>1__state = 1;
return true;
}
MelonCoroutines.Start(routine);
return false;
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
[CompilerGenerated]
private sealed class <WaitForSingleton>d__9<T> : IEnumerator<object>, IEnumerator, IDisposable where T : notnull, Singleton<T>
{
private int <>1__state;
private object <>2__current;
public IEnumerator coroutine;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <WaitForSingleton>d__9(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
goto IL_0044;
case 1:
<>1__state = -1;
goto IL_0044;
case 2:
{
<>1__state = -1;
return false;
}
IL_0044:
if (!Singleton<T>.InstanceExists)
{
<>2__current = null;
<>1__state = 1;
return true;
}
<>2__current = coroutine;
<>1__state = 2;
return true;
}
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
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();
}
[IteratorStateMachine(typeof(<WaitForPlayer>d__5))]
public static IEnumerator WaitForPlayer(IEnumerator routine)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <WaitForPlayer>d__5(0)
{
routine = routine
};
}
[IteratorStateMachine(typeof(<WaitForNetwork>d__6))]
public static IEnumerator WaitForNetwork(IEnumerator routine)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <WaitForNetwork>d__6(0)
{
routine = routine
};
}
[IteratorStateMachine(typeof(<WaitForNotNull>d__7))]
public static IEnumerator WaitForNotNull(object? obj, float timeout = float.NaN, Action onTimeout = null, Action onFinish = null)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <WaitForNotNull>d__7(0)
{
obj = obj,
timeout = timeout,
onTimeout = onTimeout,
onFinish = onFinish
};
}
[IteratorStateMachine(typeof(<WaitForNetworkSingleton>d__8<>))]
public static IEnumerator WaitForNetworkSingleton<T>(IEnumerator coroutine) where T : NetworkSingleton<T>
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <WaitForNetworkSingleton>d__8<T>(0)
{
coroutine = coroutine
};
}
[IteratorStateMachine(typeof(<WaitForSingleton>d__9<>))]
public static IEnumerator WaitForSingleton<T>(IEnumerator coroutine) where T : Singleton<T>
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <WaitForSingleton>d__9<T>(0)
{
coroutine = 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 " + ((ItemInstance)result).ID);
}
else if (Utils.Is<QualityItemInstance>((object)equippedItem, out result2))
{
EquippedItem = ((ItemInstance)result2).GetCopy(-1);
Melon<ScheduleToolbox>.Logger.Msg("Copied QualityItem " + ((ItemInstance)result2).ID);
}
else if (Utils.Is<WaterContainerInstance>((object)equippedItem, out result3))
{
EquippedItem = ((ItemInstance)result3).GetCopy(-1);
Melon<ScheduleToolbox>.Logger.Msg("Copied WaterContainer " + ((ItemInstance)result3).ID);
}
else if (Utils.Is<CashInstance>((object)equippedItem, out result4))
{
EquippedItem = ((ItemInstance)result4).GetCopy(-1);
Melon<ScheduleToolbox>.Logger.Msg("Copied CashInstance " + ((ItemInstance)result4).ID);
}
else if (Utils.Is<IntegerItemInstance>((object)equippedItem, out result5))
{
EquippedItem = ((ItemInstance)result5).GetCopy(-1);
Melon<ScheduleToolbox>.Logger.Msg("Copied IntegerItem " + ((ItemInstance)result5).ID);
}
else if (Utils.Is<StorableItemInstance>((object)equippedItem, out result6))
{
EquippedItem = ((ItemInstance)result6).GetCopy(-1);
Melon<ScheduleToolbox>.Logger.Msg("Copied StorageItem " + ((ItemInstance)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 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 " + 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_004a: 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_006e: Unknown result type (might be due to invalid IL or missing references)
//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
//IL_012e: Unknown result type (might be due to invalid IL or missing references)
//IL_0130: Unknown result type (might be due to invalid IL or missing references)
//IL_013a: Unknown result type (might be due to invalid IL or missing references)
//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
//IL_0151: Unknown result type (might be due to invalid IL or missing references)
//IL_0156: Unknown result type (might be due to invalid IL or missing references)
//IL_015d: Unknown result type (might be due to invalid IL or missing references)
//IL_015f: Unknown result type (might be due to invalid IL or missing references)
//IL_0164: Unknown result type (might be due to invalid IL or missing references)
switch (args.Count)
{
case 1:
{
string text = args.AsEnumerable<string>().ElementAt(0);
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
{
[CompilerGenerated]
private sealed class <ResetTimeWarp>d__27 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public float seconds;
public TimeWarpCommand <>4__this;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <ResetTimeWarp>d__27(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Expected O, but got Unknown
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<>2__current = (object)new WaitForSecondsRealtime(seconds);
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
<>4__this._timeScaleCommand.Execute(_warpStop);
MelonLogger.Msg("Time warp " + ((seconds > 0f) ? "ended" : "stopped") + ". Time scale reset to 1.");
return false;
}
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
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;
}
}
[IteratorStateMachine(typeof(<ResetTimeWarp>d__27))]
private IEnumerator ResetTimeWarp(float seconds)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <ResetTimeWarp>d__27(0)
{
<>4__this = this,
seconds = seconds
};
}
}
}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.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.4", "k073l", null)]
[assembly: MelonColor(1, 255, 0, 0)]
[assembly: MelonGame("TVGS", "Schedule I")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[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+99e3f7daed23429bdc9aa42885098e1725e32220")]
[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]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.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]
[Microsoft.CodeAnalysis.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]
[Microsoft.CodeAnalysis.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.4";
}
public class ScheduleToolbox : MelonMod
{
[CompilerGenerated]
private sealed class <ConsoleCoro>d__25 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public ScheduleToolbox <>4__this;
private List<ConsoleCommand> <commands>5__1;
private List<ConsoleCommand>.Enumerator <>s__2;
private ConsoleCommand <command>5__3;
private string <commandWord>5__4;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <ConsoleCoro>d__25(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<commands>5__1 = null;
<>s__2 = default(List<ConsoleCommand>.Enumerator);
<command>5__3 = null;
<commandWord>5__4 = null;
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_0052: Expected O, but got Unknown
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
if (<>4__this._addedCommands)
{
Logger.Msg("Console commands already added, skipping.");
return false;
}
<>2__current = (object)new WaitForSeconds(1f);
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
<commands>5__1 = 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()
};
<>s__2 = <commands>5__1.GetEnumerator();
try
{
while (<>s__2.MoveNext())
{
<command>5__3 = <>s__2.Current;
<commandWord>5__4 = <command>5__3.CommandWord;
Console.commands.Add(<commandWord>5__4, <command>5__3);
Console.Commands.Add(<command>5__3);
Logger.Msg("Registered command: " + <commandWord>5__4);
<commandWord>5__4 = null;
<command>5__3 = null;
}
}
finally
{
((IDisposable)<>s__2).Dispose();
}
<>s__2 = default(List<ConsoleCommand>.Enumerator);
<>4__this._addedCommands = true;
return false;
}
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
private static Instance Logger;
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 = false;
private bool _addedCommands = false;
private ConsoleUI _consoleUI;
private int currentBufferLine = -1;
private static List<string> autocompleteMatches = new List<string>();
private static int autocompleteIndex = -1;
private static string lastInputText = string.Empty;
private static string autocompletePrefix = string.Empty;
private static bool autocompleteActive = false;
private static MelonPreferences_Category _settingsCategory;
internal static MelonPreferences_Entry<int> MaxBufferLines;
private static MelonPreferences_Entry<KeyCode> _timewarpToggleKey;
private static MelonPreferences_Entry<KeyCode> _timewarpSpeedUpKey;
private static MelonPreferences_Entry<KeyCode> _timewarpSlowDownKey;
private static MelonPreferences_Entry<float> _timewarpDefaultSpeed;
private static MelonPreferences_Entry<float> _timewarpSpeedStep;
private static MelonPreferences_Entry<float> _timewarpMinSpeed;
private static MelonPreferences_Entry<float> _timewarpMaxSpeed;
private float _currentTimewarpSpeed;
public override void OnInitializeMelon()
{
Logger = ((MelonBase)this).LoggerInstance;
Logger.Msg("ScheduleToolbox initialized");
ToolboxData data = PersistenceManager.Data;
_settingsCategory = MelonPreferences.CreateCategory("ScheduleToolbox-Settings", "Schedule Toolbox Settings");
MaxBufferLines = _settingsCategory.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);
_timewarpToggleKey = _settingsCategory.CreateEntry<KeyCode>("TimewarpToggleKey", (KeyCode)268, "Timewarp Toggle Key", "Key to toggle timewarp on/off.", false, false, (ValueValidator)null, (string)null);
_timewarpSpeedUpKey = _settingsCategory.CreateEntry<KeyCode>("TimewarpSpeedUpKey", (KeyCode)270, "Timewarp Speed Up Key", "Key to increase timewarp speed.", false, false, (ValueValidator)null, (string)null);
_timewarpSlowDownKey = _settingsCategory.CreateEntry<KeyCode>("TimewarpSlowDownKey", (KeyCode)269, "Timewarp Slow Down Key", "Key to decrease timewarp speed.", false, false, (ValueValidator)null, (string)null);
_timewarpDefaultSpeed = _settingsCategory.CreateEntry<float>("TimewarpDefaultSpeed", 5f, "Timewarp Default Speed", "Default timewarp speed multiplier.", false, false, (ValueValidator)(object)new ValueRange<float>(1f, 100f), (string)null);
_timewarpSpeedStep = _settingsCategory.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);
_timewarpMinSpeed = _settingsCategory.CreateEntry<float>("TimewarpMinSpeed", 2f, "Timewarp Min Speed", "Minimum timewarp speed.", false, false, (ValueValidator)(object)new ValueRange<float>(1f, 100f), (string)null);
_timewarpMaxSpeed = _settingsCategory.CreateEntry<float>("TimewarpMaxSpeed", 20f, "Timewarp Max Speed", "Maximum timewarp speed.", false, false, (ValueValidator)(object)new ValueRange<float>(1f, 100f), (string)null);
_currentTimewarpSpeed = _timewarpDefaultSpeed.Value;
}
public override void OnSceneWasLoaded(int buildIndex, string sceneName)
{
if (sceneName == "Menu")
{
_shouldResetTimers = true;
TimeWarpCommand.Stop();
}
if (sceneName == "Main")
{
if ((Object)(object)_consoleUI == (Object)null)
{
_consoleUI = Object.FindObjectOfType<ConsoleUI>();
}
Logger.Msg("Main scene loaded, starting console commands coroutine");
MelonCoroutines.Start(Utils.WaitForSingleton<Console>(ConsoleCoro()));
}
}
public override void OnUpdate()
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
//IL_01da: Unknown result type (might be due to invalid IL or missing references)
//IL_006b: Unknown result type (might be due to invalid IL or missing references)
//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
//IL_0218: Unknown result type (might be due to invalid IL or missing references)
//IL_021d: Unknown result type (might be due to invalid IL or missing references)
//IL_0220: Unknown result type (might be due to invalid IL or missing references)
//IL_0111: Unknown result type (might be due to invalid IL or missing references)
//IL_02fd: Unknown result type (might be due to invalid IL or missing references)
//IL_0239: Unknown result type (might be due to invalid IL or missing references)
//IL_023b: Unknown result type (might be due to invalid IL or missing references)
//IL_023f: Unknown result type (might be due to invalid IL or missing references)
//IL_0243: Unknown result type (might be due to invalid IL or missing references)
//IL_025c: Unknown result type (might be due to invalid IL or missing references)
//IL_031b: Unknown result type (might be due to invalid IL or missing references)
//IL_0275: Unknown result type (might be due to invalid IL or missing references)
//IL_0279: Unknown result type (might be due to invalid IL or missing references)
//IL_027c: Expected I4, but got Unknown
//IL_029e: Unknown result type (might be due to invalid IL or missing references)
Scene activeScene = SceneManager.GetActiveScene();
if (((Scene)(ref activeScene)).name == "Main")
{
ConsoleImprovements();
if ((Object)(object)_consoleUI == (Object)null || (Object)(object)_consoleUI.canvas == (Object)null || !((Behaviour)_consoleUI.canvas).enabled)
{
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);
}
}
}
}
if (_shouldResetTimers)
{
_shouldResetTimers = false;
List<KeyCode> list = new List<KeyCode>(holdTimers.Keys);
foreach (KeyCode item in list)
{
holdTimers[item] = 0f;
}
}
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;
}
}
}
private void ConsoleImprovements()
{
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;
}
}
[IteratorStateMachine(typeof(<ConsoleCoro>d__25))]
private IEnumerator ConsoleCoro()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <ConsoleCoro>d__25(0)
{
<>4__this = this
};
}
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.exitType != 1)
{
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 (ScheduleToolbox.MaxBufferLines.Value > 0 && list.Count > ScheduleToolbox.MaxBufferLines.Value)
{
list = list.Skip(list.Count - ScheduleToolbox.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 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)(ref key)).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 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 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)(ref key)).ToString(), out var value) && value != command)
{
Logger.Msg($"Overwriting keybind for {key}: '{value}' -> '{command}'");
}
Data.Keybindings[((object)(KeyCode)(ref key)).ToString()] = command;
Save();
}
public static void RemoveKeybind(KeyCode key)
{
Data.Keybindings.Remove(((object)(KeyCode)(ref key)).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
{
[CompilerGenerated]
private sealed class <WaitForNetwork>d__6 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public IEnumerator routine;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <WaitForNetwork>d__6(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
break;
case 1:
<>1__state = -1;
break;
}
if (!InstanceFinder.IsServer && !InstanceFinder.IsClient)
{
<>2__current = null;
<>1__state = 1;
return true;
}
MelonCoroutines.Start(routine);
return false;
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
[CompilerGenerated]
private sealed class <WaitForNetworkSingleton>d__8<T> : IEnumerator<object>, IEnumerator, IDisposable where T : notnull, NetworkSingleton<T>
{
private int <>1__state;
private object <>2__current;
public IEnumerator coroutine;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <WaitForNetworkSingleton>d__8(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
goto IL_0044;
case 1:
<>1__state = -1;
goto IL_0044;
case 2:
{
<>1__state = -1;
return false;
}
IL_0044:
if (!NetworkSingleton<T>.InstanceExists)
{
<>2__current = null;
<>1__state = 1;
return true;
}
<>2__current = coroutine;
<>1__state = 2;
return true;
}
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
[CompilerGenerated]
private sealed class <WaitForNotNull>d__7 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public object obj;
public float timeout;
public Action onTimeout;
public Action onFinish;
private float <startTime>5__1;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <WaitForNotNull>d__7(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<startTime>5__1 = Time.time;
break;
case 1:
<>1__state = -1;
break;
}
if (obj == null)
{
if (!float.IsNaN(timeout) && Time.time - <startTime>5__1 > timeout)
{
onTimeout?.Invoke();
return false;
}
<>2__current = null;
<>1__state = 1;
return true;
}
onFinish?.Invoke();
return false;
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
[CompilerGenerated]
private sealed class <WaitForPlayer>d__5 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public IEnumerator routine;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <WaitForPlayer>d__5(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
break;
case 1:
<>1__state = -1;
break;
}
if ((Object)(object)Player.Local == (Object)null || (Object)(object)((Component)Player.Local).gameObject == (Object)null)
{
<>2__current = null;
<>1__state = 1;
return true;
}
MelonCoroutines.Start(routine);
return false;
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
[CompilerGenerated]
private sealed class <WaitForSingleton>d__9<T> : IEnumerator<object>, IEnumerator, IDisposable where T : notnull, Singleton<T>
{
private int <>1__state;
private object <>2__current;
public IEnumerator coroutine;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <WaitForSingleton>d__9(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
goto IL_0044;
case 1:
<>1__state = -1;
goto IL_0044;
case 2:
{
<>1__state = -1;
return false;
}
IL_0044:
if (!Singleton<T>.InstanceExists)
{
<>2__current = null;
<>1__state = 1;
return true;
}
<>2__current = coroutine;
<>1__state = 2;
return true;
}
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
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();
}
[IteratorStateMachine(typeof(<WaitForPlayer>d__5))]
public static IEnumerator WaitForPlayer(IEnumerator routine)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <WaitForPlayer>d__5(0)
{
routine = routine
};
}
[IteratorStateMachine(typeof(<WaitForNetwork>d__6))]
public static IEnumerator WaitForNetwork(IEnumerator routine)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <WaitForNetwork>d__6(0)
{
routine = routine
};
}
[IteratorStateMachine(typeof(<WaitForNotNull>d__7))]
public static IEnumerator WaitForNotNull(object? obj, float timeout = float.NaN, Action onTimeout = null, Action onFinish = null)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <WaitForNotNull>d__7(0)
{
obj = obj,
timeout = timeout,
onTimeout = onTimeout,
onFinish = onFinish
};
}
[IteratorStateMachine(typeof(<WaitForNetworkSingleton>d__8<>))]
public static IEnumerator WaitForNetworkSingleton<T>(IEnumerator coroutine) where T : NetworkSingleton<T>
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <WaitForNetworkSingleton>d__8<T>(0)
{
coroutine = coroutine
};
}
[IteratorStateMachine(typeof(<WaitForSingleton>d__9<>))]
public static IEnumerator WaitForSingleton<T>(IEnumerator coroutine) where T : Singleton<T>
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <WaitForSingleton>d__9<T>(0)
{
coroutine = 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 " + ((ItemInstance)result).ID);
}
else if (Utils.Is<QualityItemInstance>(equippedItem, out result2))
{
EquippedItem = ((ItemInstance)result2).GetCopy(-1);
Melon<ScheduleToolbox>.Logger.Msg("Copied QualityItem " + ((ItemInstance)result2).ID);
}
else if (Utils.Is<WaterContainerInstance>(equippedItem, out result3))
{
EquippedItem = ((ItemInstance)result3).GetCopy(-1);
Melon<ScheduleToolbox>.Logger.Msg("Copied WaterContainer " + ((ItemInstance)result3).ID);
}
else if (Utils.Is<CashInstance>(equippedItem, out result4))
{
EquippedItem = ((ItemInstance)result4).GetCopy(-1);
Melon<ScheduleToolbox>.Logger.Msg("Copied CashInstance " + ((ItemInstance)result4).ID);
}
else if (Utils.Is<IntegerItemInstance>(equippedItem, out result5))
{
EquippedItem = ((ItemInstance)result5).GetCopy(-1);
Melon<ScheduleToolbox>.Logger.Msg("Copied IntegerItem " + ((ItemInstance)result5).ID);
}
else if (Utils.Is<StorableItemInstance>(equippedItem, out result6))
{
EquippedItem = ((ItemInstance)result6).GetCopy(-1);
Melon<ScheduleToolbox>.Logger.Msg("Copied StorageItem " + ((ItemInstance)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 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 " + 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_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
//IL_006b: 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_00ff: 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_010b: 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_0122: Unknown result type (might be due to invalid IL or missing references)
//IL_0127: Unknown result type (might be due to invalid IL or missing references)
//IL_012e: Unknown result type (might be due to invalid IL or missing references)
//IL_0130: Unknown result type (might be due to invalid IL or missing references)
//IL_0135: Unknown result type (might be due to invalid IL or missing references)
switch (args.Count)
{
case 1:
{
string text = args.AsEnumerable().ElementAt(0);
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
{
[CompilerGenerated]
private sealed class <ResetTimeWarp>d__25 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public float seconds;
public TimeWarpCommand <>4__this;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <ResetTimeWarp>d__25(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Expected O, but got Unknown
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<>2__current = (object)new WaitForSecondsRealtime(seconds);
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
<>4__this._timeScaleCommand.Execute(_warpStop);
MelonLogger.Msg("Time warp " + ((seconds > 0f) ? "ended" : "stopped") + ". Time scale reset to 1.");
return false;
}
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
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;
}
}
[IteratorStateMachine(typeof(<ResetTimeWarp>d__25))]
private IEnumerator ResetTimeWarp(float seconds)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <ResetTimeWarp>d__25(0)
{
<>4__this = this,
seconds = seconds
};
}
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}