From 7616537bc071bc93f8d36c84b94603528be1efb0 Mon Sep 17 00:00:00 2001 From: kwolekr Date: Wed, 12 Nov 2014 23:01:13 -0500 Subject: Add Generator Element Management framework Add BiomeManager, OreManager, DecorationManager, and SchematicManager --- src/mg_decoration.h | 57 ++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 50 insertions(+), 7 deletions(-) (limited to 'src/mg_decoration.h') diff --git a/src/mg_decoration.h b/src/mg_decoration.h index 78ff9dc2e..d5c9f0165 100644 --- a/src/mg_decoration.h +++ b/src/mg_decoration.h @@ -21,12 +21,13 @@ with this program; if not, write to the Free Software Foundation, Inc., #define MG_DECORATION_HEADER #include -#include "mapnode.h" +#include "mapgen.h" class NoiseParams; class Mapgen; class ManualMapVoxelManipulator; class PseudoRandom; +class Schematic; enum DecorationType { DECO_SIMPLE, @@ -34,6 +35,13 @@ enum DecorationType { DECO_LSYSTEM }; +#define DECO_PLACE_CENTER_X 0x01 +#define DECO_PLACE_CENTER_Y 0x02 +#define DECO_PLACE_CENTER_Z 0x04 + +extern FlagDesc flagdesc_deco_schematic[]; + + #if 0 struct CutoffData { VoxelArea a; @@ -49,7 +57,7 @@ struct CutoffData { }; #endif -class Decoration { +class Decoration : public GenElement { public: INodeDefManager *ndef; @@ -66,12 +74,11 @@ public: Decoration(); virtual ~Decoration(); - void placeDeco(Mapgen *mg, u32 blockseed, v3s16 nmin, v3s16 nmax); - void placeCutoffs(Mapgen *mg, u32 blockseed, v3s16 nmin, v3s16 nmax); + size_t placeDeco(Mapgen *mg, u32 blockseed, v3s16 nmin, v3s16 nmax); + size_t placeCutoffs(Mapgen *mg, u32 blockseed, v3s16 nmin, v3s16 nmax); virtual void generate(Mapgen *mg, PseudoRandom *pr, s16 max_y, v3s16 p) = 0; virtual int getHeight() = 0; - virtual std::string getName() = 0; }; class DecoSimple : public Decoration { @@ -87,9 +94,22 @@ public: bool canPlaceDecoration(ManualMapVoxelManipulator *vm, v3s16 p); virtual void generate(Mapgen *mg, PseudoRandom *pr, s16 max_y, v3s16 p); virtual int getHeight(); - virtual std::string getName(); }; +class DecoSchematic : public Decoration { +public: + u32 flags; + Rotation rotation; + Schematic *schematic; + std::string filename; + + ~DecoSchematic() {} + + void generate(Mapgen *mg, PseudoRandom *pr, s16 max_y, v3s16 p); + virtual int getHeight(); +}; + + /* class DecoLSystem : public Decoration { public: @@ -97,6 +117,29 @@ public: }; */ -Decoration *createDecoration(DecorationType type); +class DecorationManager : public GenElementManager { +public: + static const char *ELEMENT_TITLE; + static const size_t ELEMENT_LIMIT = 0x10000; + + DecorationManager(IGameDef *gamedef) {} + ~DecorationManager() {} + + Decoration *create(int type) + { + switch (type) { + case DECO_SIMPLE: + return new DecoSimple; + case DECO_SCHEMATIC: + return new DecoSchematic; + //case DECO_LSYSTEM: + // return new DecoLSystem; + default: + return NULL; + } + } + + size_t placeAllDecos(Mapgen *mg, u32 seed, v3s16 nmin, v3s16 nmax); +}; #endif -- cgit v1.2.3