C# Class ByChance.Core.Chunk

Main building block that makes up a level.

Chunks are created based on pre-defined chunk templates and define the positions of all contexts and anchors associated with the chunk, as well as attributes that are required for the level generation process such as the probability of a chunk being picked to be added next.

The concrete 2D and 3D implementations of this base class hold additional information regarding their absolute position within the level and their size.

Show file Open project: npruehs/bychance Class Usage Examples

Public Methods

Method Description
GetAlignedContextCount ( ) : int

Gets the total number of aligned (used) contexts of this chunk.

GetAnchor ( int index ) : Anchor

Gets the anchor with the specified chunk-wide unique index.

GetContext ( int index ) : Context

Gets the context with the specified chunk-wide unique index.

RemoveContext ( Context context ) : bool

Removes passed context from the chunk's list of contexts.

Protected Methods

Method Description
Chunk ( ChunkTemplate template ) : System

Constructs a new, empty chunk with a reference to the passed chunk template.

Private Methods

Method Description
Rotate ( ) : bool

Rotates the chunk by 90°.

Actual rotation algorithm is implemented by the concrete 2D and 3D chunk classes.

Method Details

Chunk() protected method

Constructs a new, empty chunk with a reference to the passed chunk template.
is null.
protected Chunk ( ChunkTemplate template ) : System
template ChunkTemplate Chunk template the new chunk will be based on.
return System

GetAlignedContextCount() public method

Gets the total number of aligned (used) contexts of this chunk.
public GetAlignedContextCount ( ) : int
return int

GetAnchor() public method

Gets the anchor with the specified chunk-wide unique index.
public GetAnchor ( int index ) : Anchor
index int Index of the anchor to get.
return Anchor

GetContext() public method

Gets the context with the specified chunk-wide unique index.
public GetContext ( int index ) : Context
index int Index of the context to get.
return Context

RemoveContext() public method

Removes passed context from the chunk's list of contexts.
is null.
public RemoveContext ( Context context ) : bool
context Context Context to be removed.
return bool