diff options
author | Howaner <franzi.moos@googlemail.com> | 2014-06-17 19:03:56 +0200 |
---|---|---|
committer | Howaner <franzi.moos@googlemail.com> | 2014-06-17 19:03:56 +0200 |
commit | c60ba8a52d6f84316eae041a24e395a4c37ae181 (patch) | |
tree | edb983f4b20312115bc1033a2bd5a89c615ed30e /src/Generating/Prefab.h | |
parent | Check block type from cBlockEntity (diff) | |
parent | Merge pull request #1099 from Howaner/Blocks (diff) | |
download | cuberite-c60ba8a52d6f84316eae041a24e395a4c37ae181.tar cuberite-c60ba8a52d6f84316eae041a24e395a4c37ae181.tar.gz cuberite-c60ba8a52d6f84316eae041a24e395a4c37ae181.tar.bz2 cuberite-c60ba8a52d6f84316eae041a24e395a4c37ae181.tar.lz cuberite-c60ba8a52d6f84316eae041a24e395a4c37ae181.tar.xz cuberite-c60ba8a52d6f84316eae041a24e395a4c37ae181.tar.zst cuberite-c60ba8a52d6f84316eae041a24e395a4c37ae181.zip |
Diffstat (limited to 'src/Generating/Prefab.h')
-rw-r--r-- | src/Generating/Prefab.h | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/Generating/Prefab.h b/src/Generating/Prefab.h index 37db2ff16..8b4e4b4ef 100644 --- a/src/Generating/Prefab.h +++ b/src/Generating/Prefab.h @@ -82,19 +82,47 @@ 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; }; + + /** 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; + /** 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; /** 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; + + /** 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; } + + /** 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); + + /** 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. */ @@ -149,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: @@ -157,6 +189,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); |