Cuberite
A lightweight, fast and extensible game server for Minecraft
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
cPiece::cConnector Struct Reference

#include <PiecePool.h>

Collaboration diagram for cPiece::cConnector:
Collaboration graph
[legend]

Public Types

enum  eDirection {
  dirXM = BLOCK_FACE_XM , dirXP = BLOCK_FACE_XP , dirYM = BLOCK_FACE_YM , dirYP = BLOCK_FACE_YP ,
  dirZM = BLOCK_FACE_ZM , dirZP = BLOCK_FACE_ZP , dirYM_XM_ZM = BLOCK_FACE_MAX + 1 , dirYM_XM_ZP ,
  dirYM_XP_ZM , dirYM_XP_ZP , dirYP_XM_ZM , dirYP_XM_ZP ,
  dirYP_XP_ZM , dirYP_XP_ZP
}
 

Public Member Functions

 cConnector (const Vector3i &a_Pos, int a_Type, eDirection a_Direction)
 
 cConnector (int a_X, int a_Y, int a_Z, int a_Type, eDirection a_Direction)
 

Static Public Member Functions

static Vector3i AddDirection (const Vector3i &a_Pos, eDirection a_Direction)
 Returns the position of the block that has the specified direction from the specified position. More...
 
static const char * DirectionToString (eDirection a_Direction)
 Returns the string representation of the direction. More...
 
static int GetNumCCWRotationsToFit (eDirection a_FixedDir, eDirection a_RotatingDir)
 Returns the number of CCW rotations that a_RotatingDir requires in order to be the counter-direction of a_FixedDir. More...
 
static bool IsValidDirection (int a_Direction)
 Returns true if the specified number corresponds to a valid eDirection. More...
 
static eDirection RotateDirection (eDirection a_Direction)
 Returns the direction corresponding to the given direction rotated 180 degrees around the Y axis. More...
 
static eDirection RotateDirectionCCW (eDirection a_Direction)
 Returns the direction corresponding to the given direction rotated 90 degrees CCW around the Y axis. More...
 
static eDirection RotateDirectionCW (eDirection a_Direction)
 Returns the direction corresponding to the given direction rotated 90 degrees CW around the Y axis. More...
 
static bool StringToDirection (const AString &a_Value, eDirection &a_Out)
 Converts the string representation of a direction into the eDirection enum value. More...
 

Public Attributes

eDirection m_Direction
 Direction in which the connector is facing. More...
 
Vector3i m_Pos
 Position relative to the piece. More...
 
int m_Type
 Type of the connector. More...
 

Detailed Description

Definition at line 26 of file PiecePool.h.

Member Enumeration Documentation

◆ eDirection

Enumerator
dirXM 
dirXP 
dirYM 
dirYP 
dirZM 
dirZP 
dirYM_XM_ZM 
dirYM_XM_ZP 
dirYM_XP_ZM 
dirYM_XP_ZP 
dirYP_XM_ZM 
dirYP_XM_ZP 
dirYP_XP_ZM 
dirYP_XP_ZP 

Definition at line 28 of file PiecePool.h.

Constructor & Destructor Documentation

◆ cConnector() [1/2]

cPiece::cConnector::cConnector ( int  a_X,
int  a_Y,
int  a_Z,
int  a_Type,
eDirection  a_Direction 
)

Definition at line 186 of file PiecePool.cpp.

◆ cConnector() [2/2]

cPiece::cConnector::cConnector ( const Vector3i a_Pos,
int  a_Type,
eDirection  a_Direction 
)

Definition at line 197 of file PiecePool.cpp.

Member Function Documentation

◆ AddDirection()

Vector3i cPiece::cConnector::AddDirection ( const Vector3i a_Pos,
eDirection  a_Direction 
)
static

Returns the position of the block that has the specified direction from the specified position.

Similar to AddFaceDirection()

Definition at line 208 of file PiecePool.cpp.

◆ DirectionToString()

const char * cPiece::cConnector::DirectionToString ( eDirection  a_Direction)
static

Returns the string representation of the direction.

For debugging purposes.

Definition at line 234 of file PiecePool.cpp.

◆ GetNumCCWRotationsToFit()

int cPiece::cConnector::GetNumCCWRotationsToFit ( eDirection  a_FixedDir,
eDirection  a_RotatingDir 
)
static

Returns the number of CCW rotations that a_RotatingDir requires in order to be the counter-direction of a_FixedDir.

Ie. if you have a connector with a_FixedDir and you're rotating a piece that has a connector with a_RotatingDir, how many CCW rotations it needs to make the connectors compatible. Returns -1 if it is impossible to fit the two directions.

Definition at line 370 of file PiecePool.cpp.

◆ IsValidDirection()

bool cPiece::cConnector::IsValidDirection ( int  a_Direction)
static

Returns true if the specified number corresponds to a valid eDirection.

Definition at line 260 of file PiecePool.cpp.

◆ RotateDirection()

cPiece::cConnector::eDirection cPiece::cConnector::RotateDirection ( eDirection  a_Direction)
static

Returns the direction corresponding to the given direction rotated 180 degrees around the Y axis.

Definition at line 289 of file PiecePool.cpp.

◆ RotateDirectionCCW()

cPiece::cConnector::eDirection cPiece::cConnector::RotateDirectionCCW ( eDirection  a_Direction)
static

Returns the direction corresponding to the given direction rotated 90 degrees CCW around the Y axis.

Definition at line 316 of file PiecePool.cpp.

◆ RotateDirectionCW()

cPiece::cConnector::eDirection cPiece::cConnector::RotateDirectionCW ( eDirection  a_Direction)
static

Returns the direction corresponding to the given direction rotated 90 degrees CW around the Y axis.

Definition at line 343 of file PiecePool.cpp.

◆ StringToDirection()

bool cPiece::cConnector::StringToDirection ( const AString a_Value,
eDirection a_Out 
)
static

Converts the string representation of a direction into the eDirection enum value.

Returns true if successful, false on failure. Accepts both numbers and string representations such as "x+" or "Y+X-Z+".

Definition at line 401 of file PiecePool.cpp.

Member Data Documentation

◆ m_Direction

eDirection cPiece::cConnector::m_Direction

Direction in which the connector is facing.

Will be matched by the opposite direction for the connecting connector.

Definition at line 58 of file PiecePool.h.

◆ m_Pos

Vector3i cPiece::cConnector::m_Pos

Position relative to the piece.

Definition at line 50 of file PiecePool.h.

◆ m_Type

int cPiece::cConnector::m_Type

Type of the connector.

Any arbitrary number; the generator connects only connectors of opposite (negative) types.

Definition at line 54 of file PiecePool.h.


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