summaryrefslogtreecommitdiffstats
path: root/src/Generating/PieceGenerator.h
diff options
context:
space:
mode:
authordaniel0916 <theschokolps@gmail.com>2014-04-16 14:31:02 +0200
committerdaniel0916 <theschokolps@gmail.com>2014-04-16 14:31:02 +0200
commit5a9acb7eb6eef293dc53cfe916c74f5cfa069db4 (patch)
tree8e0b29c5f0240ac0961e69b905921243130d0258 /src/Generating/PieceGenerator.h
parentFixed merge conflict (diff)
parentAttempted fix for the client crash with the new protocols. (diff)
downloadcuberite-5a9acb7eb6eef293dc53cfe916c74f5cfa069db4.tar
cuberite-5a9acb7eb6eef293dc53cfe916c74f5cfa069db4.tar.gz
cuberite-5a9acb7eb6eef293dc53cfe916c74f5cfa069db4.tar.bz2
cuberite-5a9acb7eb6eef293dc53cfe916c74f5cfa069db4.tar.lz
cuberite-5a9acb7eb6eef293dc53cfe916c74f5cfa069db4.tar.xz
cuberite-5a9acb7eb6eef293dc53cfe916c74f5cfa069db4.tar.zst
cuberite-5a9acb7eb6eef293dc53cfe916c74f5cfa069db4.zip
Diffstat (limited to 'src/Generating/PieceGenerator.h')
-rw-r--r--src/Generating/PieceGenerator.h20
1 files changed, 19 insertions, 1 deletions
diff --git a/src/Generating/PieceGenerator.h b/src/Generating/PieceGenerator.h
index bef9d3463..f4433b947 100644
--- a/src/Generating/PieceGenerator.h
+++ b/src/Generating/PieceGenerator.h
@@ -85,6 +85,13 @@ typedef std::vector<cPiece *> cPieces;
+// fwd:
+class cPlacedPiece;
+
+
+
+
+
/** This class is an interface that provides pieces for the generator. It can keep track of what pieces were
placed and adjust the returned piece vectors. */
class cPiecePool
@@ -101,6 +108,16 @@ public:
Multiple starting points are supported, one of the returned piece will be chosen. */
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.
+ 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.
+ */
+ virtual int GetPieceWeight(
+ const cPlacedPiece & a_PlacedPiece,
+ const cPiece::cConnector & a_ExistingConnector,
+ 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;
@@ -157,8 +174,9 @@ protected:
cPiece * m_Piece; // The piece being connected
cPiece::cConnector m_Connector; // The piece's connector being used (relative non-rotated coords)
int m_NumCCWRotations; // Number of rotations necessary to match the two connectors
+ int m_Weight; // Relative chance that this connection will be chosen
- cConnection(cPiece & a_Piece, cPiece::cConnector & a_Connector, int a_NumCCWRotations);
+ cConnection(cPiece & a_Piece, cPiece::cConnector & a_Connector, int a_NumCCWRotations, int a_Weight);
};
typedef std::vector<cConnection> cConnections;