Cuberite
A lightweight, fast and extensible game server for Minecraft
Public Member Functions | Protected Member Functions | Protected Attributes | Private Types | List of all members
cVillageGen::cVillage Class Reference
Inheritance diagram for cVillageGen::cVillage:
Inheritance graph
[legend]
Collaboration diagram for cVillageGen::cVillage:
Collaboration graph
[legend]

Public Member Functions

 cVillage (int a_Seed, int a_GridX, int a_GridZ, int a_OriginX, int a_OriginZ, int a_MaxRoadDepth, int a_MaxSize, int a_Density, cVillagePiecePool &a_Prefabs, cTerrainHeightGen &a_HeightGen)
 
- Public Member Functions inherited from cGridStructGen::cStructure
 cStructure (int a_GridX, int a_GridZ, int a_OriginX, int a_OriginZ)
 Creates a structure that has its origin set at the specified coords. More...
 
virtual size_t GetCacheCost (void) const
 Returns the cost of keeping this structure in the cache. More...
 
virtual ~cStructure ()
 

Protected Member Functions

virtual void DrawIntoChunk (cChunkDesc &a_Chunk) override
 Draws self into the specified chunk. More...
 
void DrawRoad (cChunkDesc &a_Chunk, cPlacedPiece &a_Road, cChunkDef::HeightMap &a_HeightMap)
 Draws the road into the chunk. More...
 
virtual cPieces GetPiecesWithConnector (int a_ConnectorType) override
 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) override
 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) override
 Returns the pieces that should be used as the starting point. More...
 
virtual int GetStartingPieceWeight (const cPiece &a_NewPiece) override
 Returns the relative weight with which the a_NewPiece is to be selected for placing as the first piece. More...
 
void MoveAllDescendants (cPlacedPieces &a_PlacedPieces, size_t a_Pivot, int a_HeightDifference)
 
virtual void PiecePlaced (const cPiece &a_Piece) override
 Called after a piece is placed, to notify the pool that it has been used. More...
 
void PlacePieceOnGround (cPlacedPiece &a_Piece)
 Adjusts the Y coord of the given piece so that the piece is on the ground. More...
 
virtual void Reset (void) override
 Called when the pool has finished the current structure and should reset any piece-counters it has for a new structure. More...
 
- Protected Member Functions inherited from cPiecePool
virtual ~cPiecePool ()
 

Protected Attributes

cCuboid m_Borders
 Borders of the village - no item may reach out of this cuboid. More...
 
int m_Density
 The density for this village. More...
 
cTerrainHeightGenm_HeightGen
 The underlying height generator, used for placing the structures on top of the terrain. More...
 
int m_MaxSize
 Maximum size, in X / Z blocks, of the village (radius from the origin) More...
 
cNoise m_Noise
 The noise used as a pseudo-random generator. More...
 
cPlacedPieces m_Pieces
 The village pieces, placed by the generator. More...
 
cVillagePiecePoolm_Prefabs
 Prefabs to use for buildings. More...
 
int m_Seed
 Seed for the random functions. More...
 

Private Types

using Super = cGridStructGen::cStructure
 

Additional Inherited Members

- Public Attributes inherited from cGridStructGen::cStructure
int m_GridX
 The grid point for which the structure is generated. More...
 
int m_GridZ
 
int m_OriginX
 The origin (the coords for which the structure is generated) More...
 
int m_OriginZ
 

Detailed Description

Definition at line 112 of file VillageGen.cpp.

Member Typedef Documentation

◆ Super

Definition at line 116 of file VillageGen.cpp.

Constructor & Destructor Documentation

◆ cVillage()

cVillageGen::cVillage::cVillage ( int  a_Seed,
int  a_GridX,
int  a_GridZ,
int  a_OriginX,
int  a_OriginZ,
int  a_MaxRoadDepth,
int  a_MaxSize,
int  a_Density,
cVillagePiecePool a_Prefabs,
cTerrainHeightGen a_HeightGen 
)
inline

Definition at line 120 of file VillageGen.cpp.

Member Function Documentation

◆ DrawIntoChunk()

virtual void cVillageGen::cVillage::DrawIntoChunk ( cChunkDesc a_ChunkDesc)
inlineoverrideprotectedvirtual

Draws self into the specified chunk.

Implements cGridStructGen::cStructure.

