示例#1
0
        public override void LoadCommand(Whee.WordBuilder.ProjectV2.IProjectSerializer serializer)
        {
            double num   = 0;
            bool   found = true;

            Token amount = null;

            while (found)
            {
                amount = serializer.ReadNumericToken(this, ref num, out found);
                if (amount != null)
                {
                    _Repetitions.Add((int)num);
                }

                if (amount == null && found)
                {
                    int    reps = 0;
                    string data;
                    amount = serializer.ReadRepeatingToken(this, out reps, out data);

                    if (amount != null)
                    {
                        List <int> numbers = new List <int>();
                        foreach (string numstring in data.Split(' '))
                        {
                            int number = 0;
                            if (int.TryParse(numstring, out number))
                            {
                                numbers.Add(number);
                            }
                            else
                            {
                                serializer.Warn("Expected numbers only", this);
                            }
                        }

                        for (int i = 0; i < reps; i++)
                        {
                            _Repetitions.AddRange(numbers);
                        }
                    }
                    else
                    {
                        found = false;
                    }
                }
            }

            CommandBlockNode cbn = new CommandBlockNode(serializer);

            Children.Add(cbn);

            foreach (CommandBase cmd in cbn.Commands)
            {
                Commands.Add(cmd);
            }
        }