LayerProcGen v0.1.0
Layer-based infinite procedural generation
|
You implement pairs of layers and chunks, e.g. ExampleLayer and ExampleChunk. A layer contains chunks of the corresponding type.
A layer class must inherit from ChunkBasedDataLayer
and a chunk class must inherit from LayerChunk
. Both of those base classes must be used with generic type parameters of the layer and chunk themselves, e.g. <ExampleLayer, ExampleChunk>
.
Here is a simplified example. See the Script Templates page for more complete templates or the Getting Started page for a simple working example.
Each layer stores a RollingGrid of corresponding chunks. This is automatically handled by the layer base class, though you can optionally specify the size of the grid in the base class constructor.
Chunks are always rectangular and all chunks in a given layer have the same world space size. This size is specified in the layer by overriding the two properties chunkW
and chunkH
.
The size is specified in integers, meaning the smallest possible size is one unit, but apart from that, chunks can have any size.
There is also a convenience property chunkSize
of type Point which combines the width and height.
A chunk is generated (invoking its generation code) when it’s depended on, and it's destroyed (recycled) when it’s no longer depended on.
The following pages will cover how to setup layer dependencies that allow chunks to request data from other layers, as well as the concept of internal layer levels, which is a special and optional concept where a single class can implement multiple layers at once.