Whee.WordBuilder.ProjectV2.WeightedCommandNode.LoadWeightedCommand C# (CSharp) Method

LoadWeightedCommand() private method

private LoadWeightedCommand ( ) : void
return void
        private void LoadWeightedCommand()
        {
            bool found = false;
            double probability = 0;
            Token probabilityToken = m_serializer.ReadNumericToken(this, ref probability, out found);

            if (probabilityToken != null)
            {
                Weight = probability;
                Token command = m_serializer.ReadTextToken(this);

                if (command != null)
                {
                    Model.Commands.CommandBase cb = Model.Commands.CommandBase.FindCommand(command.Text);

                    if (cb != null)
                    {
                        command.Type = TokenType.Command;
                        cb.Index = command.Offset;
                        cb.LoadCommand(m_serializer);
                        Command = cb;
                        Children.Add(cb);
                        //cb.Length = m_serializer.Position - cb.Index;
                    }
                    else
                    {
                        m_serializer.Warn(string.Format("Command '{0}' not found.", command.Text), this);
                        command.Type = TokenType.Error;
                        Successful = false;
                    }
                }
                else
                {
                    m_serializer.Warn("Expected a command", this);
                    probabilityToken.Type = TokenType.Error;
                    Successful = false;
                }
            }
            else if (found)
            {
                m_serializer.Warn("Expected a probability expressed as a decimal number.", this);
                Successful = false;

                m_serializer.ReadTextToken(this).Type = TokenType.Error;
            }
        }