private void ExecuteCommand(OldCommand.Command command, string [] args, Game game) { bool success = command.AttemptExecution(args, game); if (!success) { } }
public OldCommand.Command FindCommand(OldCommand.Command commandType, bool inMenu) { foreach (var command in inMenu ? _menuCommands : _gameCommands) { if (command.GetType() == commandType.GetType()) { return(command); } } return(null); }
public void FindAndExecute(string input, string [] args, Game game) { OldCommand.Command command = FindCommand(input, game.IsInMenu); if (command == null) { CustomConsole.WriteLine($"{CustomConsole.Red}ERROR: The command \"{input}\" does not exist!"); } else if (command.NeedsGodMode && !game.IsGodMode) { CustomConsole.WriteLine($"{CustomConsole.Red}ERROR: The command \"{input}\" requires {CustomConsole.DarkYellow}God Mode{CustomConsole.White} to run."); CustomConsole.WriteLine($"Use the command \"{new GodModeCommand().Aliases[0]}\" to enter {CustomConsole.DarkYellow}God Mode{CustomConsole.White}."); } else { if (command.NeedsValidation && !ValidateCommand(command)) { return; } ExecuteCommand(command, args, game); } }
private bool ValidateCommand(OldCommand.Command command) { return(IOManager.GetYesNo($"Run command \"{command.Name}\"? (y/n)")); }