Table of Contents

Class ChunkSerializer

Namespace
TileWorld.Engine.Storage
Assembly
TileWorld.Engine.dll

Serializes and deserializes chunk cell data to the on-disk binary chunk format.

public sealed class ChunkSerializer
Inheritance
ChunkSerializer
Inherited Members

Methods

Deserialize(byte[], ChunkCoord)

Deserializes a chunk payload and validates it against the expected chunk coordinate.

public Chunk Deserialize(byte[] data, ChunkCoord expectedCoord)

Parameters

data byte[]

The binary chunk payload.

expectedCoord ChunkCoord

The chunk coordinate expected by the caller.

Returns

Chunk

The deserialized chunk.

Exceptions

InvalidDataException

Thrown when the payload is malformed, truncated, or mismatched.

Serialize(Chunk)

Serializes a chunk into the engine's binary chunk payload format.

public byte[] Serialize(Chunk chunk)

Parameters

chunk Chunk

The chunk to serialize.

Returns

byte[]

The binary chunk payload.

Serialize(Chunk, IReadOnlyList<ObjectInstance>)

Serializes a chunk and its anchored object instances into the engine's binary chunk payload format.

public byte[] Serialize(Chunk chunk, IReadOnlyList<ObjectInstance> anchoredObjects)

Parameters

chunk Chunk

The chunk to serialize.

anchoredObjects IReadOnlyList<ObjectInstance>

The anchored object instances that should be stored with this chunk.

Returns

byte[]

The binary chunk payload.