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>
28 typedef u16 biome_t
; // copy from mg_biome.h to avoid an unnecessary include
41 #define DECO_PLACE_CENTER_X 0x01
42 #define DECO_PLACE_CENTER_Y 0x02
43 #define DECO_PLACE_CENTER_Z 0x04
44 #define DECO_USE_NOISE 0x08
45 #define DECO_FORCE_PLACEMENT 0x10
46 #define DECO_LIQUID_SURFACE 0x20
47 #define DECO_ALL_FLOORS 0x40
48 #define DECO_ALL_CEILINGS 0x80
50 extern FlagDesc flagdesc_deco
[];
53 class Decoration
: public ObjDef
, public NodeResolver
{
55 Decoration() = default;
56 virtual ~Decoration() = default;
58 virtual void resolveNodeNames();
60 bool canPlaceDecoration(MMVManip
*vm
, v3s16 p
);
61 size_t placeDeco(Mapgen
*mg
, u32 blockseed
, v3s16 nmin
, v3s16 nmax
);
63 virtual size_t generate(MMVManip
*vm
, PcgRandom
*pr
, v3s16 p
, bool ceiling
) = 0;
67 std::vector
<content_t
> c_place_on
;
71 float fill_ratio
= 0.0f
;
73 std::vector
<content_t
> c_spawnby
;
75 s16 place_offset_y
= 0;
77 std::unordered_set
<biome_t
> biomes
;
80 void cloneTo(Decoration
*def
) const;
84 class DecoSimple
: public Decoration
{
86 ObjDef
*clone() const;
88 virtual void resolveNodeNames();
89 virtual size_t generate(MMVManip
*vm
, PcgRandom
*pr
, v3s16 p
, bool ceiling
);
91 std::vector
<content_t
> c_decos
;
99 class DecoSchematic
: public Decoration
{
101 ObjDef
*clone() const;
103 DecoSchematic() = default;
104 virtual ~DecoSchematic();
106 virtual size_t generate(MMVManip
*vm
, PcgRandom
*pr
, v3s16 p
, bool ceiling
);
109 Schematic
*schematic
= nullptr;
110 bool was_cloned
= false; // see FIXME inside DecoSchemtic::clone()
115 class DecoLSystem : public Decoration {
117 virtual void generate(Mapgen *mg, u32 blockseed, v3s16 nmin, v3s16 nmax);
122 class DecorationManager
: public ObjDefManager
{
124 DecorationManager(IGameDef
*gamedef
);
125 virtual ~DecorationManager() = default;
127 DecorationManager
*clone() const;
129 const char *getObjectTitle() const
134 static Decoration
*create(DecorationType type
)
138 return new DecoSimple
;
140 return new DecoSchematic
;
142 // return new DecoLSystem;
148 size_t placeAllDecos(Mapgen
*mg
, u32 blockseed
, v3s16 nmin
, v3s16 nmax
);
151 DecorationManager() {};