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

Public Member Functions

void AddRoadPieces (void)
 
 cVillagePiecePool (const cPrefab::sDef *a_PieceDefs, size_t a_NumPieceDefs, const cPrefab::sDef *a_StartingPieceDefs, size_t a_NumStartingPieceDefs)
 
 cVillagePiecePool (void)
 
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...
 
- Public Member Functions inherited from cPrefabPiecePool
void AddPieceDefs (const cPrefab::sDef *a_PieceDefs, size_t a_NumPieceDefs)
 Adds pieces from the specified definitions into m_AllPieces. More...
 
void AddStartingPieceDefs (const cPrefab::sDef *a_StartingPieceDefs, size_t a_NumStartingPieceDefs, int a_DefaultPieceHeight=-1)
 Adds pieces from the specified definitions into m_StartingPieces. More...
 
void AssignGens (int a_Seed, cBiomeGen &a_BiomeGen, cTerrainHeightGen &a_HeightGen, int a_SeaLevel)
 Called when the piece pool is assigned to a generator, so that the individual starting pieces' vertical strategies may bind to the underlying subgenerators. More...
 
void Clear (void)
 Removes and frees all pieces from this pool. More...
 
 cPrefabPiecePool (const cPrefab::sDef *a_PieceDefs, size_t a_NumPieceDefs, const cPrefab::sDef *a_StartingPieceDefs, size_t a_NumStartingPieceDefs, int a_DefaultStartingPieceHeight=-1)
 Creates a piece pool with prefabs from the specified definitions. More...
 
 cPrefabPiecePool (void)
 Creates an empty instance. More...
 
const AStringMapGetAllMetadata (void) const
 
size_t GetAllPiecesCount (void) const
 Returns the number of regular (non-starting) pieces. More...
 
const AStringGetIntendedUse (void) const
 
int GetMaxDensity (void) const
 
AString GetMetadata (const AString &a_ParamName) const
 Returns the specified value from the metadata map. More...
 
int GetMinDensity (void) const
 
virtual cPieces GetPiecesWithConnector (int a_ConnectorType) override
 Returns a list of pieces that contain the specified connector type. More...
 
virtual cPieces GetStartingPieces (void) override
 Returns the pieces that should be used as the starting point. More...
 
size_t GetStartingPiecesCount (void) const
 Returns the number of starting pieces. 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...
 
NIBBLETYPE GetVillageRoadBlockMeta (void) const
 
BLOCKTYPE GetVillageRoadBlockType (void) const
 
NIBBLETYPE GetVillageWaterRoadBlockMeta (void) const
 
BLOCKTYPE GetVillageWaterRoadBlockType (void) const
 
bool IsBiomeAllowed (EMCSBiome a_Biome) const
 Returns true if a_Biome is among the accepted biomes in the m_AcceptedBiomes metadata member. More...
 
bool LoadFromCubeset (const AString &a_Contents, const AString &a_FileName, bool a_LogWarnings)
 Loads the pieces from the specified string containing Cubeset file data. More...
 
bool LoadFromFile (const AString &a_FileName, bool a_LogWarnings)
 Loads the pieces from the specified file. More...
 
bool LoadFromString (const AString &a_Contents, const AString &a_FileName, bool a_LogWarnings)
 Loads the pieces from the specified string. More...
 
virtual void PiecePlaced (const cPiece &a_Piece) override
 Called after a piece is placed, to notify the pool that it has been used. 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...
 
virtual ~cPrefabPiecePool () override
 Destroys the pool, freeing all pieces. More...
 
- Public Member Functions inherited from cPiecePool
virtual ~cPiecePool ()
 

Private Types

using Super = cPrefabPiecePool
 

Additional Inherited Members

- Protected Types inherited from cPrefabPiecePool
typedef std::map< int, cPiecescPiecesMap
 The type used to map a connector type to the list of pieces with that connector. More...
 
- Protected Member Functions inherited from cPrefabPiecePool
void AddToPerConnectorMap (cPrefab *a_Prefab)
 Adds the prefab to the m_PiecesByConnector map for all its connectors. More...
 
void ApplyBaseMetadataCubesetVer1 (const AString &a_FileName, bool a_LogWarnings)
 Applies the base known metadata from the m_Metadata map into this pool. More...
 
