public static bool TryGettingCommandByName(string commandName, out GameConsoleCommand command) { command = null; for (int i = 0; i < Commands.Count; i++) { if (!AliasExists(Commands[i], commandName) || !Commands[i].Active) { continue; } command = Commands[i]; return(true); } return(false); }
public static List <GameConsoleCommand> UpdateList() { List <Type> types = TypeFinder.FindAllTypes <GameConsoleCommand>(); _commands.Clear(); for (int i = 0; i < types.Count; i++) { ConstructorInfo constructor = types[i].GetConstructor(Type.EmptyTypes); GameConsoleCommand command = (GameConsoleCommand)constructor.Invoke(null); if (command.Active) { _commands.Add(command); } } return(_commands); }
private static bool AliasExists(GameConsoleCommand command, string targetName) { if (command.CommandName == targetName) { return(true); } if (command.Aliases == null) { return(false); } for (int i = 0; i < command.Aliases.Length; i++) { if (command.Aliases[i] == targetName) { return(true); } } return(false); }