From 9c8e8ef7aece2f881ef97c387600c8a751579b20 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Mon, 12 May 2014 22:43:59 +0200 Subject: VillageGen: Added well placement and the general algorithm description. --- src/Generating/Prefab.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/Generating/Prefab.h') diff --git a/src/Generating/Prefab.h b/src/Generating/Prefab.h index 37db2ff16..472584c3a 100644 --- a/src/Generating/Prefab.h +++ b/src/Generating/Prefab.h @@ -95,6 +95,9 @@ public: /** Returns the weight (chance) of this prefab generating as the next piece after the specified placed piece. PiecePool implementations can use this for their GetPieceWeight() implementations. */ int GetPieceWeight(const cPlacedPiece & a_PlacedPiece, const cPiece::cConnector & a_ExistingConnector) const; + + /** Returns the unmodified DefaultWeight property for the piece. */ + int GetDefaultWeight(void) const { return m_DefaultWeight; } protected: /** Packs complete definition of a single block, for per-letter assignment. */ -- cgit v1.2.3 From 3660ce68343ad2e867e49d1650f61fc0eb85ac23 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 15 May 2014 00:12:01 +0200 Subject: cPrefab can be constructed in code. --- src/Generating/Prefab.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/Generating/Prefab.h') diff --git a/src/Generating/Prefab.h b/src/Generating/Prefab.h index 472584c3a..c08413e87 100644 --- a/src/Generating/Prefab.h +++ b/src/Generating/Prefab.h @@ -84,8 +84,13 @@ public: int m_AddWeightIfSame; }; + + /** Creates a prefab from the provided definition. */ cPrefab(const sDef & a_Def); + /** Creates a prefab based on the given BlockArea and allowed rotations. */ + cPrefab(const cBlockArea & a_Image, int a_AllowedRotations); + /** Draws the prefab into the specified chunk, according to the placement stored in the PlacedPiece. */ void Draw(cChunkDesc & a_Dest, const cPlacedPiece * a_Placement) const; @@ -98,6 +103,12 @@ public: /** Returns the unmodified DefaultWeight property for the piece. */ int GetDefaultWeight(void) const { return m_DefaultWeight; } + + /** Sets the AddWeightIfSame member, that is used to modify the weight when the previous piece is the same prefab */ + void SetAddWeightIfSame(int a_AddWeightIfSame) { m_AddWeightIfSame = a_AddWeightIfSame; } + + /** Adds the specified connector to the list of connectors this piece supports. */ + void AddConnector(int a_RelX, int a_RelY, int a_RelZ, eBlockFace a_Direction, int a_Type); protected: /** Packs complete definition of a single block, for per-letter assignment. */ @@ -160,6 +171,10 @@ protected: virtual cCuboid GetHitBox(void) const override; virtual bool CanRotateCCW(int a_NumRotations) const override; + /** Based on the m_AllowedRotations, adds rotated cBlockAreas to the m_BlockArea array. + To be called only from this class's constructor! */ + void AddRotatedBlockAreas(void); + /** Parses the CharMap in the definition into a CharMap binary data used for translating the definition into BlockArea. */ void ParseCharMap(CharMap & a_CharMapOut, const char * a_CharMapDef); -- cgit v1.2.3 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/Prefab.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/Generating/Prefab.h') diff --git a/src/Generating/Prefab.h b/src/Generating/Prefab.h index c08413e87..2b89a204c 100644 --- a/src/Generating/Prefab.h +++ b/src/Generating/Prefab.h @@ -94,6 +94,9 @@ public: /** Draws the prefab into the specified chunk, according to the placement stored in the PlacedPiece. */ void Draw(cChunkDesc & a_Dest, const cPlacedPiece * a_Placement) const; + /** Draws the prefab into the specified chunks, according to the specified placement and rotations. */ + void Draw(cChunkDesc & a_Dest, const Vector3i & a_Placement, int a_NumRotations) const; + /** Returns true if the prefab has any connector of the specified type. */ bool HasConnectorType(int a_ConnectorType) const; -- cgit v1.2.3 From 96a22cd82c350b1205985a9b8e01f5e6c11f069a Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sat, 24 May 2014 15:03:39 +0200 Subject: Added Japanese village prefabs. --- src/Generating/Prefab.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/Generating/Prefab.h') diff --git a/src/Generating/Prefab.h b/src/Generating/Prefab.h index 2b89a204c..adc0e688e 100644 --- a/src/Generating/Prefab.h +++ b/src/Generating/Prefab.h @@ -104,6 +104,9 @@ public: PiecePool implementations can use this for their GetPieceWeight() implementations. */ int GetPieceWeight(const cPlacedPiece & a_PlacedPiece, const cPiece::cConnector & a_ExistingConnector) const; + /** Sets the (unmodified) DefaultWeight property for this piece. */ + void SetDefaultWeight(int a_DefaultWeight); + /** Returns the unmodified DefaultWeight property for the piece. */ int GetDefaultWeight(void) const { return m_DefaultWeight; } -- 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/Prefab.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/Generating/Prefab.h') diff --git a/src/Generating/Prefab.h b/src/Generating/Prefab.h index adc0e688e..8b4e4b4ef 100644 --- a/src/Generating/Prefab.h +++ b/src/Generating/Prefab.h @@ -82,6 +82,10 @@ public: Can be positive or negative. This is used e. g. to make nether bridges prefer spanning multiple segments or to penalize turrets next to each other. */ int m_AddWeightIfSame; + + /** If true, the piece will be moved Y-wise so that its first connector is sitting on the terrain. + This is used e. g. for village houses. */ + bool m_MoveToGround; }; @@ -115,6 +119,10 @@ public: /** Adds the specified connector to the list of connectors this piece supports. */ void AddConnector(int a_RelX, int a_RelY, int a_RelZ, eBlockFace a_Direction, int a_Type); + + /** Returns whether the prefab should be moved Y-wise to ground before drawing, rather than staying + at the coords governed by the connectors. */ + bool ShouldMoveToGround(void) const { return m_MoveToGround; } protected: /** Packs complete definition of a single block, for per-letter assignment. */ @@ -169,6 +177,10 @@ protected: Can be positive or negative. This is used e. g. to make nether bridges prefer spanning multiple segments or to penalize turrets next to each other. */ int m_AddWeightIfSame; + + /** If true, the piece will be moved Y-wise so that its first connector is sitting on the terrain. + This is used e. g. for village houses. */ + bool m_MoveToGround; // cPiece overrides: -- cgit v1.2.3