public ResourceChunkHeader ReadChunkHeader() { var header = new ResourceChunkHeader(); header.Read(this); return(header); }
public void WriteResourceChunk(Resource resource) { // Get chunk type ResourceChunkType type; switch (resource.ResourceType) { case ResourceType.TextureDictionary: type = ResourceChunkType.TextureDictionary; break; case ResourceType.MaterialDictionary: type = ResourceChunkType.MaterialDictionary; break; case ResourceType.Model: type = ResourceChunkType.Model; break; case ResourceType.ChunkType000100F9: type = ResourceChunkType.ChunkType000100F9; break; case ResourceType.ChunkType000100F8: type = ResourceChunkType.ChunkType000100F8; break; case ResourceType.AnimationPack: type = ResourceChunkType.AnimationPack; break; default: throw new InvalidOperationException($"Resource of type {resource.ResourceType} has no associated chunk type."); } // Skip to-be chunk header var startPos = Position; SeekCurrent(ResourceChunkHeader.SIZE); // Write chunk body resource.Write(this); var endPos = Position; var delta = endPos - startPos; // Write chunk header SeekBegin(startPos); var header = new ResourceChunkHeader(resource.Version, type, (int)delta); header.Write(this); // Seek to end of the chunk SeekBegin(endPos); }
public void WriteEndChunk(uint version) { var header = new ResourceChunkHeader(version, ResourceChunkType.Invalid, 0); header.Write(this); }