Exemple #1
0
        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);
        }
Exemple #2
0
        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);
        }
Exemple #3
0
 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);
 }