From 7004043c6164c6b22346f94489cb823f9495738f Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sat, 17 May 2014 21:54:04 +0200 Subject: Village houses are height-adjusted onto the terrain. --- src/Generating/PieceGenerator.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/Generating/PieceGenerator.h') diff --git a/src/Generating/PieceGenerator.h b/src/Generating/PieceGenerator.h index 16bec3bb4..56ce996d2 100644 --- a/src/Generating/PieceGenerator.h +++ b/src/Generating/PieceGenerator.h @@ -144,6 +144,13 @@ public: const cCuboid & GetHitBox (void) const { return m_HitBox; } int GetDepth (void) const { return m_Depth; } + /** 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; + protected: const cPlacedPiece * m_Parent; const cPiece * m_Piece; -- cgit v1.2.3 From a7e52e51dc3665ac2c2f27ed52e732ef7bbad32e Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sat, 17 May 2014 22:26:09 +0200 Subject: Village roads are drawn properly. --- src/Generating/PieceGenerator.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/Generating/PieceGenerator.h') diff --git a/src/Generating/PieceGenerator.h b/src/Generating/PieceGenerator.h index 56ce996d2..643ca58b6 100644 --- a/src/Generating/PieceGenerator.h +++ b/src/Generating/PieceGenerator.h @@ -156,8 +156,8 @@ protected: 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 }; typedef std::vector cPlacedPieces; -- cgit v1.2.3 From 6aa7df367f8db7506a8a5ab853c26e3c9fd60253 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 22 May 2014 21:47:56 +0200 Subject: Villages have min and max density setting. Also made roads use 3+9 scheme, instead of 3+5, for the house connectors. Fixes #1020. --- src/Generating/PieceGenerator.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/Generating/PieceGenerator.h') diff --git a/src/Generating/PieceGenerator.h b/src/Generating/PieceGenerator.h index 643ca58b6..e396643a9 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. */ @@ -151,6 +152,10 @@ public: 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; + protected: const cPlacedPiece * m_Parent; const cPiece * m_Piece; -- cgit v1.2.3 From 1a742a2b52d32bd22cd57b4d462bee312717e010 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sun, 25 May 2014 23:50:16 +0200 Subject: Added support for Miners' Village. The village contains both prefabs that snap to ground and prefabs that connect strictly via connectors. Fixes #1027. --- src/Generating/PieceGenerator.h | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'src/Generating/PieceGenerator.h') diff --git a/src/Generating/PieceGenerator.h b/src/Generating/PieceGenerator.h index e396643a9..21c155c96 100644 --- a/src/Generating/PieceGenerator.h +++ b/src/Generating/PieceGenerator.h @@ -139,11 +139,13 @@ 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; } @@ -156,6 +158,11 @@ public: 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; @@ -163,6 +170,10 @@ protected: int m_NumCCWRotations; 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 cPlacedPieces; -- cgit v1.2.3 From ff99373237178e9f7da02f51581f9a83d0e624d9 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Tue, 27 May 2014 22:05:50 +0200 Subject: cPieceGenerator chooses starting pieces based on weights. Fixes #1033. --- src/Generating/PieceGenerator.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/Generating/PieceGenerator.h') diff --git a/src/Generating/PieceGenerator.h b/src/Generating/PieceGenerator.h index 21c155c96..fd8576706 100644 --- a/src/Generating/PieceGenerator.h +++ b/src/Generating/PieceGenerator.h @@ -120,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; -- cgit v1.2.3