Пример #1
0
        internal static W3dAggregateInfo Parse(BinaryReader reader, W3dParseContext context)
        {
            return(ParseChunk(reader, context, header =>
            {
                var result = new W3dAggregateInfo
                {
                    BaseModelName = reader.ReadFixedLengthString(W3dConstants.NameLength * 2),
                    SubObjectCount = reader.ReadUInt32()
                };

                result.SubObjects = new List <W3dAggregateSubObject>();
                for (var i = 0; i < result.SubObjectCount; i++)
                {
                    result.SubObjects.Add(W3dAggregateSubObject.Parse(reader));
                }

                return result;
            }));
        }
Пример #2
0
        internal static W3dAggregate Parse(BinaryReader reader, W3dParseContext context)
        {
            var parsedChunk = ParseChunk(reader, context, header =>
            {
                var result = new W3dAggregate();

                ParseChunks(reader, context.CurrentEndPosition, chunkType =>
                {
                    switch (chunkType)
                    {
                    case W3dChunkType.W3D_CHUNK_AGGREGATE_CLASS_INFO:
                        result.ClassInfo = W3dAggregateClassInfo.Parse(reader, context);
                        break;

                    case W3dChunkType.W3D_CHUNK_AGGREGATE_HEADER:
                        result.Header = W3dAggregateHeader.Parse(reader, context);
                        break;

                    case W3dChunkType.W3D_CHUNK_AGGREGATE_INFO:
                        result.Info = W3dAggregateInfo.Parse(reader, context);
                        break;

                    case W3dChunkType.W3D_CHUNK_TEXTURE_REPLACER_INFO:
                        result.TextureReplacerInfo = W3dTextureReplacerInfo.Parse(reader, context);
                        break;

                    default:
                        throw CreateUnknownChunkException(chunkType);
                    }
                });

                return(result);
            });

            return(parsedChunk);
        }