예제 #1
0
        /// <summary>
        /// Dispatch a console command to all listeners
        /// </summary>
        /// <param name="command"></param>
        public static void DispatchCommand(string[] command)
        {
            // Master server command handler
            if (MasterServer.Instance != null)
            {
                MasterServer.Instance.Command(command);
            }

            // Handle commands for the module manager
            Command(command);

            // Registered command listeners
            foreach (ICommandListener listener in commandListeners)
            {
                listener.Command(command);
            }

            // Active modules which are command listeners
            foreach (ActiveModule module in activeModules.Values)
            {
                if (module.Module.GetType().GetInterface(typeof(ICommandListener).Name) != null)
                {
                    ICommandListener listener = (ICommandListener)module.Module;
                    if (listener != null)
                    {
                        listener.Command(command);
                    }
                }
            }
        }