From c18fe8aa45fa731a134c454dd16e1111742ca936 Mon Sep 17 00:00:00 2001 From: 12xx12 <44411062+12xx12@users.noreply.github.com> Date: Fri, 18 Sep 2020 00:20:50 +0200 Subject: Adding Generator For Single Piece Structures (#4830) * the beginning of a magnificent work - added basic files and classes without functionality * fixed checkstyle * added imports * moved imports * - Adding SinglePieceStructureGen - Adding a cPrefabChestStructure to generate Chests with contents - Added the options and calls to the ComposableGenerator * moved Globals to .h file * removed the chest thingy from the code (for now) * Update SinglePieceStructureGen.cpp * readded whitespace * renamed to SinglePieceStructuresGen for consistency added new classes to test * fixed small things (mostly style and cleanup) removed loottables * added small changes suggested by madmaxoft * small change to documentation * added check for allowed biomes * check only the biome of the origin position * fixed error on IsBiomeAllowed * added new cubesets * updated structures for with sponging * updated biome names * updated metadata to prevent crashing removed debug output * updated structures with sponging * added sponging to deserterWell to make it disappear in sand * small change in meta * rename DesertTemple -> DesertPyramid * minor style changes Co-authored-by: 12xx12 <12xx12100@gmail.com> Co-authored-by: Alexander Harkness --- src/Generating/SinglePieceStructuresGen.h | 52 +++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 src/Generating/SinglePieceStructuresGen.h (limited to 'src/Generating/SinglePieceStructuresGen.h') diff --git a/src/Generating/SinglePieceStructuresGen.h b/src/Generating/SinglePieceStructuresGen.h new file mode 100644 index 000000000..c14757738 --- /dev/null +++ b/src/Generating/SinglePieceStructuresGen.h @@ -0,0 +1,52 @@ + +// PrefabSingleStructureGen.h + + +/* +Classes to support the generation of single piece prefab structures +*/ + +#pragma once + +#include "Globals.h" + +#include "ComposableGenerator.h" +#include "PrefabPiecePool.h" + +/** The Single Prefab Structure Generator: +This uses the cGridStructGen to generate the structures on the map +This is similar to the Piece Structure Generator but only placing one possible structure +The Exported cubeset MUST have all possible structures as start structures or the server crashes on generation +else it isn't accessible from the m_Piecepool. */ +class cSinglePieceStructuresGen : + public cFinishGen +{ +using Super = cFinishGen; + +public: + cSinglePieceStructuresGen(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, const cBiomeGenPtr & a_BiomeGen, const cTerrainHeightGenPtr & a_HeightGen); + + + // cFinishGen override: + virtual void GenFinish(cChunkDesc & a_ChunkDesc) override; + +protected: + /** The generator doing the work for a single prefab set. + Forward-declared so that its implementation changes don't affect the header. */ + class cGen; + + typedef std::shared_ptr cGenPtr; + typedef std::vector cGenPtrs; + + /** The individual structure generators, one per piecepool. */ + cGenPtrs m_Gens; + + /** The seed for the random number generator */ + int m_Seed; +}; -- cgit v1.2.3