Cuberite
A lightweight, fast and extensible game server for Minecraft
Public Member Functions | List of all members
cPiecePool Class Referenceabstract

This class is an interface that stores pieces for a generator. More...

#include <PiecePool.h>

Inheritance diagram for cPiecePool:
Inheritance graph
[legend]

Public Member Functions

virtual cPieces GetPiecesWithConnector (int a_ConnectorType)=0
 Returns a list of pieces that contain the specified connector type. More...
 
virtual int GetPieceWeight (const cPlacedPiece &a_PlacedPiece, const cPiece::cConnector &a_ExistingConnector, const cPiece &a_NewPiece)
 Returns the relative weight with which the a_NewPiece is to be selected for placing under a_PlacedPiece through a_ExistingConnector. More...
 
virtual cPieces GetStartingPieces (void)=0
 Returns the pieces that should be used as the starting point. More...
 
virtual int GetStartingPieceWeight (const cPiece &a_NewPiece)
 Returns the relative weight with which the a_NewPiece is to be selected for placing as the first piece. More...
 
virtual void PiecePlaced (const cPiece &a_Piece)=0
 Called after a piece is placed, to notify the pool that it has been used. More...
 
virtual void Reset (void)=0
 Called when the pool has finished the current structure and should reset any piece-counters it has for a new structure. More...
 
virtual ~cPiecePool ()
 

Detailed Description

This class is an interface that stores pieces for a generator.

Provides lists of pieces based on criteria (IsStarting, HasConnector). Provides per-piece weights for random distribution of individual pieces.

Definition at line 277 of file PiecePool.h.

Constructor & Destructor Documentation

◆ ~cPiecePool()

virtual cPiecePool::~cPiecePool ( )
inlinevirtual

Definition at line 281 of file PiecePool.h.

Member Function Documentation

◆ GetPiecesWithConnector()

virtual cPieces cPiecePool::GetPiecesWithConnector ( int  a_ConnectorType)
pure virtual

Returns a list of pieces that contain the specified connector type.

The cPiece pointers returned are managed by the pool and the caller doesn't free them.

Implemented in cVillageGen::cVillage, and cPrefabPiecePool.

◆ GetPieceWeight()

virtual int cPiecePool::GetPieceWeight ( const cPlacedPiece a_PlacedPiece,
const cPiece::cConnector a_ExistingConnector,
const cPiece a_NewPiece 
)
inlinevirtual

Returns the relative weight with which the a_NewPiece is to be selected for placing under a_PlacedPiece through a_ExistingConnector.

a_ExistingConnector is the original connector, before any movement or rotation is applied to it. This allows the pool to tweak the piece's chances, based on the previous pieces in the tree and the connector used. The higher the number returned, the higher the chance the piece will be chosen. 0 means the piece will never be chosen.

Reimplemented in cVillageGen::cVillage, cVillagePiecePool, and cPrefabPiecePool.

Definition at line 295 of file PiecePool.h.

◆ GetStartingPieces()

virtual cPieces cPiecePool::GetStartingPieces ( void  )
pure virtual

Returns the pieces that should be used as the starting point.

Multiple starting points are supported, one of the returned piece will be chosen.

Implemented in cVillageGen::cVillage, and cPrefabPiecePool.

◆ GetStartingPieceWeight()

virtual int cPiecePool::GetStartingPieceWeight ( const cPiece a_NewPiece)
inlinevirtual

Returns the relative weight with which the a_NewPiece is to be selected for placing as the first piece.

This allows the pool to tweak the piece's chances. The higher the number returned, the higher the chance the piece will be chosen. 0 means the piece will not be chosen. If all pieces return 0, a random piece is chosen, with all equal chances.

Reimplemented in cVillageGen::cVillage, and cPrefabPiecePool.

Definition at line 308 of file PiecePool.h.

◆ PiecePlaced()

virtual void cPiecePool::PiecePlaced ( const cPiece a_Piece)
pure virtual

Called after a piece is placed, to notify the pool that it has been used.

The pool may adjust the pieces it will return the next time.

Implemented in cVillageGen::cVillage, and cPrefabPiecePool.

◆ Reset()

virtual void cPiecePool::Reset ( void  )
pure virtual

Called when the pool has finished the current structure and should reset any piece-counters it has for a new structure.

Implemented in cVillageGen::cVillage, and cPrefabPiecePool.


The documentation for this class was generated from the following file: