Class ChunkStorage
In-memory store of a world's cubic chunks: holds loaded BlockChunks and generates them on first access (via the TerrainGenerator) for any position inside Bounds. A position outside the bounds has no chunk (the world ends there).
This is the interim holder — persistence (load/save from disk) is being built separately (Nullicorn's ChunkStorage); this generate-on-miss cache slots behind that when it lands, so the rest of the world/ streaming code depends on this shape, not on where a chunk came from.
public sealed class ChunkStorage
- Inheritance
-
ChunkStorage
- Inherited Members
Constructors
ChunkStorage(TerrainGenerator, WorldBounds)
In-memory store of a world's cubic chunks: holds loaded BlockChunks and generates them on first access (via the TerrainGenerator) for any position inside Bounds. A position outside the bounds has no chunk (the world ends there).
This is the interim holder — persistence (load/save from disk) is being built separately (Nullicorn's ChunkStorage); this generate-on-miss cache slots behind that when it lands, so the rest of the world/ streaming code depends on this shape, not on where a chunk came from.
public ChunkStorage(TerrainGenerator generator, WorldBounds bounds)
Parameters
generatorTerrainGeneratorboundsWorldBounds
Properties
Bounds
The world's chunk-space extent; null sides are unbounded.
public WorldBounds Bounds { get; }
Property Value
LoadedCount
How many chunks are currently resident in memory.
public int LoadedCount { get; }
Property Value
LoadedPositions
A snapshot of the currently-resident chunk positions (safe to iterate while others load/unload).
public IReadOnlyCollection<ChunkPos> LoadedPositions { get; }
Property Value
Methods
Get(ChunkPos)
The chunk 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?)
The chunk only if it is already resident (no generation).
public bool TryGetLoaded(ChunkPos position, out BlockChunk? chunk)
Parameters
positionChunkPoschunkBlockChunk
Returns
Unload(ChunkPos)
Evict a chunk from memory. Returns whether it was resident.
public bool Unload(ChunkPos position)
Parameters
positionChunkPos