internal static TDerived Parse(BinaryReader reader, W3dParseContext context) { return(ParseChunk(reader, context, header => { var result = new TDerived(); ParseChunks(reader, context.CurrentEndPosition, chunkType => { switch (chunkType) { case W3dChunkType.W3D_CHUNK_HLOD_SUB_OBJECT_ARRAY_HEADER: result.Header = W3dHLodArrayHeader.Parse(reader, context); break; case W3dChunkType.W3D_CHUNK_HLOD_SUB_OBJECT: result.SubObjects.Add(W3dHLodSubObject.Parse(reader, context)); break; default: throw CreateUnknownChunkException(chunkType); } }); return result; })); }
public static W3dHLodArray Parse(BinaryReader reader, uint chunkSize) { var currentSubObjectIndex = 0; return(ParseChunk <W3dHLodArray>(reader, chunkSize, (result, header) => { switch (header.ChunkType) { case W3dChunkType.W3D_CHUNK_HLOD_SUB_OBJECT_ARRAY_HEADER: result.Header = W3dHLodArrayHeader.Parse(reader); result.SubObjects = new W3dHLodSubObject[result.Header.ModelCount]; break; case W3dChunkType.W3D_CHUNK_HLOD_SUB_OBJECT: result.SubObjects[currentSubObjectIndex] = W3dHLodSubObject.Parse(reader); currentSubObjectIndex++; break; default: throw CreateUnknownChunkException(header); } })); }