Table of Contents

Class ChunkStorage

Namespace
Shard.Gameplay.Universe.World.Chunks
Assembly
Shard.Gameplay.Universe.dll

Caches generated block data by chunk position within the World bounds.

public sealed class ChunkStorage
Inheritance
ChunkStorage
Inherited Members

Remarks

Persistence can supply chunk data here when loading from disk is implemented.

Constructors

ChunkStorage(TerrainGenerator, WorldBounds)

Caches generated block data by chunk position within the World bounds.

public ChunkStorage(TerrainGenerator generator, WorldBounds bounds)

Parameters

generator TerrainGenerator
bounds WorldBounds

Remarks

Persistence can supply chunk data here when loading from disk is implemented.

Properties

Bounds

The world's chunk-coordinate extent; null sides are unbounded.

public WorldBounds Bounds { get; }

Property Value

WorldBounds

LoadedCount

How many block data entries are currently cached.

public int LoadedCount { get; }

Property Value

int

LoadedPositions

A snapshot of the loaded chunk positions (safe to iterate while others load/unload).

public IReadOnlyCollection<ChunkPos> LoadedPositions { get; }

Property Value

IReadOnlyCollection<ChunkPos>

Methods

Get(ChunkPos)

Block data at position, generating (and caching) it on first access. Returns null when the position is outside Bounds — there is no world there.

public BlockChunk? Get(ChunkPos position)

Parameters

position ChunkPos

Returns

BlockChunk

IsInBounds(ChunkPos)

Whether a position lies inside the world (i.e. a chunk can exist there).

public bool IsInBounds(ChunkPos position)

Parameters

position ChunkPos

Returns

bool

TryGetLoaded(ChunkPos, out BlockChunk?)

Block data only if it is already cached (no generation).

public bool TryGetLoaded(ChunkPos position, out BlockChunk? section)

Parameters

position ChunkPos
section BlockChunk

Returns

bool

Unload(ChunkPos)

Evicts cached block data. Returns whether an entry was present.

public bool Unload(ChunkPos position)

Parameters

position ChunkPos

Returns

bool