private ChunkResource ReadResource() { uint type = _reader.ReadUInt32(); uint length = _reader.ReadUInt32(); if (_reader.BaseStream.Position + length > _reader.BaseStream.Length) { throw new InvalidDataException($"overflowing chunk: 0x{type:X8} ({length} bytes)"); } // set ourselves up to jump to the end long endPos = _reader.BaseStream.Position + length; // create chunk info BundleChunk chunk = new BundleChunk(); chunk.Type = type; chunk.Size = length; chunk.Offset = _reader.BaseStream.Position - 8; // find reader ResourceReader reader = ChunkMapper.GetReader(_gameId, type); // read resource ChunkResource resource = reader.ReadResource(chunk, _reader); // we're all done _reader.BaseStream.Position = endPos; return(resource); }
protected override GenericChunk ReadInternal(BundleChunk chunk, BinaryReader binaryReader) { throw new System.NotImplementedException(); }
/// <summary> /// Reads the resource from the given stream /// </summary> /// <param name="chunk"></param> /// <param name="binaryReader"></param> /// <returns></returns> public abstract ChunkResource ReadResource(BundleChunk chunk, BinaryReader binaryReader);