]> git.lizzy.rs Git - minetest.git/blob - src/mg_decoration.h
78ff9dc2e5c3bc2e9be5c20676724cb0c419ec20
[minetest.git] / src / mg_decoration.h
1 /*
2 Minetest
3 Copyright (C) 2010-2013 kwolekr, Ryan Kwolek <kwolekr@minetest.net>
4
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.
9
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.
14
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.
18 */
19
20 #ifndef MG_DECORATION_HEADER
21 #define MG_DECORATION_HEADER
22
23 #include <set>
24 #include "mapnode.h"
25
26 class NoiseParams;
27 class Mapgen;
28 class ManualMapVoxelManipulator;
29 class PseudoRandom;
30
31 enum DecorationType {
32         DECO_SIMPLE,
33         DECO_SCHEMATIC,
34         DECO_LSYSTEM
35 };
36
37 #if 0
38 struct CutoffData {
39         VoxelArea a;
40         Decoration *deco;
41         //v3s16 p;
42         //v3s16 size;
43         //s16 height;
44
45         CutoffData(s16 x, s16 y, s16 z, s16 h) {
46                 p = v3s16(x, y, z);
47                 height = h;
48         }
49 };
50 #endif
51
52 class Decoration {
53 public:
54         INodeDefManager *ndef;
55
56         int mapseed;
57         std::vector<content_t> c_place_on;
58         s16 sidelen;
59         float fill_ratio;
60         NoiseParams *np;
61
62         std::set<u8> biomes;
63         //std::list<CutoffData> cutoffs;
64         //JMutex cutoff_mutex;
65
66         Decoration();
67         virtual ~Decoration();
68
69         void placeDeco(Mapgen *mg, u32 blockseed, v3s16 nmin, v3s16 nmax);
70         void placeCutoffs(Mapgen *mg, u32 blockseed, v3s16 nmin, v3s16 nmax);
71
72         virtual void generate(Mapgen *mg, PseudoRandom *pr, s16 max_y, v3s16 p) = 0;
73         virtual int getHeight() = 0;
74         virtual std::string getName() = 0;
75 };
76
77 class DecoSimple : public Decoration {
78 public:
79         std::vector<content_t> c_decos;
80         std::vector<content_t> c_spawnby;
81         s16 deco_height;
82         s16 deco_height_max;
83         s16 nspawnby;
84
85         ~DecoSimple() {}
86
87         bool canPlaceDecoration(ManualMapVoxelManipulator *vm, v3s16 p);
88         virtual void generate(Mapgen *mg, PseudoRandom *pr, s16 max_y, v3s16 p);
89         virtual int getHeight();
90         virtual std::string getName();
91 };
92
93 /*
94 class DecoLSystem : public Decoration {
95 public:
96         virtual void generate(Mapgen *mg, u32 blockseed, v3s16 nmin, v3s16 nmax);
97 };
98 */
99
100 Decoration *createDecoration(DecorationType type);
101
102 #endif