LayerProcGen v0.1.0
Layer-based infinite procedural generation
|
In a layer-and-chunk pair of classes, the chunk inherits from this class. More...
Inherits AbstractLayerChunk.
Public Member Functions | |
virtual void | Create (int level, bool destroy) |
Create or destroy the specified level of this chunk. | |
virtual void | Reset () |
Called by the pool when this IPoolable object is returned to the pool. | |
override string | ToString () |
Example output: "[TerrainChunk (3,-4) level 0]". | |
Properties | |
override AbstractChunkBasedDataLayer | abstractLayer [get] |
Needed for C# covariance reasons. The layer property can be used instead. | |
GridBounds | bounds [get] |
The bounds in world space units of this chunk. | |
Point | index [get, set] |
The coordinate index this chunk is for. | |
L | layer [get] |
The layer for this chunk type. | |
int | level = -1 [get, set] |
The level the chunk is currently generated up to (zero-based). | |
Point | worldOffset [get] |
The position in world space units of the lower left corner of this chunk. | |
In a layer-and-chunk pair of classes, the chunk inherits from this class.
L | The corresponding layer class. |
C | The chunk class itself. |
A layer contains a grid of chunks and takes care of generating and destroying them as appropriate. Each chunk generates and destroys its own data in its Create method.
L | : | ChunkBasedDataLayer | |
L | : | L | |
L | : | C | |
L | : | new() | |
C | : | LayerChunk | |
C | : | L | |
C | : | C | |
C | : | new() |
|
virtualinherited |
Create or destroy the specified level of this chunk.
level | The level of the chunk to create or destroy. |
destroy | True if destroying, false if creating. |
The central method for procedural generation of the chunk.
If the chunk has only one level, the following is a useful pattern for the method. Placing the destruction code before the creation code will tend to place lines of code related to resource use closer to each other.
If the chunk has multiple levels, the following is a useful pattern for the method:
|
virtualinherited |
Called by the pool when this IPoolable object is returned to the pool.
AbstractLayerChunk resets internal chunk state in this method. Derived classes generally don't need to override this method as cleanup should happen in the Create method when the destroy parameter is true. If overriding this method anyway, ensure the the base method is called.
Implements IPoolable.
|
inherited |
Example output: "[TerrainChunk (3,-4) level 0]".
|
get |
Needed for C# covariance reasons. The layer property can be used instead.
Implements ILC.
|
getinherited |
The bounds in world space units of this chunk.
Based on worldOffset and layer.chunkSize.
Implements ILC.
|
getsetinherited |
The coordinate index this chunk is for.
A 2D index where consecutive chunks have consecutive indexes. The chunk with its lower left corner at the world origin will have index (0, 0). Its neighbor to the left will have index (-1, 0) and to the right (1, 0) etc.
|
get |
The layer for this chunk type.
Typically the chunk will often reference its layer to get the chunkSize property, and other chunk-related properties specified in a layer due to them being identical for all chunks of that layer.
|
getsetinherited |
The level the chunk is currently generated up to (zero-based).
This property is not updated to a higher level until the call to Create has finished, so do not check it inside the Create method. Use the level parameter of the Create method instead.
|
getinherited |
The position in world space units of the lower left corner of this chunk.
Based on index * layer.chunkSize.