Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Command
- {
- /// <summary>The string by which this command will be called</summary>
- public string commandKey;
- /// <summary>The information of this command that the help option will show</summary>
- public string helpInfo;
- public delegate String stringVoid();
- public delegate String stringString(String consoleInput);
- public delegate void voidCmd();
- public delegate void voidString(String consoleInput);
- public delegate void cmd(String[] params, Console console);
- public cmd _cmd;
- public Command(String commandInput, String helpTooltip, cmd command)
- {
- commandKey = commandInput;
- helpInfo = helpTooltip;
- _cmd = command;
- }
- #region CreateCommand Methods
- public static Command createCommand(String commandInput, String helpTooltip, stringVoid command)
- {
- cmd wrappedCommand = (String[] params, Console console) => console.log(command());
- return new Command(commandInput, helpTooltip, (String[] params, Console console) => console.log(command()));
- }
- public static Command createCommand(String commandInput, String helpTooltip, stringString command)
- {
- cmd wrappedCommand = (String[] params, Console console) => console.log(command(params.Length == 0 ? "" : params[0]));
- return new Command(createCommand, helpTooltip, wrappedCommand);
- }
- public static Command createCommand(String commandInput, String helpTooltip, voidCmd command)
- {
- cmd wrappedCommand = (String[] params, Console console) => command();
- return new Command(commandInput, helpTooltip, wrappedCommand);
- }
- public static Command createCommand(String commandInput, String helpTooltip, voidString command)
- {
- cmd wrappedCommand = (String[] params, Console console) => command(params.Length == 0 ? "" : params[0]);
- return new Command(commandInput, helpTooltip, wrappedCommand);
- }
- #endregion
- }
Advertisement
Add Comment
Please, Sign In to add comment