]> git.lizzy.rs Git - minetest.git/blobdiff - src/mg_decoration.h
Small fixes of minetest.has_feature
[minetest.git] / src / mg_decoration.h
index 78ff9dc2e5c3bc2e9be5c20676724cb0c419ec20..c712ce7c8e5dfb672950457dda810804c9e19c30 100644 (file)
@@ -21,12 +21,14 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #define MG_DECORATION_HEADER
 
 #include <set>
-#include "mapnode.h"
+#include "objdef.h"
+#include "noise.h"
+#include "nodedef.h"
 
-class NoiseParams;
 class Mapgen;
-class ManualMapVoxelManipulator;
+class MMVManip;
 class PseudoRandom;
+class Schematic;
 
 enum DecorationType {
        DECO_SIMPLE,
@@ -34,6 +36,15 @@ enum DecorationType {
        DECO_LSYSTEM
 };
 
+#define DECO_PLACE_CENTER_X  0x01
+#define DECO_PLACE_CENTER_Y  0x02
+#define DECO_PLACE_CENTER_Z  0x04
+#define DECO_USE_NOISE       0x08
+#define DECO_FORCE_PLACEMENT 0x10
+
+extern FlagDesc flagdesc_deco[];
+
+
 #if 0
 struct CutoffData {
        VoxelArea a;
@@ -49,47 +60,60 @@ struct CutoffData {
 };
 #endif
 
-class Decoration {
+class Decoration : public ObjDef, public NodeResolver {
 public:
-       INodeDefManager *ndef;
+       Decoration();
+       virtual ~Decoration();
+
+       virtual void resolveNodeNames();
 
+       size_t placeDeco(Mapgen *mg, u32 blockseed, v3s16 nmin, v3s16 nmax);
+       //size_t placeCutoffs(Mapgen *mg, u32 blockseed, v3s16 nmin, v3s16 nmax);
+
+       virtual size_t generate(MMVManip *vm, PseudoRandom *pr, v3s16 p) = 0;
+       virtual int getHeight() = 0;
+
+       u32 flags;
        int mapseed;
        std::vector<content_t> c_place_on;
        s16 sidelen;
+       s16 y_min;
+       s16 y_max;
        float fill_ratio;
-       NoiseParams *np;
+       NoiseParams np;
 
        std::set<u8> biomes;
        //std::list<CutoffData> cutoffs;
-       //JMutex cutoff_mutex;
-
-       Decoration();
-       virtual ~Decoration();
-
-       void placeDeco(Mapgen *mg, u32 blockseed, v3s16 nmin, v3s16 nmax);
-       void 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;
+       //Mutex cutoff_mutex;
 };
 
 class DecoSimple : public Decoration {
 public:
+       virtual size_t generate(MMVManip *vm, PseudoRandom *pr, v3s16 p);
+       bool canPlaceDecoration(MMVManip *vm, v3s16 p);
+       virtual int getHeight();
+
+       virtual void resolveNodeNames();
+
        std::vector<content_t> c_decos;
        std::vector<content_t> c_spawnby;
        s16 deco_height;
        s16 deco_height_max;
        s16 nspawnby;
+};
 
-       ~DecoSimple() {}
+class DecoSchematic : public Decoration {
+public:
+       DecoSchematic();
 
-       bool canPlaceDecoration(ManualMapVoxelManipulator *vm, v3s16 p);
-       virtual void generate(Mapgen *mg, PseudoRandom *pr, s16 max_y, v3s16 p);
+       virtual size_t generate(MMVManip *vm, PseudoRandom *pr, v3s16 p);
        virtual int getHeight();
-       virtual std::string getName();
+
+       Rotation rotation;
+       Schematic *schematic;
 };
 
+
 /*
 class DecoLSystem : public Decoration {
 public:
@@ -97,6 +121,31 @@ class DecoLSystem : public Decoration {
 };
 */
 
-Decoration *createDecoration(DecorationType type);
+class DecorationManager : public ObjDefManager {
+public:
+       DecorationManager(IGameDef *gamedef);
+       virtual ~DecorationManager() {}
+
+       const char *getObjectTitle() const
+       {
+               return "decoration";
+       }
+
+       static Decoration *create(DecorationType 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 blockseed, v3s16 nmin, v3s16 nmax);
+};
 
 #endif