Exemplo n.º 1
0
        protected bool ParseSubBlocks(BinaryReader inputReader)
        {
            bool continueParsing = false;

            do
            {
                string subBlockTypeName = inputReader.ReadUInt32AsString();
                if (!Enum.IsDefined(typeof(SubBlockType), subBlockTypeName))
                {
                    Trace.Assert(false, "Undefined sub block type encountered!");
                    return(false);
                }

                SubBlockType subBlockType = (SubBlockType)Enum.Parse(typeof(SubBlockType), subBlockTypeName);
                switch (subBlockType)
                {
                case SubBlockType.CInt:
                case SubBlockType.CMod:
                    continueParsing = ParseSubBlock(inputReader, subBlockType);
                    break;

                case SubBlockType.CEnd:
                    continueParsing = false;
                    break;

                default:
                    Trace.Assert(false, "Unimplemented sub block type!");
                    return(false);
                }
            } while (continueParsing);

            return(SubBlocks.Count > 0);
        }
Exemplo n.º 2
0
        private bool ParseSubBlock(BinaryReader inputReader, SubBlockType type)
        {
            ModelBlock block = null;

            if (type == SubBlockType.CMod)
            {
                block = ModelBlock.ParseBlock(inputReader, BlockType.CMod);
            }
            else
            {
                block = ModelBlock.ParseBlock(inputReader);
            }

            if (block == null)
            {
                return(false);
            }

            SubBlocks.Add(block);
            return(true);
        }