/* Queue a command to be executed on update on the main thread */ public static void Queue(CUDLRCommandAttribute command, string[] args) { QueuedCommand queuedCommand = new QueuedCommand(); queuedCommand.command = command; queuedCommand.args = args; Instance.m_commandQueue.Enqueue(queuedCommand); }
private void _add(string[] commands, int command_index, CUDLRCommandAttribute cmd) { if (commands.Length == command_index) { m_command = cmd; return; } string token = commands[command_index]; if (!m_subcommands.ContainsKey(token)) { m_subcommands[token] = new CommandTree(); } m_subcommands[token]._add(commands, command_index + 1, cmd); }
/* Register a new console command */ public static void RegisterCommand(string command, string desc, CUDLRCommandAttribute.Callback callback, bool runOnMainThread = true) { if (string.IsNullOrEmpty(command)) { if (callback != null && callback.Method != null) { command = callback.Method.Name; } else { throw new Exception("Command String cannot be empty"); } } CUDLRCommandAttribute cmd = new CUDLRCommandAttribute(command, desc, runOnMainThread); cmd.m_callback = callback; Instance.m_commands.Add(cmd); Instance.m_help += string.Format("\n{0} : {1}", command, desc); }
public void Add(CUDLRCommandAttribute cmd) { _add(cmd.m_command.ToLower().Split(' '), 0, cmd); }