Пример #1
0
        /// <inheritdoc />
        public ICommandList Create(IEnumerable <ICommand> commands)
        {
            ICommandList commandList = new CommandList(_commandListLogger);

            commandList.AddRange(commands);
            return(commandList);
        }
Пример #2
0
 public IEnumerable <GameCommandBase> GetActionCommands()
 {
     CommandList.Clear();
     foreach (var obj in GameObjects)
     {
         CommandList.AddRange(obj.GetActionCommands());
     }
     CommandList.Add(new QuitGameCommand(this));
     return(CommandList);
 }
        protected override ICommandList ConvertInputToObject(string input)
        {
            CommandList commandList = (CommandList)Factory.CreateInputObject <ICommandList>();

            CommandType[] commands = input?.Trim()?
                                     .Replace(" ", string.Empty)?
                                     .Select(p => (CommandType)p)
                                     .ToArray();
            commandList.AddRange(commands);

            return(commandList);
        }
Пример #4
0
        /// <summary>
        /// Update all the commands.
        /// </summary>
        public static void updateAll()
        {
            CommandList commandList = new CommandList();

            using (_commandLock.read())
            {
                commandList.AddRange(_commandList);
            }
            foreach (Command command in commandList)
            {
                command.update();
            }
        }
Пример #5
0
        private void SaveCommands()
        {
            Type[] types      = { typeof(Command) };
            var    serializer = new XmlSerializer(typeof(CommandList), types);

            using (var stream = new FileStream(_storagePath, FileMode.Create))
            {
                var commandList = new CommandList();
                commandList.AddRange(_dataSource.Select(o => o));
                serializer.Serialize(stream, commandList);
                stream.Flush();
            }
        }
Пример #6
0
        /// <summary>
        /// Joins every user-defined function to the end of the command list.
        /// After calling this function you should NOT change the command list.
        /// </summary>
        public void JoinCommands()
        {
            if (!isJoined)
            {
                originalCommandList = CommandList;
                CommandList = new CommandList();
                CommandList.AddRange(originalCommandList);
                if (CommandList.Count > 0 && !(CommandList.Last() is Return))
                {
                    CommandList.Add(new Return(false));
                }
                //EntryPoints.Clear();
                foreach (var udf in Functions)
                {
                    //EntryPoints.Add(udf, CommandList.Count);
                    udf.EntryPoint = CommandList.Count;
                    CommandList.AddRange(udf.Commands);
                }

                isJoined = true;
            }
        }