Cuberite
A lightweight, fast and extensible game server for Minecraft
|
#include <Prefab.h>
Classes | |
struct | sBlockTypeDef |
Packs complete definition of a single block, for per-letter assignment. More... | |
struct | sDef |
Public Types | |
enum | eExtendFloorStrategy { efsNone , efsRepeatBottomTillNonAir , efsRepeatBottomTillSolid } |
How to handle the space between the prefab bottom and the terrain top. More... | |
Public Types inherited from cPiece | |
typedef std::vector< cConnector > | cConnectors |
typedef std::shared_ptr< cPieceModifier > | cPieceModifierPtr |
typedef std::vector< cPieceModifierPtr > | cPieceModifiers |
typedef std::shared_ptr< cVerticalLimit > | cVerticalLimitPtr |
typedef std::shared_ptr< cVerticalStrategy > | cVerticalStrategyPtr |
Public Member Functions | |
void | AddConnector (int a_RelX, int a_RelY, int a_RelZ, cPiece::cConnector::eDirection a_Direction, int a_Type) |
Adds the specified connector to the list of connectors this piece supports. More... | |
cPrefab (const AString &a_BlockDefinitions, const AString &a_BlockData, int a_SizeX, int a_SizeY, int a_SizeZ) | |
Creates a prefab based on the specified block data, using the char-to-block map in a_BlockDefinitions. More... | |
cPrefab (const cBlockArea &a_Image) | |
Creates a prefab based on the given BlockArea. More... | |
cPrefab (const cBlockArea &a_Image, int a_AllowedRotations) | |
Creates a prefab based on the given BlockArea and allowed rotations. More... | |
cPrefab (const sDef &a_Def) | |
Creates a prefab from the provided definition. More... | |
void | Draw (cChunkDesc &a_Dest, const cPlacedPiece *a_Placement) const |
Draws the prefab into the specified chunk, according to the placement stored in the PlacedPiece. More... | |
void | Draw (cChunkDesc &a_Dest, const Vector3i &a_Placement, int a_NumRotations) const |
Draws the prefab into the specified chunks, according to the specified placement and rotations. More... | |
int | GetDefaultWeight (void) const |
Returns the unmodified DefaultWeight property for the piece. More... | |
int | GetPieceWeight (const cPlacedPiece &a_PlacedPiece, const cPiece::cConnector &a_ExistingConnector) const |
Returns the weight (chance) of this prefab generating as the next piece after the specified placed piece. More... | |
bool | HasConnectorType (int a_ConnectorType) const |
Returns true if the prefab has any connector of the specified type. More... | |
void | ParseDepthWeight (const char *a_DepthWeightDef) |
Parses the per-depth weight into m_DepthWeight member. More... | |
void | SetAddWeightIfSame (int a_AddWeightIfSame) |
Sets the AddWeightIfSame member, that is used to modify the weight when the previous piece is the same prefab. More... | |
void | SetAllowedRotations (int a_AllowedRotations) |
Sets the m_AllowedRotations bitmask and fills the m_BlockArea[] with rotated versions of m_BlockArea[0]. More... | |
void | SetDefaultWeight (int a_DefaultWeight) |
Sets the (unmodified) DefaultWeight property for this piece. More... | |
void | SetExtendFloorStrategy (eExtendFloorStrategy a_Strategy) |
Sets the strategy to use between the bottom of the prefab and the terrain top. More... | |
void | SetHitBox (const cCuboid &a_HitBox) |
Sets the internal hitbox to the specified value. More... | |
void | SetMergeStrategy (cBlockArea::eMergeStrategy a_MergeStrategy) |
Sets the merge strategy to be used when drawing the piece. More... | |
void | SetMoveToGround (bool a_MoveToGround) |
Sets the flag whether the prefab should be moved to ground level before being drawn. More... | |
bool | ShouldMoveToGround (void) const |
Returns whether the prefab should be moved Y-wise to ground before drawing, rather than staying at the coords governed by the connectors. More... | |
Public Member Functions inherited from cPiece | |
cPieceModifiers | GetModifiers (void) const |
int | GetStartingPieceHeight (int a_BlockX, int a_BlockZ) |
Returns the height, based on m_VerticalStrategy, for this piece when used as the starting piece. More... | |
cVerticalLimitPtr | GetVerticalLimit (void) const |
cVerticalStrategyPtr | GetVerticalStrategy (void) const |
cCuboid | RotateHitBoxToConnector (const cConnector &a_MyConnector, const Vector3i &a_ToConnectorPos, int a_NumCCWRotations) const |
Returns the hitbox after the specified number of rotations and moved so that a_MyConnector is placed at a_ToConnectorPos. More... | |
cConnector | RotateMoveConnector (const cConnector &a_Connector, int a_NumCCWRotations, int a_MoveX, int a_MoveY, int a_MoveZ) const |
Returns a copy of the connector that is rotated and then moved by the specified amounts. More... | |
cCuboid | RotateMoveHitBox (int a_NumCCWRotations, int a_MoveX, int a_MoveY, int a_MoveZ) const |
Returns the hitbox after the specified number of CCW rotations and moved by the specified amounts. More... | |
Vector3i | RotatePos (const Vector3i &a_Pos, int a_NumCCWRotations) const |
Returns a copy of the a_Pos after rotating the piece the specified number of CCW rotations. More... | |
bool | SetPieceModifiersFromString (const AString &a_Definition, bool a_LogWarnings) |
Sets the modifiers with their params in the string. More... | |
bool | SetVerticalLimitFromString (const AString &a_LimitDesc, bool a_LogWarnings) |
Sets the vertical limit based on the description string. More... | |
void | SetVerticalStrategy (cVerticalStrategyPtr a_VerticalStrategy) |
bool | SetVerticalStrategyFromString (const AString &a_StrategyDesc, bool a_LogWarnings) |
Sets the vertical strategy based on the description in the string. More... | |
virtual | ~cPiece () |
Protected Types | |
typedef std::map< int, int > | cDepthWeight |
Maps generator tree depth to weight. More... | |
typedef sBlockTypeDef | CharMap[256] |
Maps letters in the sDef::m_Image onto a sBlockTypeDef block type definition. More... | |
Protected Member Functions | |
void | AddRotatedBlockAreas (void) |
Based on the m_AllowedRotations, adds rotated cBlockAreas to the m_BlockArea array. More... | |
virtual bool | CanRotateCCW (int a_NumRotations) const override |
Returns true if the piece can be rotated CCW the specific number of 90-degree turns. More... | |
virtual cConnectors | GetConnectors (void) const override |
Returns all of the available connectors that the piece has. More... | |
virtual cCuboid | GetHitBox (void) const override |
Returns the "hitbox" of this piece. More... | |
virtual Vector3i | GetSize (void) const override |
Returns the dimensions of this piece. More... | |
void | ParseBlockImage (const CharMap &a_CharMap, const char *a_BlockImage) |
Parses the Image in the definition into m_BlockArea[0]'s block types and metas, using the specified CharMap. More... | |
void | ParseCharMap (CharMap &a_CharMapOut, const char *a_CharMapDef) |
Parses the CharMap in the definition into a CharMap binary data used for translating the definition into BlockArea. More... | |
void | ParseConnectors (const char *a_ConnectorsDef) |
Parses the connectors definition text into m_Connectors member. More... | |
Protected Attributes | |
int | m_AddWeightIfSame |
The weight to add to this piece's base per-depth chance if the previous piece is the same. More... | |
int | m_AllowedRotations |
Bitmask, bit N set -> N rotations CCW supported. More... | |
cBlockArea | m_BlockArea [4] |
The cBlockArea that contains the block definitions for the prefab. More... | |
cConnectors | m_Connectors |
The connectors through which the piece connects to other pieces. More... | |
int | m_DefaultWeight |
Chance of this piece being used, if no other modifier is active. More... | |
cDepthWeight | m_DepthWeight |
Chances of this piece being used, per depth of the generated piece tree. More... | |
eExtendFloorStrategy | m_ExtendFloorStrategy |
How the prefab should handle not being on top of the ground. More... | |
cCuboid | m_HitBox |
The hitbox used for collision-checking between prefabs. More... | |
cBlockArea::eMergeStrategy | m_MergeStrategy |
The merge strategy to use when drawing the prefab into a block area. More... | |
bool | m_MoveToGround |
If true, the piece will be moved Y-wise so that its first connector is sitting on the terrain. More... | |
Vector3i | m_Size |
The size of the prefab. More... | |
Additional Inherited Members | |
Public Attributes inherited from cPiece | |
cPieceModifiers | m_Modifiers |
The modifiers which are modifying piece's blocks. More... | |
cVerticalLimitPtr | m_VerticalLimit |
The checker that verifies each placement's vertical position. More... | |
cVerticalStrategyPtr | m_VerticalStrategy |
The strategy used for vertical placement of this piece when it is used as a starting piece. More... | |
|
protected |
|
protected |
Maps letters in the sDef::m_Image onto a sBlockTypeDef block type definition.
How to handle the space between the prefab bottom and the terrain top.
cPrefab::cPrefab | ( | const sDef & | a_Def | ) |
Creates a prefab from the provided definition.
Definition at line 19 of file Prefab.cpp.
cPrefab::cPrefab | ( | const cBlockArea & | a_Image, |
int | a_AllowedRotations | ||
) |
Creates a prefab based on the given BlockArea and allowed rotations.
Definition at line 46 of file Prefab.cpp.
cPrefab::cPrefab | ( | const cBlockArea & | a_Image | ) |
Creates a prefab based on the given BlockArea.
Allowed rotations can be added later on using SetAllowedRotations().
Definition at line 65 of file Prefab.cpp.
cPrefab::cPrefab | ( | const AString & | a_BlockDefinitions, |
const AString & | a_BlockData, | ||
int | a_SizeX, | ||
int | a_SizeY, | ||
int | a_SizeZ | ||
) |
Creates a prefab based on the specified block data, using the char-to-block map in a_BlockDefinitions.
Allowed rotations can be added later on using SetAllowedRotations().
Definition at line 83 of file Prefab.cpp.
void cPrefab::AddConnector | ( | int | a_RelX, |
int | a_RelY, | ||
int | a_RelZ, | ||
cPiece::cConnector::eDirection | a_Direction, | ||
int | a_Type | ||
) |
Adds the specified connector to the list of connectors this piece supports.
Definition at line 320 of file Prefab.cpp.
|
protected |
Based on the m_AllowedRotations, adds rotated cBlockAreas to the m_BlockArea array.
To be called only from this class's constructor!
Definition at line 104 of file Prefab.cpp.
|
overrideprotectedvirtual |
Returns true if the piece can be rotated CCW the specific number of 90-degree turns.
Implements cPiece.
Definition at line 521 of file Prefab.cpp.
void cPrefab::Draw | ( | cChunkDesc & | a_Dest, |
const cPlacedPiece * | a_Placement | ||
) | const |
Draws the prefab into the specified chunk, according to the placement stored in the PlacedPiece.
Definition at line 133 of file Prefab.cpp.
void cPrefab::Draw | ( | cChunkDesc & | a_Dest, |
const Vector3i & | a_Placement, | ||
int | a_NumRotations | ||
) | const |
Draws the prefab into the specified chunks, according to the specified placement and rotations.
Definition at line 142 of file Prefab.cpp.
|
overrideprotectedvirtual |
Returns all of the available connectors that the piece has.
Each connector has a (relative) position in the piece, and a type associated with it.
Implements cPiece.
Definition at line 494 of file Prefab.cpp.
|
inline |
|
overrideprotectedvirtual |
Returns the "hitbox" of this piece.
A hitbox is what is compared and must not intersect other pieces' hitboxes when generating.
Implements cPiece.
Definition at line 512 of file Prefab.cpp.
int cPrefab::GetPieceWeight | ( | const cPlacedPiece & | a_PlacedPiece, |
const cPiece::cConnector & | a_ExistingConnector | ||
) | const |
Returns the weight (chance) of this prefab generating as the next piece after the specified placed piece.
PiecePool implementations can use this for their GetPieceWeight() implementations.
Definition at line 291 of file Prefab.cpp.
|
overrideprotectedvirtual |
Returns the dimensions of this piece.
The dimensions cover the entire piece, there is no block that the piece generates outside of this size.
Implements cPiece.
Definition at line 503 of file Prefab.cpp.
bool cPrefab::HasConnectorType | ( | int | a_ConnectorType | ) | const |
Returns true if the prefab has any connector of the specified type.
Definition at line 275 of file Prefab.cpp.
|
protected |
Parses the Image in the definition into m_BlockArea[0]'s block types and metas, using the specified CharMap.
Definition at line 378 of file Prefab.cpp.
|
protected |
Parses the CharMap in the definition into a CharMap binary data used for translating the definition into BlockArea.
Definition at line 339 of file Prefab.cpp.
|
protected |
Parses the connectors definition text into m_Connectors member.
Definition at line 400 of file Prefab.cpp.
void cPrefab::ParseDepthWeight | ( | const char * | a_DepthWeightDef | ) |
Parses the per-depth weight into m_DepthWeight member.
Definition at line 446 of file Prefab.cpp.
|
inline |
void cPrefab::SetAllowedRotations | ( | int | a_AllowedRotations | ) |
Sets the m_AllowedRotations bitmask and fills the m_BlockArea[] with rotated versions of m_BlockArea[0].
Definition at line 329 of file Prefab.cpp.
void cPrefab::SetDefaultWeight | ( | int | a_DefaultWeight | ) |
Sets the (unmodified) DefaultWeight property for this piece.
Definition at line 311 of file Prefab.cpp.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
protected |
|
protected |
|
protected |
The cBlockArea that contains the block definitions for the prefab.
The index identifies the number of CCW rotations applied (0 = no rotation, 1 = 1 CCW rotation, ...).
|
protected |
|
protected |
|
protected |
Chances of this piece being used, per depth of the generated piece tree.
The starting piece has a depth of 0, the pieces connected to it are depth 1, etc. The specified depth stands for the depth of the new piece (not the existing already-placed piece), so valid depths start at 1. Depths that are not specified will use the m_DefaultWeight value.
|
protected |
|
protected |
|
protected |
|
protected |