LayerProcGen v0.1.0
Layer-based infinite procedural generation
|
Internal. Non-generic class that LayerChunk inherits from. More...
Inherited by LayerChunk< L, C >.
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 | |
AbstractChunkBasedDataLayer | abstractLayer [get] |
The layer for this chunk type. In derived classes 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. | |
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. | |
Internal. Non-generic class that LayerChunk inherits from.
|
virtual |
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:
|
virtual |
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.
override string ToString | ( | ) |
Example output: "[TerrainChunk (3,-4) level 0]".
|
getabstract |
The layer for this chunk type. In derived classes the layer property can be used instead.
Implements ILC.
|
get |
The bounds in world space units of this chunk.
Based on worldOffset and layer.chunkSize.
Implements ILC.
|
getset |
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.
|
getset |
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.
|
get |
The position in world space units of the lower left corner of this chunk.
Based on index * layer.chunkSize.