/*
Minetest
-Copyright (C) 2010-2013 kwolekr, Ryan Kwolek <kwolekr@minetest.net>
+Copyright (C) 2014-2016 kwolekr, Ryan Kwolek <kwolekr@minetest.net>
+Copyright (C) 2015-2017 paramat
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
#ifndef MG_DECORATION_HEADER
#define MG_DECORATION_HEADER
-#include <set>
-#include "mapgen.h"
+#include <unordered_set>
+#include "objdef.h"
+#include "noise.h"
+#include "nodedef.h"
-struct NoiseParams;
class Mapgen;
-class ManualMapVoxelManipulator;
-class PseudoRandom;
+class MMVManip;
+class PcgRandom;
class Schematic;
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_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
+#define DECO_LIQUID_SURFACE 0x20
extern FlagDesc flagdesc_deco[];
};
#endif
-class Decoration : public GenElement, public NodeResolver {
+class Decoration : public ObjDef, public NodeResolver {
public:
- INodeDefManager *ndef;
+ Decoration() {};
+ virtual ~Decoration() {};
- u32 flags;
- int mapseed;
- std::vector<content_t> c_place_on;
- s16 sidelen;
- s16 height_min;
- s16 height_max;
- float fill_ratio;
- NoiseParams np;
-
- std::set<u8> biomes;
- //std::list<CutoffData> cutoffs;
- //JMutex cutoff_mutex;
+ virtual void resolveNodeNames();
- Decoration();
- virtual ~Decoration();
+ bool canPlaceDecoration(MMVManip *vm, v3s16 p);
+ size_t placeDeco(Mapgen *mg, u32 blockseed,
+ v3s16 nmin, v3s16 nmax, s16 deco_zero_level);
+ //size_t placeCutoffs(Mapgen *mg, u32 blockseed, v3s16 nmin, v3s16 nmax);
- virtual void resolveNodeNames(NodeResolveInfo *nri);
+ virtual size_t generate(MMVManip *vm, PcgRandom *pr, v3s16 p) = 0;
+ virtual int getHeight() = 0;
- size_t placeDeco(Mapgen *mg, u32 blockseed, v3s16 nmin, v3s16 nmax);
- size_t placeCutoffs(Mapgen *mg, u32 blockseed, v3s16 nmin, v3s16 nmax);
+ u32 flags = 0;
+ int mapseed = 0;
+ std::vector<content_t> c_place_on;
+ s16 sidelen = 1;
+ s16 y_min;
+ s16 y_max;
+ float fill_ratio = 0.0f;
+ NoiseParams np;
+ std::vector<content_t> c_spawnby;
+ s16 nspawnby;
- virtual size_t generate(Mapgen *mg, PseudoRandom *pr, s16 max_y, v3s16 p) = 0;
- virtual int getHeight() = 0;
+ std::unordered_set<u8> biomes;
};
class DecoSimple : public Decoration {
public:
+ virtual void resolveNodeNames();
+ virtual size_t generate(MMVManip *vm, PcgRandom *pr, v3s16 p);
+ virtual int getHeight();
+
std::vector<content_t> c_decos;
- std::vector<content_t> c_spawnby;
s16 deco_height;
s16 deco_height_max;
- s16 nspawnby;
-
- virtual void resolveNodeNames(NodeResolveInfo *nri);
-
- bool canPlaceDecoration(ManualMapVoxelManipulator *vm, v3s16 p);
- virtual size_t generate(Mapgen *mg, PseudoRandom *pr, s16 max_y, v3s16 p);
- virtual int getHeight();
+ u8 deco_param2;
};
class DecoSchematic : public Decoration {
public:
- Rotation rotation;
- Schematic *schematic;
- std::string filename;
+ DecoSchematic() {};
- virtual size_t generate(Mapgen *mg, PseudoRandom *pr, s16 max_y, v3s16 p);
+ virtual size_t generate(MMVManip *vm, PcgRandom *pr, v3s16 p);
virtual int getHeight();
+
+ Rotation rotation;
+ Schematic *schematic = nullptr;
};
};
*/
-class DecorationManager : public GenElementManager {
+class DecorationManager : public ObjDefManager {
public:
- static const char *ELEMENT_TITLE;
- static const size_t ELEMENT_LIMIT = 0x10000;
-
DecorationManager(IGameDef *gamedef);
- ~DecorationManager() {}
+ virtual ~DecorationManager() {}
+
+ const char *getObjectTitle() const
+ {
+ return "decoration";
+ }
- Decoration *create(int type)
+ static Decoration *create(DecorationType type)
{
switch (type) {
case DECO_SIMPLE:
}
}
- void clear();
-
- size_t placeAllDecos(Mapgen *mg, u32 seed, v3s16 nmin, v3s16 nmax);
+ size_t placeAllDecos(Mapgen *mg, u32 blockseed,
+ v3s16 nmin, v3s16 nmax, s16 deco_zero_level = 0);
};
#endif