diff options
author | Mattes D <github@xoft.cz> | 2015-11-11 10:32:42 +0100 |
---|---|---|
committer | Mattes D <github@xoft.cz> | 2015-12-01 10:35:07 +0100 |
commit | b8fbba5eb92cda32b13d65f3704adf778da82f38 (patch) | |
tree | 0c6e8f47ae152e5ffade6f0a7457505101764753 /src/Generating/PieceStructuresGen.h | |
parent | Merge pull request #2696 from Gargaj/breeding (diff) | |
download | cuberite-b8fbba5eb92cda32b13d65f3704adf778da82f38.tar cuberite-b8fbba5eb92cda32b13d65f3704adf778da82f38.tar.gz cuberite-b8fbba5eb92cda32b13d65f3704adf778da82f38.tar.bz2 cuberite-b8fbba5eb92cda32b13d65f3704adf778da82f38.tar.lz cuberite-b8fbba5eb92cda32b13d65f3704adf778da82f38.tar.xz cuberite-b8fbba5eb92cda32b13d65f3704adf778da82f38.tar.zst cuberite-b8fbba5eb92cda32b13d65f3704adf778da82f38.zip |
Diffstat (limited to 'src/Generating/PieceStructuresGen.h')
-rw-r--r-- | src/Generating/PieceStructuresGen.h | 91 |
1 files changed, 91 insertions, 0 deletions
diff --git a/src/Generating/PieceStructuresGen.h b/src/Generating/PieceStructuresGen.h new file mode 100644 index 000000000..bcad86353 --- /dev/null +++ b/src/Generating/PieceStructuresGen.h @@ -0,0 +1,91 @@ + +// PieceStructuresGen.h + +// Declares the cPieceStructuresGen class representing the PieceStructures finisher generator + +/* +This generator loads various pieces from "piecepool" files, and each such piecepool is then used in a separate +cPieceGenerator instance. +*/ + + + + + +#pragma once + +#include "ComposableGenerator.h" +#include "PrefabPiecePool.h" +#include "GridStructGen.h" + + + + + +class cPieceStructuresGen : + public cFinishGen +{ + typedef cFinishGen Super; + +public: + cPieceStructuresGen(int a_Seed); + + /** Initializes the generator based on the specified prefab sets. + a_Prefabs contains the list of prefab sets that should be activated, "|"-separated. + All problems are logged to the console and the generator skips over them. + Returns true if at least one prefab set is valid (the generator should be kept). */ + bool Initialize(const AString & a_Prefabs, int a_SeaLevel, cBiomeGenPtr a_BiomeGen, cTerrainHeightGenPtr a_HeightGen); + + // cFinishGen override: + virtual void GenFinish(cChunkDesc & a_ChunkDesc) override; + +protected: + class cGen: + public cGridStructGen + { + typedef cGridStructGen Super; + public: + cGen(int a_Seed, cBiomeGenPtr a_BiomeGen, cTerrainHeightGenPtr a_HeightGen, int a_SeaLevel, const AString & a_Name); + + /** Loads the piecepool from a file. + Returns true on success, logs warning and returns false on failure. */ + bool LoadFromFile(const AString & a_FileName); + + // cGridStructGen overrides: + virtual cStructurePtr CreateStructure(int a_GridX, int a_GridZ, int a_OriginX, int a_OriginZ) override; + + protected: + + /** The underlying biome generator that defines whether the structure is created or not */ + cBiomeGenPtr m_BiomeGen; + + /** The underlying height generator, used to position the prefabs crossing chunk borders if they are set to FitGround. */ + cTerrainHeightGenPtr m_HeightGen; + + /** The world's sea level, if available. Used for some cVerticalStrategy descendants. */ + int m_SeaLevel; + + /** The name that is used for reporting. */ + AString m_Name; + + /** All available prefabs. */ + cPrefabPiecePool m_Pool; + + /** Maximum depth of the generated piece tree. */ + int m_MaxDepth; + }; + + typedef SharedPtr<cGen> cGenPtr; + typedef std::vector<cGenPtr> cGenPtrs; + + + /** The individual structure generators, one per piecepool. */ + cGenPtrs m_Gens; + + /** The seed for the random number generator */ + int m_Seed; +}; + + + + |