Definition at line 179 of file VillageGen.cpp.

◆ DrawRoad()

void cVillageGen::cVillage::DrawRoad ( cChunkDesc a_Chunk,
cPlacedPiece a_Road,
cChunkDef::HeightMap a_HeightMap 
)
inlineprotected

Draws the road into the chunk.

The heightmap is not queried from the heightgen, but is given via parameter, so that it may be queried just once for all roads in a chunk.

Definition at line 224 of file VillageGen.cpp.

◆ GetPiecesWithConnector()

virtual cPieces cVillageGen::cVillage::GetPiecesWithConnector ( int  a_ConnectorType)
inlineoverrideprotectedvirtual

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.

Implements cPiecePool.

Definition at line 255 of file VillageGen.cpp.

◆ GetPieceWeight()

virtual int cVillageGen::cVillage::GetPieceWeight ( const cPlacedPiece a_PlacedPiece,
const cPiece::cConnector a_ExistingConnector,
const cPiece a_NewPiece 
)
inlineoverrideprotectedvirtual

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 from cPiecePool.

Definition at line 267 of file VillageGen.cpp.

◆ GetStartingPieces()

virtual cPieces cVillageGen::cVillage::GetStartingPieces ( void  )
inlineoverrideprotectedvirtual

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

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

Implements cPiecePool.

Definition at line 261 of file VillageGen.cpp.

◆ GetStartingPieceWeight()

virtual int cVillageGen::cVillage::GetStartingPieceWeight ( const cPiece a_NewPiece)
inlineoverrideprotectedvirtual

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 from cPiecePool.

Definition at line 289 of file VillageGen.cpp.

◆ MoveAllDescendants()

void cVillageGen::cVillage::MoveAllDescendants ( cPlacedPieces a_PlacedPieces,
size_t  a_Pivot,
int  a_HeightDifference 
)
inlineprotected

Definition at line 307 of file VillageGen.cpp.

◆ PiecePlaced()

virtual void cVillageGen::cVillage::PiecePlaced ( const cPiece a_Piece)
inlineoverrideprotectedvirtual

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.

Implements cPiecePool.

Definition at line 295 of file VillageGen.cpp.

◆ PlacePieceOnGround()

void cVillageGen::cVillage::PlacePieceOnGround ( cPlacedPiece a_Piece)
inlineprotected

Adjusts the Y coord of the given piece so that the piece is on the ground.

Ground level is assumed to be represented by the first connector in the piece.

Definition at line 206 of file VillageGen.cpp.

◆ Reset()

virtual void cVillageGen::cVillage::Reset ( void  )
inlineoverrideprotectedvirtual

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

Implements cPiecePool.

Definition at line 301 of file VillageGen.cpp.

Member Data Documentation

◆ m_Borders

cCuboid cVillageGen::cVillage::m_Borders
protected

Borders of the village - no item may reach out of this cuboid.

Definition at line 166 of file VillageGen.cpp.

◆ m_Density

int cVillageGen::cVillage::m_Density
protected

The density for this village.

Used to refrain from populating all house connectors. Range [0, 100]

Definition at line 163 of file VillageGen.cpp.

◆ m_HeightGen

cTerrainHeightGen& cVillageGen::cVillage::m_HeightGen
protected

The underlying height generator, used for placing the structures on top of the terrain.

Definition at line 172 of file VillageGen.cpp.

◆ m_MaxSize

int cVillageGen::cVillage::m_MaxSize
protected

Maximum size, in X / Z blocks, of the village (radius from the origin)

Definition at line 160 of file VillageGen.cpp.

◆ m_Noise

cNoise cVillageGen::cVillage::m_Noise
protected

The noise used as a pseudo-random generator.

Definition at line 157 of file VillageGen.cpp.

◆ m_Pieces

cPlacedPieces cVillageGen::cVillage::m_Pieces
protected

The village pieces, placed by the generator.

Definition at line 175 of file VillageGen.cpp.

◆ m_Prefabs

cVillagePiecePool& cVillageGen::cVillage::m_Prefabs
protected

Prefabs to use for buildings.

Definition at line 169 of file VillageGen.cpp.

◆ m_Seed

int cVillageGen::cVillage::m_Seed
protected

Seed for the random functions.

Definition at line 154 of file VillageGen.cpp.


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