Table of Contents

Class WorldStorage

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

Provides file-system access for world metadata and chunk payloads.

public sealed class WorldStorage
Inheritance
WorldStorage
Inherited Members

Constructors

WorldStorage()

Creates storage services with the default metadata and chunk serializers.

public WorldStorage()

WorldStorage(WorldMetadataSerializer, ChunkSerializer)

Creates storage services with explicit serializer dependencies.

public WorldStorage(WorldMetadataSerializer worldMetadataSerializer, ChunkSerializer chunkSerializer)

Parameters

worldMetadataSerializer WorldMetadataSerializer

The serializer used for world metadata JSON.

chunkSerializer ChunkSerializer

The serializer used for binary chunk payloads.

Methods

HasChunkData(string, ChunkCoord)

Returns true when chunk data exists on disk for the supplied coordinate.

public bool HasChunkData(string worldPath, ChunkCoord coord)

Parameters

worldPath string

The root path of the world on disk.

coord ChunkCoord

The chunk coordinate to inspect.

Returns

bool

true when persisted chunk data exists.

HasWorld(string)

Returns true when metadata exists for the supplied world path.

public bool HasWorld(string worldPath)

Parameters

worldPath string

The root path of the world on disk.

Returns

bool

true when world metadata exists.

LoadMetadata(string)

Loads world metadata from the supplied world path.

public WorldMetadata LoadMetadata(string worldPath)

Parameters

worldPath string

The root path of the world on disk.

Returns

WorldMetadata

The deserialized world metadata.

SaveChunk(string, Chunk)

Saves a chunk payload to the supplied world path.

public void SaveChunk(string worldPath, Chunk chunk)

Parameters

worldPath string

The root path of the world on disk.

chunk Chunk

The chunk to serialize.

SaveMetadata(string, WorldMetadata)

Saves world metadata to the supplied world path.

public void SaveMetadata(string worldPath, WorldMetadata metadata)

Parameters

worldPath string

The root path of the world on disk.

metadata WorldMetadata

The world metadata to serialize.

TryLoadChunk(string, ChunkCoord)

Attempts to load persisted chunk data for the supplied coordinate.

public Chunk TryLoadChunk(string worldPath, ChunkCoord coord)

Parameters

worldPath string

The root path of the world on disk.

coord ChunkCoord

The chunk coordinate to load.

Returns

Chunk

The loaded chunk when persisted data exists; otherwise null.