3 Copyright (C) 2014-2018 kwolekr, Ryan Kwolek <kwolekr@minetest.net>
4 Copyright (C) 2015-2018 paramat
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU Lesser General Public License as published by
8 the Free Software Foundation; either version 2.1 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public License along
17 with this program; if not, write to the Free Software Foundation, Inc.,
18 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 #include <unordered_set>
39 #define DECO_PLACE_CENTER_X 0x01
40 #define DECO_PLACE_CENTER_Y 0x02
41 #define DECO_PLACE_CENTER_Z 0x04
42 #define DECO_USE_NOISE 0x08
43 #define DECO_FORCE_PLACEMENT 0x10
44 #define DECO_LIQUID_SURFACE 0x20
45 #define DECO_ALL_FLOORS 0x40
46 #define DECO_ALL_CEILINGS 0x80
48 extern FlagDesc flagdesc_deco[];
51 class Decoration : public ObjDef, public NodeResolver {
53 Decoration() = default;
54 virtual ~Decoration() = default;
56 virtual void resolveNodeNames();
58 bool canPlaceDecoration(MMVManip *vm, v3s16 p);
59 size_t placeDeco(Mapgen *mg, u32 blockseed, v3s16 nmin, v3s16 nmax);
61 virtual size_t generate(MMVManip *vm, PcgRandom *pr, v3s16 p, bool ceiling) = 0;
65 std::vector<content_t> c_place_on;
69 float fill_ratio = 0.0f;
71 std::vector<content_t> c_spawnby;
73 s16 place_offset_y = 0;
75 std::unordered_set<u8> biomes;
78 void cloneTo(Decoration *def) const;
82 class DecoSimple : public Decoration {
84 ObjDef *clone() const;
86 virtual void resolveNodeNames();
87 virtual size_t generate(MMVManip *vm, PcgRandom *pr, v3s16 p, bool ceiling);
89 std::vector<content_t> c_decos;
97 class DecoSchematic : public Decoration {
99 ObjDef *clone() const;
101 DecoSchematic() = default;
103 virtual size_t generate(MMVManip *vm, PcgRandom *pr, v3s16 p, bool ceiling);
106 Schematic *schematic = nullptr;
111 class DecoLSystem : public Decoration {
113 virtual void generate(Mapgen *mg, u32 blockseed, v3s16 nmin, v3s16 nmax);
118 class DecorationManager : public ObjDefManager {
120 DecorationManager(IGameDef *gamedef);
121 virtual ~DecorationManager() = default;
123 DecorationManager *clone() const;
125 const char *getObjectTitle() const
130 static Decoration *create(DecorationType type)
134 return new DecoSimple;
136 return new DecoSchematic;
138 // return new DecoLSystem;
144 size_t placeAllDecos(Mapgen *mg, u32 blockseed, v3s16 nmin, v3s16 nmax);
147 DecorationManager() {};