18 #include "../BlockArea.h"
110 cPrefab(
const AString & a_BlockDefinitions,
const AString & a_BlockData,
int a_SizeX,
int a_SizeY,
int a_SizeZ);
221 virtual bool CanRotateCCW(
int a_NumRotations)
const override;
unsigned char NIBBLETYPE
The datatype used by nibbledata (meta, light, skylight)
unsigned char BLOCKTYPE
The datatype used by blockdata.
eMergeStrategy
The per-block strategy to use when merging another block area into this object.
Represents a single piece.
std::vector< cConnector > cConnectors
Represents a single piece that has been placed to specific coords in the world.
sBlockTypeDef CharMap[256]
Maps letters in the sDef::m_Image onto a sBlockTypeDef block type definition.
void SetMergeStrategy(cBlockArea::eMergeStrategy a_MergeStrategy)
Sets the merge strategy to be used when drawing the piece.
void SetMoveToGround(bool a_MoveToGround)
Sets the flag whether the prefab should be moved to ground level before being drawn.
void SetHitBox(const cCuboid &a_HitBox)
Sets the internal hitbox to the specified value.
bool ShouldMoveToGround(void) const
Returns whether the prefab should be moved Y-wise to ground before drawing, rather than staying at th...
virtual Vector3i GetSize(void) const override
Returns the dimensions of this piece.
cDepthWeight m_DepthWeight
Chances of this piece being used, per depth of the generated piece tree.
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 i...
int m_AllowedRotations
Bitmask, bit N set -> N rotations CCW supported.
void SetExtendFloorStrategy(eExtendFloorStrategy a_Strategy)
Sets the strategy to use between the bottom of the prefab and the terrain top.
void ParseConnectors(const char *a_ConnectorsDef)
Parses the connectors definition text into m_Connectors member.
void ParseDepthWeight(const char *a_DepthWeightDef)
Parses the per-depth weight into m_DepthWeight member.
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.
cCuboid m_HitBox
The hitbox used for collision-checking between prefabs.
int m_DefaultWeight
Chance of this piece being used, if no other modifier is active.
void SetAllowedRotations(int a_AllowedRotations)
Sets the m_AllowedRotations bitmask and fills the m_BlockArea[] with rotated versions of m_BlockArea[...
Vector3i m_Size
The size of the prefab.
virtual bool CanRotateCCW(int a_NumRotations) const override
Returns true if the piece can be rotated CCW the specific number of 90-degree turns.
void SetAddWeightIfSame(int a_AddWeightIfSame)
Sets the AddWeightIfSame member, that is used to modify the weight when the previous piece is the sam...
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.
cBlockArea m_BlockArea[4]
The cBlockArea that contains the block definitions for the prefab.
cConnectors m_Connectors
The connectors through which the piece connects to other pieces.
virtual cConnectors GetConnectors(void) const override
Returns all of the available connectors that the piece has.
cPrefab(const sDef &a_Def)
Creates a prefab from the provided definition.
int GetDefaultWeight(void) const
Returns the unmodified DefaultWeight property for the piece.
void AddRotatedBlockAreas(void)
Based on the m_AllowedRotations, adds rotated cBlockAreas to the m_BlockArea array.
eExtendFloorStrategy
How to handle the space between the prefab bottom and the terrain top.
@ efsRepeatBottomTillSolid
Repeat the bottom-most block down until the first solid block; non-solids are overwritten.
@ efsRepeatBottomTillNonAir
Repeat the bottom-most block down until the first non-air block.
@ efsNone
No processing, the prefab is left "floating in the air".
void SetDefaultWeight(int a_DefaultWeight)
Sets the (unmodified) DefaultWeight property for this piece.
int m_AddWeightIfSame
The weight to add to this piece's base per-depth chance if the previous piece is the same.
cBlockArea::eMergeStrategy m_MergeStrategy
The merge strategy to use when drawing the prefab into a block area.
eExtendFloorStrategy m_ExtendFloorStrategy
How the prefab should handle not being on top of the ground.
virtual cCuboid GetHitBox(void) const override
Returns the "hitbox" of this piece.
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 C...
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 pi...
std::map< int, int > cDepthWeight
Maps generator tree depth to weight.
bool m_MoveToGround
If true, the piece will be moved Y-wise so that its first connector is sitting on the terrain.
bool HasConnectorType(int a_ConnectorType) const
Returns true if the prefab has any connector of the specified type.
const char * m_Connectors
List of connectors.
const char * m_CharMap
The mapping between characters in m_Image and the blocktype / blockmeta.
int m_AllowedRotations
Bitmask specifying the allowed rotations.
cBlockArea::eMergeStrategy m_MergeStrategy
The merge strategy to use while drawing the prefab.
int m_DefaultWeight
Chance of this piece being used, if no other modifier is active.
const char * m_DepthWeight
Chances of this piece being used, per depth of the generated piece tree.
int m_AddWeightIfSame
The weight to add to this piece's base per-depth chance if the previous piece is the same.
const char * m_Image
The actual image to be used for the prefab.
int m_HitboxMinX
The hitbox used for collision-checking between prefabs.
bool m_MoveToGround
If true, the piece will be moved Y-wise so that its first connector is sitting on the terrain.
eExtendFloorStrategy m_ExtendFloorStrategy
How the prefab should handle not being on top of the ground.
Packs complete definition of a single block, for per-letter assignment.