Skip to main content

CaveLayerChunk

A class in Root.Township, Alta.Chunks.

The location chunk for one cave layer, on the same object as its ICaveLayer. On the server it makes sure the layers above and below exist whenever it loads or is looked up.

Constructors​

MemberWhat it is
CaveLayerChunk()Unity makes components itself; use AddComponent or spawn a prefab instead of new.

Fields​

1 private and internal field
MemberWhat it is
private ICaveLayer caveLayerThe cave layer this chunk belongs to.

Properties​

MemberWhat it is
override ChunkRegion ChunkRegion { get; }Always ChunkRegion.caves.

Methods​

MemberWhat it is
override void GetNeighboursForLoading(float remainingLoadBudget, HashSet<Chunk> result)Spawns the adjacent layers first (server), then returns the normal loading neighbours.
override IEnumerable<LocationChunk> GetNeighboursForLookup()Spawns the adjacent layers first (server), then returns the normal lookup neighbours.
override void Initialize()Finds the ICaveLayer on the object and registers this chunk with LocationChunkHelper.
override void InitializeAsServer(SpawnData spawnData)Server: hooks FullyLoaded so adjacent layers spawn once this chunk is loaded.
override void PlayerEnteredChunk(Player player)Also reports the layer depth (layer + 1) to the game task system, for depth-based tasks.
protected override void OnDestroy()Client: unregisters the chunk and resets the other chunk bounds.
2 private and internal methods
MemberWhat it is
private void OnFullyLoaded(Chunk chunk)Handler for FullyLoaded: spawns the adjacent layers.
private void PrepareAdjacentLayers()Server: spawns the layer below, and the one above if this isn't layer 0, without generating them.