Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of DanceTools v1.1.4
DanceTools.dll
Decompiled 2 years agousing System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using GameNetcodeStuff; using HarmonyLib; using TMPro; using Unity.Netcode; using UnityEngine; using UnityEngine.Events; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("DanceTools")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("DanceTools")] [assembly: AssemblyCopyright("Copyright © 2023")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("d167b59d-d5db-4cf5-80e6-6f257c0b03cb")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyVersion("1.0.0.0")] namespace DanceTools { public class DTCmdHandler : MonoBehaviour { public static DTCmdHandler Instance; private void Awake() { Instance = this; DanceTools.mls.LogInfo((object)"Loading Commands.."); Type interfaceType = typeof(ICommand); Type[] types = Assembly.GetExecutingAssembly().GetTypes(); IEnumerable<Type> enumerable = types.Where((Type t) => interfaceType.IsAssignableFrom(t) && t.IsClass); foreach (Type item in enumerable) { ICommand command = (ICommand)Activator.CreateInstance(item); DanceTools.commands.Add(command); DanceTools.mls.LogInfo((object)("Loaded " + command.Name + " command!")); } DanceTools.mls.LogInfo((object)"Commands Loaded!"); } public void CheckCommand(string input) { string[] array = input.Split(new char[1] { ' ' }, StringSplitOptions.RemoveEmptyEntries); if (array.Length == 0) { return; } bool flag = false; for (int i = 0; i < DanceTools.commands.Count; i++) { if (DanceTools.commands[i].Name.ToLower() == array[0].ToLower()) { flag = true; array = array.Skip(1).ToArray(); TriggerCommand(DanceTools.commands[i], array); break; } } if (!flag) { DTConsole.Instance.PushTextToOutput("Invalid Command", DanceTools.consoleErrorColor); } } public void TriggerCommand(ICommand cmd, string[] args) { cmd.ExecCommand(args); } } public class DTConsole : MonoBehaviour { internal static bool isUIOpen = true; public GameObject holder; public Image inputBackground; public Image outputBackground; public TMP_InputField input; public TextMeshProUGUI output; private string oldOutput = ""; public static DTConsole Instance; internal static string[] sillyMessages = new string[5] { "Hey there!", "Console colors are customizable in the config o.o", "Haiii! >.<", "Dancing on the moon or something..", "If you need help or have feedback, join the LC Modding discord!" }; private void Awake() { Instance = this; holder = ((Component)((Component)this).transform.Find("Holder")).gameObject; input = ((Component)((Component)this).transform.Find("Holder/InputBackground/InputField")).GetComponent<TMP_InputField>(); output = ((Component)((Component)this).transform.Find("Holder/OutputBackground/Scroll/Viewport/OutputField")).GetComponent<TextMeshProUGUI>(); DanceTools.mls.LogInfo((object)("Setup holder: " + ((Object)holder).name)); DanceTools.mls.LogInfo((object)("Setup input: " + ((Object)input).name)); DanceTools.mls.LogInfo((object)("Setup output: " + ((Object)output).name)); ((UnityEvent<string>)(object)input.onSubmit).AddListener((UnityAction<string>)delegate(string text) { OnEditEnd(text); }); input.text = "help"; ((TMP_Text)output).text = ""; PushTextToOutput("\n" + sillyMessages[Random.Range(0, sillyMessages.Length)] + "\nDanceTools v1.1.4\n", "#FF00FF"); holder.SetActive(false); } public void SetCustomizationSettings() { //IL_003d: 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_005f: Unknown result type (might be due to invalid IL or missing references) inputBackground = ((Component)((Component)this).transform.Find("Holder/InputBackground")).GetComponent<Image>(); outputBackground = ((Component)((Component)this).transform.Find("Holder/OutputBackground")).GetComponent<Image>(); ((Graphic)outputBackground).color = DanceTools.consoleOutputFieldColor; ((Graphic)inputBackground).color = DanceTools.consoleInputFieldColor; PushTextToOutput($"{DanceTools.consoleInputFieldColor}"); } public void OnEditEnd(string txt) { PushTextToOutput("> " + input.text, DanceTools.consolePlayerColor); DTCmdHandler.Instance.CheckCommand(input.text); input.text = ""; input.ActivateInputField(); } public void PushTextToOutput(string text, string color = "#00FFF3") { ((TMP_Text)output).text = "<color=" + color + ">" + text + "</color>\n" + oldOutput; oldOutput = ((TMP_Text)output).text; } public void Update() { if (((KeyboardShortcut)(ref DanceTools.keyboardShortcut)).IsDown()) { ToggleUI(); } } public void ToggleUI() { isUIOpen = !isUIOpen; if (isUIOpen) { holder.gameObject.SetActive(false); if (DanceTools.isIngame) { GameNetworkManager.Instance.localPlayerController.quickMenuManager.isMenuOpen = false; Cursor.lockState = (CursorLockMode)1; Cursor.visible = false; } return; } holder.gameObject.SetActive(true); if (DanceTools.isIngame) { GameNetworkManager.Instance.localPlayerController.quickMenuManager.isMenuOpen = true; Cursor.lockState = (CursorLockMode)0; Cursor.visible = true; } if (DanceTools.consoleClearAfterOpening) { ClearConsole(); } input.text = ""; input.ActivateInputField(); } public void ClearConsole() { ((TMP_Text)output).text = ""; oldOutput = ""; } } [BepInPlugin("dancemoon.lethalcompany.dancetools", "DanceTools", "1.1.4")] public class DanceTools : BaseUnityPlugin { public struct SpawnableEnemy { public GameObject prefab; public string name; public bool isOutside; } public struct DTItem { public GameObject prefab; public string name; public int id; } public const string pluginGUID = "dancemoon.lethalcompany.dancetools"; public const string pluginName = "DanceTools"; public const string pluginVersion = "1.1.4"; private readonly Harmony harmony = new Harmony("dancemoon.lethalcompany.dancetools"); public static ManualLogSource mls; internal static DanceTools Instance; internal static RoundManager currentRound; internal static bool isIngame = false; internal static GameObject consoleRef; internal static GameObject console; internal static GameObject consoleHolder; internal static KeyboardShortcut keyboardShortcut = new KeyboardShortcut((KeyCode)96, Array.Empty<KeyCode>()); public static bool consoleDebug = false; public static List<ICommand> commands = new List<ICommand>(); public static List<SpawnableEnemy> spawnableEnemies = new List<SpawnableEnemy>(); public static List<DTItem> spawnableItems = new List<DTItem>(); public static string consolePlayerColor; public static string consoleSuccessColor; public static string consoleInfoColor; public static string consoleErrorColor; public static Color consoleOutputFieldColor = new Color(0f, 0f, 0f, 0.78f); public static Color consoleInputFieldColor = new Color(0f, 0f, 0f, 0.78f); public static bool consoleClearAfterOpening = false; internal static bool isHost; internal static bool playerGodMode = false; public void Awake() { Instance = this; mls = Logger.CreateLogSource("DanceTools"); AssetBundle val = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "DanceTools/dancetoolsconsole")); if ((Object)(object)val != (Object)null) { consoleRef = val.LoadAsset<GameObject>("assets/prefabs/dancetoolsconsole.prefab"); mls.LogInfo((object)"Loaded DanceTools AssetBundle"); } else { mls.LogWarning((object)"Failed to load DanceTools AssetBundle, trying fallback.."); val = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "dancetoolsconsole")); if (!((Object)(object)val != (Object)null)) { mls.LogFatal((object)"Failed to load DanceTools AssetBundle"); return; } consoleRef = val.LoadAsset<GameObject>("assets/prefabs/dancetoolsconsole.prefab"); mls.LogInfo((object)"Loaded DanceTools AssetBundle from fallback"); } spawnableEnemies = new List<SpawnableEnemy>(); if ((Object)(object)consoleRef != (Object)null) { console = Object.Instantiate<GameObject>(consoleRef); console.AddComponent<DTConsole>(); console.AddComponent<DTCmdHandler>(); ((Object)console).hideFlags = (HideFlags)61; Object.DontDestroyOnLoad((Object)(object)console); InitConfig(); mls.LogInfo((object)"DanceTools Loaded :^]"); harmony.PatchAll(typeof(DanceTools)); } else { mls.LogFatal((object)"No console assets present!!!!\nPlease check that you've installed everything correctly!!"); } } private void InitConfig() { //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) consolePlayerColor = ((BaseUnityPlugin)this).Config.Bind<string>("Console Customization", "Console Player Color", "#00FFF3", "Set player console color").Value; consoleSuccessColor = ((BaseUnityPlugin)this).Config.Bind<string>("Console Customization", "Console Success Color", "green", "Set success message console color").Value; consoleInfoColor = ((BaseUnityPlugin)this).Config.Bind<string>("Console Customization", "Console Info Color", "yellow", "Set info message console color").Value; consoleErrorColor = ((BaseUnityPlugin)this).Config.Bind<string>("Console Customization", "Console Error Color", "red", "Set error/fail message console color").Value; consoleOutputFieldColor = ((BaseUnityPlugin)this).Config.Bind<Color>("Console Customization", "Console Output Field Color (Hex)", new Color(0f, 0f, 0f, 0.78f), "Sets the color and opacity of the OUTPUT field background\nUse this tool to get a hex value with alpha: https://rgbacolorpicker.com/rgba-to-hex").Value; consoleInputFieldColor = ((BaseUnityPlugin)this).Config.Bind<Color>("Console Customization", "Console Input Field Color (Hex)", new Color(0f, 0f, 0f, 0.78f), "Sets the color and opacity of the INPUT field background\nUse this tool to get a hex value with alpha: https://rgbacolorpicker.com/rgba-to-hex").Value; keyboardShortcut = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Console Customization", "Console Keybind", new KeyboardShortcut((KeyCode)96, Array.Empty<KeyCode>()), "Set the shortcut key to open the console. Avaiable keys: https://docs.unity3d.com/ScriptReference/KeyCode.html").Value; consoleDebug = ((BaseUnityPlugin)this).Config.Bind<bool>("Console Customization", "Console Debug", false, "Print debug text to console").Value; consoleClearAfterOpening = ((BaseUnityPlugin)this).Config.Bind<bool>("Console Customization", "Auto-Clear console when opening", false, "Clears the console output window each time it is opened").Value; DTConsole.Instance.SetCustomizationSettings(); } [HarmonyPatch(typeof(RoundManager), "Start")] [HarmonyPrefix] private static void setHost() { isHost = ((NetworkBehaviour)RoundManager.Instance).NetworkManager.IsHost; currentRound = RoundManager.Instance; isIngame = true; } [HarmonyPatch(typeof(GameNetworkManager), "Disconnect")] [HarmonyPrefix] private static void Disconnect() { isIngame = false; } [HarmonyPatch(typeof(Terminal), "Start")] [HarmonyPostfix] private static void GetAllEnemiesAndItems(ref SelectableLevel[] ___moonsCatalogueList) { GetAllItems(); DTConsole.Instance.PushTextToOutput("Ran get enemies", "white"); SelectableLevel[] array = ___moonsCatalogueList; SpawnableEnemy item = default(SpawnableEnemy); string text = "Spawnable Enemy List Updated:\n"; foreach (SelectableLevel level in array) { int j; for (j = 0; j < level.Enemies.Count; j++) { if (spawnableEnemies.Any((SpawnableEnemy x) => x.name == level.Enemies[j].enemyType.enemyName)) { if (consoleDebug) { DTConsole.Instance.PushTextToOutput(level.PlanetName + " | " + level.Enemies[j].enemyType.enemyName + " exists", "red"); } continue; } item.name = level.Enemies[j].enemyType.enemyName; item.isOutside = level.Enemies[j].enemyType.isOutsideEnemy; item.prefab = level.Enemies[j].enemyType.enemyPrefab; spawnableEnemies.Add(item); text = text + "\n" + item.name + " | " + (item.isOutside ? "outside" : "inside"); } int i; for (i = 0; i < level.OutsideEnemies.Count; i++) { if (spawnableEnemies.Any((SpawnableEnemy x) => x.name == level.OutsideEnemies[i].enemyType.enemyName)) { if (consoleDebug) { DTConsole.Instance.PushTextToOutput(level.PlanetName + " | " + level.OutsideEnemies[i].enemyType.enemyName + " exists", "red"); } continue; } item.name = level.OutsideEnemies[i].enemyType.enemyName; item.isOutside = level.OutsideEnemies[i].enemyType.isOutsideEnemy; item.prefab = level.OutsideEnemies[i].enemyType.enemyPrefab; spawnableEnemies.Add(item); text = text + "\n" + item.name + " | " + (item.isOutside ? "outside" : "inside"); } if (consoleDebug) { DTConsole.Instance.PushTextToOutput(text, "white"); } } } private static void GetAllItems() { DTItem item = default(DTItem); string text = "Started Items:"; AllItemsList allItemsList = StartOfRound.Instance.allItemsList; text += $"{allItemsList.itemsList.Count} <- item 0"; for (int i = 0; i < allItemsList.itemsList.Count; i++) { item.name = allItemsList.itemsList[i].itemName; item.id = i; item.prefab = allItemsList.itemsList[i].spawnPrefab; spawnableItems.Add(item); text += $"\n{i} | {item.name}"; } if (consoleDebug) { DTConsole.Instance.PushTextToOutput(text, "white"); DTConsole.Instance.PushTextToOutput("Ran get all items", "white"); } } public static int CheckInt(string input) { if (int.TryParse(input, out var result)) { return result; } DTConsole.Instance.PushTextToOutput("Invalid Argument", consoleErrorColor); return -1; } public static float CheckFloat(string input) { if (float.TryParse(input, out var result)) { return result; } DTConsole.Instance.PushTextToOutput("Invalid Argument", consoleErrorColor); return -1f; } public static bool CheckHost() { if (!isHost || !isIngame) { DTConsole.Instance.PushTextToOutput("You must be host to use this command", consoleErrorColor); return false; } return true; } public static void DMNotice(string title, string msg) { HUDManager.Instance.DisplayTip(title, msg, false, false, "LC_Tip1"); } [HarmonyPatch(typeof(PlayerControllerB), "AllowPlayerDeath")] [HarmonyPrefix] public static bool AllowPlayerDeath() { return !playerGodMode; } public static void AddToCommandsList(ICommand cmd) { try { commands.Add(cmd); mls.LogInfo((object)("Loaded external command " + cmd.Name + "!")); } catch (Exception ex) { mls.LogError((object)ex.ToString()); } } } public interface ICommand { string Name { get; } string Desc { get; } void ExecCommand(string[] args); void DisplayCommandDesc(); } } namespace DanceTools.Commands { internal class ClearCommand : ICommand { public string Name => "clear"; public string Desc => "Clears the console log"; public void DisplayCommandDesc() { DTConsole.Instance.PushTextToOutput(Desc, DanceTools.consoleInfoColor); } public void ExecCommand(string[] args) { DTConsole.Instance.ClearConsole(); } } internal class CloseConsole : ICommand { public string Name => "close"; public string Desc => "Closes the console in case of bug/can't close it"; public void DisplayCommandDesc() { DTConsole.Instance.PushTextToOutput(Desc, DanceTools.consoleInfoColor); } public void ExecCommand(string[] args) { DTConsole.Instance.ToggleUI(); } } internal class EnemySpawn : ICommand { public string Name => "enemy"; public string Desc => "Spawns enemies\nUsage: enemy name amount (onme/inside/outside)\nType just the command without arguments \nto see list of enemies"; public void DisplayCommandDesc() { DTConsole.Instance.PushTextToOutput(Desc, DanceTools.consoleInfoColor); } public void ExecCommand(string[] args) { //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_026a: Unknown result type (might be due to invalid IL or missing references) //IL_026f: Unknown result type (might be due to invalid IL or missing references) //IL_02a2: Unknown result type (might be due to invalid IL or missing references) //IL_02a7: Unknown result type (might be due to invalid IL or missing references) //IL_033d: Unknown result type (might be due to invalid IL or missing references) if (!DanceTools.CheckHost()) { return; } if (args.Length < 1) { string text = "\nSpawnable Enemies (Name | Inside/Outside)\n<color=red>Warning. Enemies spawning in wrong place may break the game\nSpawn at your own risk.</color>"; if (DanceTools.currentRound.currentLevel.Enemies.Count <= 0) { DTConsole.Instance.PushTextToOutput("No enemies to spawn in this level", DanceTools.consoleErrorColor); return; } for (int i = 0; i < DanceTools.spawnableEnemies.Count; i++) { text = text + "\n" + DanceTools.spawnableEnemies[i].name + " | " + (DanceTools.spawnableEnemies[i].isOutside ? "outside" : "inside"); } DTConsole.Instance.PushTextToOutput(text ?? "", DanceTools.consoleSuccessColor); DTConsole.Instance.PushTextToOutput("Command usage: enemy name amount (onme/inside/outside)", DanceTools.consoleInfoColor); return; } try { string enemyName = args[0].ToLower(); int num = 1; string text2 = ""; string text3 = ""; Vector3 spawnPos = Vector3.zero; int num2 = -1; if (args.Length > 1) { num = DanceTools.CheckInt(args[1]); if (num == -1) { return; } if (num <= 0) { DTConsole.Instance.PushTextToOutput("Amount cannot be 0 or less than 0", DanceTools.consoleErrorColor); return; } } if (!DanceTools.spawnableEnemies.Any((DanceTools.SpawnableEnemy x) => x.name.ToLower().Contains(enemyName))) { DTConsole.Instance.PushTextToOutput("Enemy " + enemyName + " doesn't exist in current list.\nSometimes you need to load a certain map to load an enemy reference.", DanceTools.consoleErrorColor); return; } DanceTools.SpawnableEnemy spawnableEnemy = DanceTools.spawnableEnemies.Find((DanceTools.SpawnableEnemy x) => x.name.ToLower().Contains(enemyName)); text3 = (spawnableEnemy.isOutside ? "outside on a random node" : "inside a random vent"); if (args.Length > 2) { switch (args[2]) { case "onme": num2 = 0; spawnPos = ((Component)GameNetworkManager.Instance.localPlayerController).transform.position; text3 = "on top of you.."; if (GameNetworkManager.Instance.localPlayerController.isPlayerDead) { spawnPos = ((Component)GameNetworkManager.Instance.localPlayerController.spectatedPlayerScript).transform.position; text3 = "on " + GameNetworkManager.Instance.localPlayerController.spectatedPlayerScript.playerUsername; } break; case "inside": num2 = 1; text3 = "inside a random vent"; break; case "outside": num2 = 2; text3 = "outside on a random node"; break; default: num2 = -1; break; } } for (int j = 0; j < num; j++) { switch (num2) { case -1: if (spawnableEnemy.isOutside) { OutsideSpawner(spawnableEnemy); } else { InsideSpawner(spawnableEnemy); } break; case 0: SpawnEnemy(spawnableEnemy, spawnPos); break; case 1: InsideSpawner(spawnableEnemy); break; case 2: OutsideSpawner(spawnableEnemy); break; } } text2 = $"Spawned {num}x {spawnableEnemy.name} {text3}"; DTConsole.Instance.PushTextToOutput(text2, DanceTools.consoleSuccessColor); } catch (Exception ex) { DTConsole.Instance.PushTextToOutput("Can't spawn enemies when not landed.", DanceTools.consoleErrorColor); DanceTools.mls.LogError((object)("error: " + ex.Message)); } } private void InsideSpawner(DanceTools.SpawnableEnemy enemyToSpawn) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) int num = Random.Range(0, DanceTools.currentRound.allEnemyVents.Length); SpawnEnemy(enemyToSpawn, DanceTools.currentRound.allEnemyVents[num].floorNode.position); } private void OutsideSpawner(DanceTools.SpawnableEnemy enemyToSpawn) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) int num = Random.Range(0, DanceTools.currentRound.outsideAINodes.Length); SpawnEnemy(enemyToSpawn, DanceTools.currentRound.outsideAINodes[num].transform.position); } private void SpawnEnemy(DanceTools.SpawnableEnemy enemy, Vector3 spawnPos) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: 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) GameObject val = Object.Instantiate<GameObject>(enemy.prefab, spawnPos, Quaternion.identity); val.GetComponentInChildren<NetworkObject>().Spawn(true); if (DanceTools.consoleDebug) { DTConsole.Instance.PushTextToOutput($"{enemy.name} pos: {spawnPos}", "white"); } } } internal class HelpCommand : ICommand { public string Name => "help"; public string Desc => "Shows list of commands and what each command does"; public void DisplayCommandDesc() { string text = ""; for (int i = 0; i < DanceTools.commands.Count; i++) { text = text + "\n" + DanceTools.commands[i].Name; } DTConsole.Instance.PushTextToOutput("If you need help or have feedback, join the LC Modding discord!\nList Of Commands: \n" + text, DanceTools.consoleSuccessColor); } public void ExecCommand(string[] args) { if (args.Length < 1) { DisplayCommandDesc(); return; } bool flag = false; for (int i = 0; i < DanceTools.commands.Count; i++) { if (DanceTools.commands[i].Name.ToLower() == args[0].ToLower()) { flag = true; DTConsole.Instance.PushTextToOutput(DanceTools.commands[i].Desc, DanceTools.consoleSuccessColor); break; } } if (!flag) { DTConsole.Instance.PushTextToOutput("Command not found", DanceTools.consoleErrorColor); } } } internal class ItemCommand : ICommand { public string Name => "item"; public string Desc => "Spawns items on you\nUsage: item itemID/itemName amount value weight\nType just the command without arguments \nto see list of items"; public void DisplayCommandDesc() { DTConsole.Instance.PushTextToOutput(Desc, DanceTools.consoleInfoColor); } public void ExecCommand(string[] args) { //IL_0220: Unknown result type (might be due to invalid IL or missing references) //IL_0225: Unknown result type (might be due to invalid IL or missing references) //IL_0251: Unknown result type (might be due to invalid IL or missing references) //IL_0256: Unknown result type (might be due to invalid IL or missing references) //IL_0313: Unknown result type (might be due to invalid IL or missing references) //IL_0315: Unknown result type (might be due to invalid IL or missing references) if (!DanceTools.CheckHost()) { return; } if (args.Length < 1) { string text = $"\nItem List (ID | Name) Total items: {DanceTools.spawnableItems.Count}"; for (int i = 0; i < DanceTools.spawnableItems.Count; i++) { text += $"\n{DanceTools.spawnableItems[i].id} | {DanceTools.spawnableItems[i].name}"; } DTConsole.Instance.PushTextToOutput(text ?? "", DanceTools.consoleSuccessColor); DTConsole.Instance.PushTextToOutput("Command usage: item itemID/itemName amount value weight", DanceTools.consoleInfoColor); return; } int num = 1; int num2 = 1; int num3 = 0; float num4 = -1f; if (int.TryParse(args[0], out var result)) { num3 = result; } else { if (!DanceTools.spawnableItems.Any((DanceTools.DTItem x) => x.name.ToLower().Contains(args[0]))) { DTConsole.Instance.PushTextToOutput("Cannot find item by the name: " + args[0], DanceTools.consoleErrorColor); return; } num3 = DanceTools.spawnableItems.Find((DanceTools.DTItem x) => x.name.ToLower().Contains(args[0])).id; } if (num3 > StartOfRound.Instance.allItemsList.itemsList.Count || num3 < 0) { DTConsole.Instance.PushTextToOutput($"Invalid Item ID: {num3}", DanceTools.consoleErrorColor); return; } if (args.Length > 1) { num2 = DanceTools.CheckInt(args[1]); if (num2 == -1) { return; } if (num2 <= 0) { DTConsole.Instance.PushTextToOutput("Amount cannot be 0 or less than 0", DanceTools.consoleErrorColor); return; } } Vector3 position = ((Component)GameNetworkManager.Instance.localPlayerController).transform.position; if (GameNetworkManager.Instance.localPlayerController.isPlayerDead) { position = ((Component)GameNetworkManager.Instance.localPlayerController.spectatedPlayerScript).transform.position; DTConsole.Instance.PushTextToOutput("Spawning item on " + GameNetworkManager.Instance.localPlayerController.spectatedPlayerScript.playerUsername, DanceTools.consoleInfoColor); } if (args.Length > 2) { num = DanceTools.CheckInt(args[2]); if (num == -1) { num = 1; } } if (args.Length > 3) { num4 = DanceTools.CheckFloat(args[3]); if (num4 == -1f) { num4 = -1f; } } for (int j = 0; j < num2; j++) { GameObject val = Object.Instantiate<GameObject>(StartOfRound.Instance.allItemsList.itemsList[num3].spawnPrefab, position, Quaternion.identity); ScanNodeProperties component = val.GetComponent<ScanNodeProperties>(); if ((Object)(object)component == (Object)null) { component = val.AddComponent<ScanNodeProperties>(); component.scrapValue = num; component.subText = $"Value: ${num}"; } val.GetComponent<GrabbableObject>().fallTime = 0f; val.GetComponent<GrabbableObject>().scrapValue = num; if (num4 != -1f) { val.GetComponent<GrabbableObject>().itemProperties.weight = num4; } val.GetComponent<GrabbableObject>().itemProperties.creditsWorth = num; val.GetComponent<GrabbableObject>().SetScrapValue(num); val.GetComponent<NetworkObject>().Spawn(false); } DTConsole.Instance.PushTextToOutput($"Spawned {num2}x item {StartOfRound.Instance.allItemsList.itemsList[num3].itemName}({num3}) valued at {num} (weight: {num4} (buggy))", DanceTools.consoleSuccessColor); } } internal class CreditsCommands : ICommand { public string Name => "setcredits"; public string Desc => "Set credits to a value\nUsage: setcredits amount"; public void DisplayCommandDesc() { DTConsole.Instance.PushTextToOutput(Desc, DanceTools.consoleInfoColor); } public void ExecCommand(string[] args) { //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Expected O, but got Unknown if (!DanceTools.CheckHost()) { return; } if (args.Length < 1) { DTConsole.Instance.PushTextToOutput(Desc, DanceTools.consoleInfoColor); return; } int num = 0; num = DanceTools.CheckInt(args[0]); if (num != -1) { if (num < 0) { DTConsole.Instance.PushTextToOutput("Can't set credits bellow 0", DanceTools.consoleErrorColor); return; } Terminal val = (Terminal)Object.FindObjectOfType(typeof(Terminal)); val.SyncGroupCreditsServerRpc(num, val.numberOfItemsInDropship); DTConsole.Instance.PushTextToOutput($"Set group credits to {num}", DanceTools.consoleSuccessColor); } } } internal class GodCommand : ICommand { public string Name => "god"; public string Desc => "Toggles godmode for the host"; public void DisplayCommandDesc() { DTConsole.Instance.PushTextToOutput(Desc, DanceTools.consoleInfoColor); } public void ExecCommand(string[] args) { if (DanceTools.CheckHost()) { DanceTools.playerGodMode = !DanceTools.playerGodMode; string text = (DanceTools.playerGodMode ? "God mode enabled" : "God mode disabled"); DTConsole.Instance.PushTextToOutput(text, DanceTools.consoleInfoColor); } } } internal class LightsCommand : ICommand { public string Name => "lights"; public string Desc => "Toggles lights inside the facility\nUsage: lights on/off"; public void DisplayCommandDesc() { DTConsole.Instance.PushTextToOutput(Desc, DanceTools.consoleInfoColor); } public void ExecCommand(string[] args) { if (!DanceTools.CheckHost()) { return; } if (args.Length < 1) { DTConsole.Instance.PushTextToOutput(Desc, DanceTools.consoleInfoColor); return; } string text = ""; try { string text2 = args[0]; string text3 = text2; if (!(text3 == "on")) { if (text3 == "off") { DanceTools.currentRound.SwitchPower(false); text = "Indoor lights turned off"; } } else { DanceTools.currentRound.SwitchPower(true); text = "Indoor lights turned on"; } } catch (Exception) { text = "Failed to toggle lights"; } DTConsole.Instance.PushTextToOutput(text, DanceTools.consoleInfoColor); } } internal class Tester : ICommand { public string Name => "tester"; public string Desc => "command for testing stuff. disabled in current build"; public void DisplayCommandDesc() { DTConsole.Instance.PushTextToOutput(Desc, DanceTools.consoleInfoColor); } public void ExecCommand(string[] args) { DisplayCommandDesc(); } } }