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

Represents a single piece. More...

#include <PiecePool.h>

Inheritance diagram for cPiece:
Inheritance graph
[legend]

Classes

struct  cConnector
 
class  cPieceModifier
 Base class (interface) for piece modifiers. More...
 
class  cVerticalLimit
 Base class (interface) for the vertical limit of piece placement. More...
 
class  cVerticalStrategy
 Base class (interface) for strategies for placing the starting pieces vertically. More...
 

Public Types

typedef std::vector< cConnectorcConnectors
 
typedef std::shared_ptr< cPieceModifiercPieceModifierPtr
 
typedef std::vector< cPieceModifierPtrcPieceModifiers
 
typedef std::shared_ptr< cVerticalLimitcVerticalLimitPtr
 
typedef std::shared_ptr< cVerticalStrategycVerticalStrategyPtr
 

Public Member Functions

virtual bool CanRotateCCW (int a_NumRotations) const =0
 Returns true if the piece can be rotated CCW the specific number of 90-degree turns. More...
 
virtual cConnectors GetConnectors (void) const =0
 Returns all of the available connectors that the piece has. More...
 
virtual cCuboid GetHitBox (void) const =0
 Returns the "hitbox" of this piece. More...
 
cPieceModifiers GetModifiers (void) const
 
virtual Vector3i GetSize (void) const =0
 Returns the dimensions of this piece. More...
 
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 ()
 

Public Attributes

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

Detailed Description

Represents a single piece.

Can have multiple connectors of different types where other pieces can connect.

Definition at line 20 of file PiecePool.h.

Member Typedef Documentation

◆ cConnectors

typedef std::vector<cConnector> cPiece::cConnectors

Definition at line 95 of file PiecePool.h.

◆ cPieceModifierPtr

typedef std::shared_ptr<cPieceModifier> cPiece::cPieceModifierPtr

Definition at line 174 of file PiecePool.h.

◆ cPieceModifiers

Definition at line 176 of file PiecePool.h.

◆ cVerticalLimitPtr

typedef std::shared_ptr<cVerticalLimit> cPiece::cVerticalLimitPtr

Definition at line 148 of file PiecePool.h.

◆ cVerticalStrategyPtr

Definition at line 121 of file PiecePool.h.

Constructor & Destructor Documentation

◆ ~cPiece()

virtual cPiece::~cPiece ( )
inlinevirtual

Definition at line 24 of file PiecePool.h.

Member Function Documentation

◆ CanRotateCCW()

virtual bool cPiece::CanRotateCCW ( int  a_NumRotations) const
pure virtual

Returns true if the piece can be rotated CCW the specific number of 90-degree turns.

Implemented in cPrefab.

◆ GetConnectors()

virtual cConnectors cPiece::GetConnectors ( void  ) const
pure virtual

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.

Implemented in cPrefab.

◆ GetHitBox()

virtual cCuboid cPiece::GetHitBox ( void  ) const
pure virtual

Returns the "hitbox" of this piece.

A hitbox is what is compared and must not intersect other pieces' hitboxes when generating.

Implemented in cPrefab.

◆ GetModifiers()

cPieceModifiers cPiece::GetModifiers ( void  ) const
inline

Definition at line 228 of file PiecePool.h.

◆ GetSize()

virtual Vector3i cPiece::GetSize ( void  ) const
pure virtual

Returns the dimensions of this piece.

The dimensions cover the entire piece, there is no block that the piece generates outside of this size.

Implemented in cPrefab.

◆ GetStartingPieceHeight()

int cPiece::GetStartingPieceHeight ( int  a_BlockX,
int  a_BlockZ 
)
inline

Returns the height, based on m_VerticalStrategy, for this piece when used as the starting piece.

If there's no strategy assigned to this piece, returns -1.

Definition at line 204 of file PiecePool.h.

◆ GetVerticalLimit()

cVerticalLimitPtr cPiece::GetVerticalLimit ( void  ) const
inline

Definition at line 223 of file PiecePool.h.

◆ GetVerticalStrategy()

cVerticalStrategyPtr cPiece::GetVerticalStrategy ( void  ) const
inline

Definition at line 218 of file PiecePool.h.

◆ RotateHitBoxToConnector()

cCuboid cPiece::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.

Definition at line 152 of file PiecePool.cpp.

◆ RotateMoveConnector()

cPiece::cConnector cPiece::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.

Definition at line 107 of file PiecePool.cpp.

◆ RotateMoveHitBox()

cCuboid cPiece::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.

Definition at line 168 of file PiecePool.cpp.

◆ RotatePos()

Vector3i cPiece::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.

Definition at line 73 of file PiecePool.cpp.

◆ SetPieceModifiersFromString()

bool cPiece::SetPieceModifiersFromString ( const AString a_Definition,
bool  a_LogWarnings 
)

Sets the modifiers with their params in the string.

If a_LogWarnings is true, logs the parsing problems into the server console. Returns true if successful, false if strategy parsing failed (no strategy assigned).

Definition at line 50 of file PiecePool.cpp.

◆ SetVerticalLimitFromString()

bool cPiece::SetVerticalLimitFromString ( const AString a_LimitDesc,
bool  a_LogWarnings 
)

Sets the vertical limit based on the description string.

Returns true if successful, false if limit parsing failed (no limit assigned). If a_LogWarnings is true, any problem is reported into the server console.

Definition at line 35 of file PiecePool.cpp.

◆ SetVerticalStrategy()

void cPiece::SetVerticalStrategy ( cVerticalStrategyPtr  a_VerticalStrategy)
inline

Definition at line 213 of file PiecePool.h.

◆ SetVerticalStrategyFromString()

bool cPiece::SetVerticalStrategyFromString ( const AString a_StrategyDesc,
bool  a_LogWarnings 
)

Sets the vertical strategy based on the description in the string.

If a_LogWarnings is true, logs the parsing problems into the server console. Returns true if successful, false if strategy parsing failed (no strategy assigned).

Definition at line 20 of file PiecePool.cpp.

Member Data Documentation

◆ m_Modifiers

cPieceModifiers cPiece::m_Modifiers

The modifiers which are modifying piece's blocks.

Definition at line 185 of file PiecePool.h.

◆ m_VerticalLimit

cVerticalLimitPtr cPiece::m_VerticalLimit

The checker that verifies each placement's vertical position.

Definition at line 182 of file PiecePool.h.

◆ m_VerticalStrategy

cVerticalStrategyPtr cPiece::m_VerticalStrategy

The strategy used for vertical placement of this piece when it is used as a starting piece.

Definition at line 179 of file PiecePool.h.


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