3 Copyright (C) 2010-2013 kwolekr, Ryan Kwolek <kwolekr@minetest.net>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation; either version 2.1 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 #ifndef MG_DECORATION_HEADER
21 #define MG_DECORATION_HEADER
38 #define DECO_PLACE_CENTER_X 0x01
39 #define DECO_PLACE_CENTER_Y 0x02
40 #define DECO_PLACE_CENTER_Z 0x04
41 #define DECO_USE_NOISE 0x08
42 #define DECO_FORCE_PLACEMENT 0x10
44 extern FlagDesc flagdesc_deco[];
55 CutoffData(s16 x, s16 y, s16 z, s16 h) {
62 class Decoration : public GenElement, public NodeResolver {
64 INodeDefManager *ndef;
68 std::vector<content_t> c_place_on;
76 //std::list<CutoffData> cutoffs;
77 //JMutex cutoff_mutex;
80 virtual ~Decoration();
82 virtual void resolveNodeNames(NodeResolveInfo *nri);
84 size_t placeDeco(Mapgen *mg, u32 blockseed, v3s16 nmin, v3s16 nmax);
85 //size_t placeCutoffs(Mapgen *mg, u32 blockseed, v3s16 nmin, v3s16 nmax);
87 virtual size_t generate(MMVManip *vm, PseudoRandom *pr, s16 max_y, v3s16 p) = 0;
88 virtual int getHeight() = 0;
91 class DecoSimple : public Decoration {
93 std::vector<content_t> c_decos;
94 std::vector<content_t> c_spawnby;
99 virtual void resolveNodeNames(NodeResolveInfo *nri);
101 bool canPlaceDecoration(MMVManip *vm, v3s16 p);
102 virtual size_t generate(MMVManip *vm, PseudoRandom *pr, s16 max_y, v3s16 p);
103 virtual int getHeight();
106 class DecoSchematic : public Decoration {
109 Schematic *schematic;
110 std::string filename;
112 virtual size_t generate(MMVManip *vm, PseudoRandom *pr, s16 max_y, v3s16 p);
113 virtual int getHeight();
118 class DecoLSystem : public Decoration {
120 virtual void generate(Mapgen *mg, u32 blockseed, v3s16 nmin, v3s16 nmax);
124 class DecorationManager : public GenElementManager {
126 static const char *ELEMENT_TITLE;
127 static const size_t ELEMENT_LIMIT = 0x10000;
129 DecorationManager(IGameDef *gamedef);
130 ~DecorationManager() {}
132 Decoration *create(int type)
136 return new DecoSimple;
138 return new DecoSchematic;
140 // return new DecoLSystem;
148 size_t placeAllDecos(Mapgen *mg, u32 blockseed, v3s16 nmin, v3s16 nmax);