Table of Contents

Class WorldData

Namespace
TileWorld.Engine.World
Assembly
TileWorld.Engine.dll

Owns loaded chunks and metadata for a single world instance.

public sealed class WorldData
Inheritance
WorldData
Inherited Members

Constructors

WorldData(WorldMetadata)

Creates a world-data container for the supplied metadata.

public WorldData(WorldMetadata metadata)

Parameters

metadata WorldMetadata

The metadata associated with the world instance.

Properties

LoadedChunkCount

Gets the number of chunks currently loaded in memory.

public int LoadedChunkCount { get; }

Property Value

int

Metadata

Gets the persistent metadata associated with this world.

public WorldMetadata Metadata { get; }

Property Value

WorldMetadata

Methods

EnumerateLoadedChunks()

Enumerates all chunks currently loaded in memory.

public IEnumerable<Chunk> EnumerateLoadedChunks()

Returns

IEnumerable<Chunk>

The currently loaded chunks.

GetOrCreateChunk(ChunkCoord)

Resolves a chunk from memory or creates a new empty loaded chunk when one is not present.

public Chunk GetOrCreateChunk(ChunkCoord coord)

Parameters

coord ChunkCoord

The chunk coordinate to resolve.

Returns

Chunk

The existing or newly created chunk.

HasChunk(ChunkCoord)

Returns whether a chunk is currently loaded at the supplied coordinate.

public bool HasChunk(ChunkCoord coord)

Parameters

coord ChunkCoord

The chunk coordinate to inspect.

Returns

bool

true when the chunk is loaded.

RemoveChunk(ChunkCoord)

Removes a loaded chunk from memory when present.

public bool RemoveChunk(ChunkCoord coord)

Parameters

coord ChunkCoord

The chunk coordinate to remove.

Returns

bool

true when a loaded chunk was removed.

SetChunk(Chunk)

Stores or replaces a loaded chunk at its coordinate.

public void SetChunk(Chunk chunk)

Parameters

chunk Chunk

The chunk to store.

TryGetChunk(ChunkCoord, out Chunk)

Attempts to resolve a loaded chunk by coordinate.

public bool TryGetChunk(ChunkCoord coord, out Chunk chunk)

Parameters

coord ChunkCoord

The chunk coordinate to resolve.

chunk Chunk

The loaded chunk when present.

Returns

bool

true when a chunk is already loaded at the supplied coordinate.

UpdateMetadata(WorldMetadata)

Replaces the persistent metadata associated with this world.

public void UpdateMetadata(WorldMetadata metadata)

Parameters

metadata WorldMetadata

The metadata to store.