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
28 class ManualMapVoxelManipulator;
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
43 extern FlagDesc flagdesc_deco[];
54 CutoffData(s16 x, s16 y, s16 z, s16 h) {
61 class Decoration : public GenElement, public NodeResolver {
63 INodeDefManager *ndef;
67 std::vector<content_t> c_place_on;
73 //std::list<CutoffData> cutoffs;
74 //JMutex cutoff_mutex;
77 virtual ~Decoration();
79 virtual void resolveNodeNames(NodeResolveInfo *nri);
81 size_t placeDeco(Mapgen *mg, u32 blockseed, v3s16 nmin, v3s16 nmax);
82 size_t placeCutoffs(Mapgen *mg, u32 blockseed, v3s16 nmin, v3s16 nmax);
84 virtual size_t generate(Mapgen *mg, PseudoRandom *pr, s16 max_y, v3s16 p) = 0;
85 virtual int getHeight() = 0;
88 class DecoSimple : public Decoration {
90 std::vector<content_t> c_decos;
91 std::vector<content_t> c_spawnby;
96 virtual void resolveNodeNames(NodeResolveInfo *nri);
98 bool canPlaceDecoration(ManualMapVoxelManipulator *vm, v3s16 p);
99 virtual size_t generate(Mapgen *mg, PseudoRandom *pr, s16 max_y, v3s16 p);
100 virtual int getHeight();
103 class DecoSchematic : public Decoration {
106 Schematic *schematic;
107 std::string filename;
109 virtual size_t generate(Mapgen *mg, PseudoRandom *pr, s16 max_y, v3s16 p);
110 virtual int getHeight();
115 class DecoLSystem : public Decoration {
117 virtual void generate(Mapgen *mg, u32 blockseed, v3s16 nmin, v3s16 nmax);
121 class DecorationManager : public GenElementManager {
123 static const char *ELEMENT_TITLE;
124 static const size_t ELEMENT_LIMIT = 0x10000;
126 DecorationManager(IGameDef *gamedef);
127 ~DecorationManager() {}
129 Decoration *create(int type)
133 return new DecoSimple;
135 return new DecoSchematic;
137 // return new DecoLSystem;
145 size_t placeAllDecos(Mapgen *mg, u32 seed, v3s16 nmin, v3s16 nmax);