Class ChunkStorage
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
generatorTerrainGeneratorboundsWorldBounds
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
LoadedCount
How many block data entries are currently cached.
public int LoadedCount { get; }
Property Value
LoadedPositions
A snapshot of the loaded chunk positions (safe to iterate while others load/unload).
public IReadOnlyCollection<ChunkPos> LoadedPositions { get; }
Property Value
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
positionChunkPos
Returns
IsInBounds(ChunkPos)
Whether a position lies inside the world (i.e. a chunk can exist there).
public bool IsInBounds(ChunkPos position)
Parameters
positionChunkPos
Returns
TryGetLoaded(ChunkPos, out BlockChunk?)
Block data only if it is already cached (no generation).
public bool TryGetLoaded(ChunkPos position, out BlockChunk? section)
Parameters
positionChunkPossectionBlockChunk
Returns
Unload(ChunkPos)
Evicts cached block data. Returns whether an entry was present.
public bool Unload(ChunkPos position)
Parameters
positionChunkPos