MapChunk
A class in Root.Township, Alta.Caves.
One square of a cave generator's map. It holds a MapChunkLayer per plugin, runs its generation on a worker thread, then hands itself to the generator to render through MapChunkDisplay objects.
- Listed in World generation
- Inherits or implements
MonoBehaviour - Documented in Caves
Constructors
| Member | What it is |
|---|---|
MapChunk() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
3 private and internal fields
| Member | What it is |
|---|---|
private List<MapChunkDisplay> displays | Backing field for Displays: displays spawned by Render. |
private ChunkThread generationThread | Background thread generating this chunk's layers. Null once it finishes. |
private Dictionary<Plugin, MapChunkLayer> layers | One layer of values per plugin, added by AddLayer and read by GetLayer. |
Properties
| Member | What it is |
|---|---|
List<MapChunkDisplay> Displays { get; } | Displays spawned to render this chunk. |
IGenerator Generator { get; private set; } | The generator this chunk belongs to. |
int OffX { get; private set; } | X offset in cells: X times the chunk size. |
int OffZ { get; private set; } | Z offset in cells: Z times the chunk size. |
GenerationBase RenderGenerator { get; private set; } | The generator as a GenerationBase, or null. |
int RequestCount { get; set; } | Number of outstanding requests for this chunk. |
int X { get; private set; } | Chunk grid x. |
int Z { get; private set; } | Chunk grid z. |
Methods
| Member | What it is |
|---|---|
void AddLayer(PluginInstance pluginInstance) | Adds a layer for a plugin instance. |
void Clear() | Disposes all layers. |
void CreateAllNonZeroLists() | Builds the non-zero cell list on every layer. |
MapChunkLayer GetLayer(Plugin plugin) | The layer for a plugin. Throws if there is none. |
ChunkThread Initialize(IGenerator generator, int x, int z) | Sets the generator and grid position, works out the offsets and creates the generation thread. |
void Prepare() | Clears any old layers and starts a fresh set. |
IEnumerator Render(PluginInstance pluginInstance, MapChunkDisplay displayPrefab, int renderIndex) | Spawns a display for a plugin's layer and returns its render coroutine, or null without a prefab. |
2 private and internal methods
Used in
Members of other types that take, return or hold a MapChunk:
ChunkThread.chunk, ChunkThread.ChunkThread, GenerationBase.chunks, GenerationBase.Chunks, GenerationBase.Render, GenerationBase.rendering, GenerationBase.StartRendering, IGenerator.StartRendering, MapChunkDisplay.chunk, MapChunkDisplay.Initialize, MapChunkLayer.Chunk, MapChunkLayer.MapChunkLayer, MarchingCubesChunkDisplay.GetMesh, MarchingCubesPlugin.GetMesh, MarchingCubesPlugin.meshes, MarchingCubesPlugin.Modify, Plugin.Modify, Plugin.Render, PluginInstance.ModifyChunk, PluginInstance.RenderChunk, IPartInstance.Modify, MapGeneratorPartInstance<T>.Modify, RoomFixPlugin.Render.