/// <summary> /// Command handler for 'GET' command /// </summary> private DebugCommandStatus CommandHandle_GET(DebugCommand command, string[] args) { if (args.Length < 1) { return(DebugCommandStatus.ARGUMENT_ERROR); } int amount = 1; // try get amount if (args.Length >= 2) { int.TryParse(args[1], out amount); } // try parse args and add items to inventory if (Enum.TryParse(args[0], true, out BlockType blockType)) { PlayerController.InventorySystem.AddItem(blockType, amount); } else if (Enum.TryParse(args[0], true, out ItemType itemType)) { PlayerController.InventorySystem.AddItem(itemType, amount); } else { return(DebugCommandStatus.SYNTAX_ERROR); } return(DebugCommandStatus.OK); }
private DebugCommandStatus CommandHandle_CLEAR_INVENTORY(DebugCommand command, string[] args) { InventorySlot[] allInventorySlots = PlayerController.InventorySystem.InventorySlots.ToArray(); foreach (var slot in allInventorySlots) { PlayerController.InventorySystem.RemoveItem(slot, -1); } return(DebugCommandStatus.OK); }
/// <summary> /// Called when command was executed successfully /// </summary> private void CommandExecuted(DebugCommand command) { string msg = $"[{command.Command.ToUpper()}] {command.ExecutedMsg}"; DebugManager.AddDebugMessageStatic(msg); #if UNITY_ENGINE Debug.Log(msg, this); #endif }
/// <summary> /// Called when player wants to see help for command (arg[0] == '-h' v '-help') /// </summary> private void CommandHelp(DebugCommand command) { string msg = command.HelpMsg; DebugManager.AddDebugMessageStatic(msg); #if UNITY_ENGINE Debug.Log(msg, this); #endif }
/// <summary> /// Called when there is a problem with arguments syntax (e.g. /get qwerty will cause this because there is no such item type) /// </summary> private void CommandSyntaxError(DebugCommand command, string[] args) { string msg = $"[{command.Command.ToUpper()}] {command.SyntaxErrorMsg}"; DebugManager.AddDebugMessageStatic(msg); #if UNITY_ENGINE Debug.Log(msg, this); #endif }