bool LoadCubesetPieceVer1 (const AString &a_FileName, cLuaState &a_LuaState, int a_PieceIndex, bool a_LogWarnings)
 Loads a single piece from the cubeset file parsed into the specified Lua state. More...
 
bool LoadFromCubesetVer1 (const AString &a_FileName, cLuaState &a_LuaState, bool a_LogWarnings)
 Loads the pieces from the cubeset file parsed into the specified Lua state. More...
 
std::unique_ptr< cPrefabLoadPrefabFromCubesetVer1 (const AString &a_FileName, cLuaState &a_LuaState, const AString &a_PieceName, bool a_LogWarnings)
 Loads a single piece's prefab from the cubeset file parsed into the specified Lua state. More...
 
bool ReadConnectorsCubesetVer1 (const AString &a_FileName, cLuaState &a_LuaState, const AString &a_PieceName, cPrefab *a_Prefab, bool a_LogWarnings)
 Reads a single piece's connectors from the cubeset file parsed into the specified Lua state. More...
 
bool ReadPieceMetadataCubesetVer1 (const AString &a_FileName, cLuaState &a_LuaState, const AString &a_PieceName, cPrefab *a_Prefab, bool a_LogWarnings)
 Reads a single piece's metadata from the cubeset file parsed into the specified Lua state. More...
 
bool ReadPoolMetadataCubesetVer1 (const AString &a_FileName, cLuaState &a_LuaState, bool a_LogWarnings)
 Reads the metadata for the entire pool from the cubeset file, stores it in the m_Metadata map. More...
 
- Protected Attributes inherited from cPrefabPiecePool
std::unordered_set< EMCSBiome, BiomeHasherm_AllowedBiomes
 A set of allowed biomes for the pool. More...
 
cPieces m_AllPieces
 All the pieces that are allowed for building. More...
 
AString m_IntendedUse
 The intended use of this piece pool, as specified by the pool's metadata. More...
 
int m_MaxDensity
 The maximum density, as read from the metadata. More...
 
AStringMap m_Metadata
 A dictionary of pool-wide metadata, as read from the cubeset file. More...
 
int m_MinDensity
 The minimum density, as read from the metadata. More...
 
cPiecesMap m_PiecesByConnector
 The map that has all pieces by their connector types The pieces are copies out of m_AllPieces and shouldn't be ever delete-d. More...
 
cPieces m_StartingPieces
 The pieces that are used as starting pieces. More...
 
NIBBLETYPE m_VillageRoadBlockMeta
 The block meta to use for the village roads. More...
 
BLOCKTYPE m_VillageRoadBlockType
 The block type to use for the village roads. More...
 
NIBBLETYPE m_VillageWaterRoadBlockMeta
 The block meta used for the village roads if the road is on water. More...
 
BLOCKTYPE m_VillageWaterRoadBlockType
 The block type used for the village roads if the road is on water. More...
 

Detailed Description

Definition at line 40 of file VillageGen.cpp.

Member Typedef Documentation

◆ Super

Definition at line 43 of file VillageGen.cpp.

Constructor & Destructor Documentation

◆ cVillagePiecePool() [1/2]

cVillagePiecePool::cVillagePiecePool ( const cPrefab::sDef a_PieceDefs,
size_t  a_NumPieceDefs,
const cPrefab::sDef a_StartingPieceDefs,
size_t  a_NumStartingPieceDefs 
)
inline

Definition at line 47 of file VillageGen.cpp.

◆ cVillagePiecePool() [2/2]

cVillagePiecePool::cVillagePiecePool ( void  )
inline

Definition at line 56 of file VillageGen.cpp.

Member Function Documentation

◆ AddRoadPieces()

void cVillagePiecePool::AddRoadPieces ( void  )
inline

Definition at line 61 of file VillageGen.cpp.

◆ GetPieceWeight()

virtual int cVillagePiecePool::GetPieceWeight ( const cPlacedPiece a_PlacedPiece,
const cPiece::cConnector a_ExistingConnector,
const cPiece a_NewPiece 
)
inlineoverridevirtual

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 cPrefabPiecePool.

Definition at line 96 of file VillageGen.cpp.


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