diff options
author | Mattes D <github@xoft.cz> | 2014-05-31 19:11:13 +0200 |
---|---|---|
committer | Mattes D <github@xoft.cz> | 2014-05-31 19:11:13 +0200 |
commit | 6de45037c774f5fc748a4520b6f2afacdca94661 (patch) | |
tree | dc5908fdb33d679c05f10aa562ccbb107e7f3518 /src/Generating/PieceGenerator.h | |
parent | Merge pull request #951 from worktycho/chunksparsing/structs (diff) | |
parent | Updated PlainsVillage prefabs. (diff) | |
download | cuberite-6de45037c774f5fc748a4520b6f2afacdca94661.tar cuberite-6de45037c774f5fc748a4520b6f2afacdca94661.tar.gz cuberite-6de45037c774f5fc748a4520b6f2afacdca94661.tar.bz2 cuberite-6de45037c774f5fc748a4520b6f2afacdca94661.tar.lz cuberite-6de45037c774f5fc748a4520b6f2afacdca94661.tar.xz cuberite-6de45037c774f5fc748a4520b6f2afacdca94661.tar.zst cuberite-6de45037c774f5fc748a4520b6f2afacdca94661.zip |
Diffstat (limited to 'src/Generating/PieceGenerator.h')
-rw-r--r-- | src/Generating/PieceGenerator.h | 46 |
1 files changed, 39 insertions, 7 deletions
diff --git a/src/Generating/PieceGenerator.h b/src/Generating/PieceGenerator.h index 16bec3bb4..fd8576706 100644 --- a/src/Generating/PieceGenerator.h +++ b/src/Generating/PieceGenerator.h @@ -110,6 +110,7 @@ public: virtual cPieces GetStartingPieces(void) = 0; /** 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. */ @@ -119,6 +120,15 @@ public: const cPiece & a_NewPiece ) { return 1; } + /** Returns the relative weight with which the a_NewPiece is to be selected for placing as the first piece. + This allows the pool to tweak the piece's chances. + The higher the number returned, the higher the chance the piece will be chosen. 0 means the piece will not be chosen. + If all pieces return 0, a random piece is chosen, with all equal chances. + */ + virtual int GetStartingPieceWeight( + const cPiece & a_NewPiece + ) { return 1; } + /** Called after a piece is placed, to notify the pool that it has been used. The pool may adjust the pieces it will return the next time. */ virtual void PiecePlaced(const cPiece & a_Piece) = 0; @@ -138,19 +148,41 @@ class cPlacedPiece public: cPlacedPiece(const cPlacedPiece * a_Parent, const cPiece & a_Piece, const Vector3i & a_Coords, int a_NumCCWRotations); - const cPiece & GetPiece (void) const { return *m_Piece; } - const Vector3i & GetCoords (void) const { return m_Coords; } - int GetNumCCWRotations(void) const { return m_NumCCWRotations; } - const cCuboid & GetHitBox (void) const { return m_HitBox; } - int GetDepth (void) const { return m_Depth; } + const cPlacedPiece * GetParent (void) const { return m_Parent; } + const cPiece & GetPiece (void) const { return *m_Piece; } + const Vector3i & GetCoords (void) const { return m_Coords; } + int GetNumCCWRotations (void) const { return m_NumCCWRotations; } + const cCuboid & GetHitBox (void) const { return m_HitBox; } + int GetDepth (void) const { return m_Depth; } + bool HasBeenMovedToGround(void) const { return m_HasBeenMovedToGround; } + + /** Returns the coords as a modifiable object. */ + Vector3i & GetCoords(void) { return m_Coords; } + + /** Returns the connector at the specified index, rotated in the actual placement. + Undefined behavior if a_Index is out of range. */ + cPiece::cConnector GetRotatedConnector(size_t a_Index) const; + + /** Returns a copy of the specified connector, modified to account for the translation and rotation for + this placement. */ + cPiece::cConnector GetRotatedConnector(const cPiece::cConnector & a_Connector) const; + + /** Moves the placed piece Y-wise by the specified offset. + Sets m_HasBeenMovedToGround to true, too. + Used eg. by village houses. */ + void MoveToGroundBy(int a_OffsetY); protected: const cPlacedPiece * m_Parent; const cPiece * m_Piece; Vector3i m_Coords; int m_NumCCWRotations; - cCuboid m_HitBox; - int m_Depth; + cCuboid m_HitBox; // Hitbox of the placed piece, in world coords + int m_Depth; // Depth in the generated piece tree + + /** Set to true once the piece has been moved Y-wise. + Used eg. by village houses. */ + bool m_HasBeenMovedToGround; }; typedef std::vector<cPlacedPiece *> cPlacedPieces; |