1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
|
/*
Minetest
Copyright (C) 2014-2018 kwolekr, Ryan Kwolek <kwolekr@minetest.net>
Copyright (C) 2015-2018 paramat
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#pragma once
#include <unordered_set>
#include "objdef.h"
#include "noise.h"
#include "nodedef.h"
typedef u16 biome_t; // copy from mg_biome.h to avoid an unnecessary include
class Mapgen;
class MMVManip;
class PcgRandom;
class Schematic;
enum DecorationType {
DECO_SIMPLE,
DECO_SCHEMATIC,
DECO_LSYSTEM
};
#define DECO_PLACE_CENTER_X 0x01
#define DECO_PLACE_CENTER_Y 0x02
#define DECO_PLACE_CENTER_Z 0x04
#define DECO_USE_NOISE 0x08
#define DECO_FORCE_PLACEMENT 0x10
#define DECO_LIQUID_SURFACE 0x20
#define DECO_ALL_FLOORS 0x40
#define DECO_ALL_CEILINGS 0x80
extern FlagDesc flagdesc_deco[];
class Decoration : public ObjDef, public NodeResolver {
public:
Decoration() = default;
virtual ~Decoration() = default;
virtual void resolveNodeNames();
bool canPlaceDecoration(MMVManip *vm, v3s16 p);
size_t placeDeco(Mapgen *mg, u32 blockseed, v3s16 nmin, v3s16 nmax);
virtual size_t generate(MMVManip *vm, PcgRandom *pr, v3s16 p, bool ceiling) = 0;
u32 flags = 0;
int mapseed = 0;
std::vector<content_t> c_place_on;
s16 sidelen = 1;
s16 y_min;
s16 y_max;
float fill_ratio = 0.0f;
NoiseParams np;
std::vector<content_t> c_spawnby;
s16 nspawnby;
s16 place_offset_y = 0;
std::unordered_set<biome_t> biomes;
protected:
void cloneTo(Decoration *def) const;
};
class DecoSimple : public Decoration {
public:
ObjDef *clone() const;
virtual void resolveNodeNames();
virtual size_t generate(MMVManip *vm, PcgRandom *pr, v3s16 p, bool ceiling);
std::vector<content_t> c_decos;
s16 deco_height;
s16 deco_height_max;
u8 deco_param2;
u8 deco_param2_max;
};
class DecoSchematic : public Decoration {
public:
ObjDef *clone() const;
DecoSchematic() = default;
virtual ~DecoSchematic();
virtual size_t generate(MMVManip *vm, PcgRandom *pr, v3s16 p, bool ceiling);
Rotation rotation;
Schematic *schematic = nullptr;
bool was_cloned = false; // see FIXME inside DecoSchemtic::clone()
};
/*
class DecoLSystem : public Decoration {
public:
virtual void generate(Mapgen *mg, u32 blockseed, v3s16 nmin, v3s16 nmax);
};
*/
class DecorationManager : public ObjDefManager {
public:
DecorationManager(IGameDef *gamedef);
virtual ~DecorationManager() = default;
DecorationManager *clone() const;
const char *getObjectTitle() const
{
return "decoration";
}
static Decoration *create(DecorationType type)
{
switch (type) {
case DECO_SIMPLE:
return new DecoSimple;
case DECO_SCHEMATIC:
return new DecoSchematic;
//case DECO_LSYSTEM:
// return new DecoLSystem;
default:
return NULL;
}
}
size_t placeAllDecos(Mapgen *mg, u32 blockseed, v3s16 nmin, v3s16 nmax);
private:
DecorationManager() {};
};
|