]> git.lizzy.rs Git - dragonfireclient.git/blob - src/mg_decoration.h
RemotePlayer/LocalPlayer Player base class proper separation (code cleanup) (patch...
[dragonfireclient.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 "util/cpp11_container.h"
24 #include "objdef.h"
25 #include "noise.h"
26 #include "nodedef.h"
27
28 class Mapgen;
29 class MMVManip;
30 class PcgRandom;
31 class Schematic;
32
33 enum DecorationType {
34         DECO_SIMPLE,
35         DECO_SCHEMATIC,
36         DECO_LSYSTEM
37 };
38
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
46 extern FlagDesc flagdesc_deco[];
47
48
49 #if 0
50 struct CutoffData {
51         VoxelArea a;
52         Decoration *deco;
53         //v3s16 p;
54         //v3s16 size;
55         //s16 height;
56
57         CutoffData(s16 x, s16 y, s16 z, s16 h) {
58                 p = v3s16(x, y, z);
59                 height = h;
60         }
61 };
62 #endif
63
64 class Decoration : public ObjDef, public NodeResolver {
65 public:
66         Decoration();
67         virtual ~Decoration();
68
69         virtual void resolveNodeNames();
70
71         bool canPlaceDecoration(MMVManip *vm, v3s16 p);
72         size_t placeDeco(Mapgen *mg, u32 blockseed, v3s16 nmin, v3s16 nmax);
73         //size_t placeCutoffs(Mapgen *mg, u32 blockseed, v3s16 nmin, v3s16 nmax);
74
75         virtual size_t generate(MMVManip *vm, PcgRandom *pr, v3s16 p) = 0;
76         virtual int getHeight() = 0;
77
78         u32 flags;
79         int mapseed;
80         std::vector<content_t> c_place_on;
81         s16 sidelen;
82         s16 y_min;
83         s16 y_max;
84         float fill_ratio;
85         NoiseParams np;
86         std::vector<content_t> c_spawnby;
87         s16 nspawnby;
88
89         UNORDERED_SET<u8> biomes;
90         //std::list<CutoffData> cutoffs;
91         //Mutex cutoff_mutex;
92 };
93
94 class DecoSimple : public Decoration {
95 public:
96         virtual void resolveNodeNames();
97         virtual size_t generate(MMVManip *vm, PcgRandom *pr, v3s16 p);
98         virtual int getHeight();
99
100         std::vector<content_t> c_decos;
101         s16 deco_height;
102         s16 deco_height_max;
103 };
104
105 class DecoSchematic : public Decoration {
106 public:
107         DecoSchematic();
108
109         virtual size_t generate(MMVManip *vm, PcgRandom *pr, v3s16 p);
110         virtual int getHeight();
111
112         Rotation rotation;
113         Schematic *schematic;
114 };
115
116
117 /*
118 class DecoLSystem : public Decoration {
119 public:
120         virtual void generate(Mapgen *mg, u32 blockseed, v3s16 nmin, v3s16 nmax);
121 };
122 */
123
124 class DecorationManager : public ObjDefManager {
125 public:
126         DecorationManager(IGameDef *gamedef);
127         virtual ~DecorationManager() {}
128
129         const char *getObjectTitle() const
130         {
131                 return "decoration";
132         }
133
134         static Decoration *create(DecorationType type)
135         {
136                 switch (type) {
137                 case DECO_SIMPLE:
138                         return new DecoSimple;
139                 case DECO_SCHEMATIC:
140                         return new DecoSchematic;
141                 //case DECO_LSYSTEM:
142                 //      return new DecoLSystem;
143                 default:
144                         return NULL;
145                 }
146         }
147
148         size_t placeAllDecos(Mapgen *mg, u32 blockseed, v3s16 nmin, v3s16 nmax);
149 };
150
151 #endif