Luanti 5.11.0-dev
 
Loading...
Searching...
No Matches
mg_ore.h
Go to the documentation of this file.
1// Luanti
2// SPDX-License-Identifier: LGPL-2.1-or-later
3// Copyright (C) 2015-2020 paramat
4// Copyright (C) 2014-2016 kwolekr, Ryan Kwolek <kwolekr@minetest.net>
5
6#pragma once
7
8#include <unordered_set>
9#include "objdef.h"
10#include "noise.h"
11#include "nodedef.h"
12
13typedef u16 biome_t; // copy from mg_biome.h to avoid an unnecessary include
14
15class Noise;
16class Mapgen;
17class MMVManip;
18
20
21#define OREFLAG_ABSHEIGHT 0x01 // Non-functional but kept to not break flags
22#define OREFLAG_PUFF_CLIFFS 0x02
23#define OREFLAG_PUFF_ADDITIVE 0x04
24#define OREFLAG_USE_NOISE 0x08
25#define OREFLAG_USE_NOISE2 0x10
26
35
36extern FlagDesc flagdesc_ore[];
37
38class Ore : public ObjDef, public NodeResolver {
39public:
40 const bool needs_noise;
41
42 content_t c_ore; // the node to place
43 std::vector<content_t> c_wherein; // the nodes to be placed in
44 u32 clust_scarcity; // ore cluster has a 1-in-clust_scarcity chance of appearing at a node
45 s16 clust_num_ores; // how many ore nodes are in a chunk
46 s16 clust_size; // how large (in nodes) a chunk of ore is
47 s16 y_min;
48 s16 y_max;
49 u8 ore_param2; // to set node-specific attributes
50 u32 flags = 0; // attributes for this ore
51 float nthresh; // threshold for noise at which an ore is placed
52 NoiseParams np; // noise for distribution of clusters (NULL for uniform scattering)
53 Noise *noise = nullptr;
54 std::unordered_set<biome_t> biomes;
55
57 virtual ~Ore();
58
59 virtual void resolveNodeNames();
60
61 size_t placeOre(Mapgen *mg, u32 blockseed, v3s16 nmin, v3s16 nmax);
62 virtual void generate(MMVManip *vm, int mapseed, u32 blockseed,
63 v3s16 nmin, v3s16 nmax, biome_t *biomemap) = 0;
64
65protected:
66 void cloneTo(Ore *def) const;
67};
68
69class OreScatter : public Ore {
70public:
71 OreScatter() : Ore(false) {}
72
73 ObjDef *clone() const override;
74
75 void generate(MMVManip *vm, int mapseed, u32 blockseed,
76 v3s16 nmin, v3s16 nmax, biome_t *biomemap) override;
77};
78
79class OreSheet : public Ore {
80public:
81 OreSheet() : Ore(true) {}
82
83 ObjDef *clone() const override;
84
88
89 void generate(MMVManip *vm, int mapseed, u32 blockseed,
90 v3s16 nmin, v3s16 nmax, biome_t *biomemap) override;
91};
92
93class OrePuff : public Ore {
94public:
95 ObjDef *clone() const override;
96
101
102 OrePuff() : Ore(true) {}
103 virtual ~OrePuff();
104
105 void generate(MMVManip *vm, int mapseed, u32 blockseed,
106 v3s16 nmin, v3s16 nmax, biome_t *biomemap) override;
107};
108
109class OreBlob : public Ore {
110public:
111 ObjDef *clone() const override;
112
113 OreBlob() : Ore(true) {}
114 void generate(MMVManip *vm, int mapseed, u32 blockseed,
115 v3s16 nmin, v3s16 nmax, biome_t *biomemap) override;
116};
117
118class OreVein : public Ore {
119public:
120 ObjDef *clone() const override;
121
123 Noise *noise2 = nullptr;
124 int sizey_prev = 0;
125
126 OreVein() : Ore(true) {}
127 virtual ~OreVein();
128
129 void generate(MMVManip *vm, int mapseed, u32 blockseed,
130 v3s16 nmin, v3s16 nmax, biome_t *biomemap) override;
131};
132
133class OreStratum : public Ore {
134public:
135 ObjDef *clone() const override;
136
140
141 OreStratum() : Ore(false) {}
142 virtual ~OreStratum();
143
144 void generate(MMVManip *vm, int mapseed, u32 blockseed,
145 v3s16 nmin, v3s16 nmax, biome_t *biomemap) override;
146};
147
148class OreManager : public ObjDefManager {
149public:
150 OreManager(IGameDef *gamedef);
151 virtual ~OreManager() = default;
152
153 OreManager *clone() const;
154
155 const char *getObjectTitle() const
156 {
157 return "ore";
158 }
159
160 static Ore *create(OreType type)
161 {
162 switch (type) {
163 case ORE_SCATTER:
164 return new OreScatter;
165 case ORE_SHEET:
166 return new OreSheet;
167 case ORE_PUFF:
168 return new OrePuff;
169 case ORE_BLOB:
170 return new OreBlob;
171 case ORE_VEIN:
172 return new OreVein;
173 case ORE_STRATUM:
174 return new OreStratum;
175 }
176 return nullptr;
177 }
178
179 void clear();
180
181 size_t placeAllOres(Mapgen *mg, u32 blockseed, v3s16 nmin, v3s16 nmax);
182
183private:
185};
u16 biome_t
Definition cavegen.h:10
Definition gamedef.h:36
Definition map.h:305
Definition mapgen.h:153
Definition nodedef.h:837
Definition noise.h:146
Definition objdef.h:56
Definition objdef.h:30
Definition mg_ore.h:109
void generate(MMVManip *vm, int mapseed, u32 blockseed, v3s16 nmin, v3s16 nmax, biome_t *biomemap) override
Definition mg_ore.cpp:353
OreBlob()
Definition mg_ore.h:113
ObjDef * clone() const override
Definition mg_ore.cpp:345
Definition mg_ore.h:148
virtual ~OreManager()=default
OreManager()
Definition mg_ore.h:184
OreManager * clone() const
Definition mg_ore.cpp:60
size_t placeAllOres(Mapgen *mg, u32 blockseed, v3s16 nmin, v3s16 nmax)
Definition mg_ore.cpp:33
static Ore * create(OreType type)
Definition mg_ore.h:160
const char * getObjectTitle() const
Definition mg_ore.h:155
void clear()
Definition mg_ore.cpp:50
Definition mg_ore.h:93
virtual ~OrePuff()
Definition mg_ore.cpp:251
Noise * noise_puff_bottom
Definition mg_ore.h:100
NoiseParams np_puff_bottom
Definition mg_ore.h:98
ObjDef * clone() const override
Definition mg_ore.cpp:258
NoiseParams np_puff_top
Definition mg_ore.h:97
Noise * noise_puff_top
Definition mg_ore.h:99
void generate(MMVManip *vm, int mapseed, u32 blockseed, v3s16 nmin, v3s16 nmax, biome_t *biomemap) override
Definition mg_ore.cpp:272
OrePuff()
Definition mg_ore.h:102
Definition mg_ore.h:69
void generate(MMVManip *vm, int mapseed, u32 blockseed, v3s16 nmin, v3s16 nmax, biome_t *biomemap) override
Definition mg_ore.cpp:133
OreScatter()
Definition mg_ore.h:71
ObjDef * clone() const override
Definition mg_ore.cpp:125
Definition mg_ore.h:79
OreSheet()
Definition mg_ore.h:81
ObjDef * clone() const override
Definition mg_ore.cpp:182
u16 column_height_min
Definition mg_ore.h:85
u16 column_height_max
Definition mg_ore.h:86
float column_midpoint_factor
Definition mg_ore.h:87
void generate(MMVManip *vm, int mapseed, u32 blockseed, v3s16 nmin, v3s16 nmax, biome_t *biomemap) override
Definition mg_ore.cpp:195
Definition mg_ore.h:133
virtual ~OreStratum()
Definition mg_ore.cpp:504
void generate(MMVManip *vm, int mapseed, u32 blockseed, v3s16 nmin, v3s16 nmax, biome_t *biomemap) override
Definition mg_ore.cpp:523
ObjDef * clone() const override
Definition mg_ore.cpp:510
Noise * noise_stratum_thickness
Definition mg_ore.h:138
u16 stratum_thickness
Definition mg_ore.h:139
NoiseParams np_stratum_thickness
Definition mg_ore.h:137
OreStratum()
Definition mg_ore.h:141
Definition mg_ore.h:118
void generate(MMVManip *vm, int mapseed, u32 blockseed, v3s16 nmin, v3s16 nmax, biome_t *biomemap) override
Definition mg_ore.cpp:438
ObjDef * clone() const override
Definition mg_ore.cpp:425
int sizey_prev
Definition mg_ore.h:124
virtual ~OreVein()
Definition mg_ore.cpp:419
float random_factor
Definition mg_ore.h:122
OreVein()
Definition mg_ore.h:126
Noise * noise2
Definition mg_ore.h:123
Definition mg_ore.h:38
s16 y_max
Definition mg_ore.h:48
Ore(bool needs_noise)
Definition mg_ore.h:56
virtual ~Ore()
Definition mg_ore.cpp:71
std::vector< content_t > c_wherein
Definition mg_ore.h:43
s16 clust_size
Definition mg_ore.h:46
const bool needs_noise
Definition mg_ore.h:40
u32 flags
Definition mg_ore.h:50
void cloneTo(Ore *def) const
Definition mg_ore.cpp:102
virtual void generate(MMVManip *vm, int mapseed, u32 blockseed, v3s16 nmin, v3s16 nmax, biome_t *biomemap)=0
float nthresh
Definition mg_ore.h:51
NoiseParams np
Definition mg_ore.h:52
std::unordered_set< biome_t > biomes
Definition mg_ore.h:54
u8 ore_param2
Definition mg_ore.h:49
u32 clust_scarcity
Definition mg_ore.h:44
Noise * noise
Definition mg_ore.h:53
s16 clust_num_ores
Definition mg_ore.h:45
virtual void resolveNodeNames()
Definition mg_ore.cpp:77
s16 y_min
Definition mg_ore.h:47
size_t placeOre(Mapgen *mg, u32 blockseed, v3s16 nmin, v3s16 nmax)
Definition mg_ore.cpp:84
content_t c_ore
Definition mg_ore.h:42
core::vector3d< s16 > v3s16
Definition irr_v3d.h:13
u16 content_t
Definition mapnode.h:22
OreType
Definition mg_ore.h:27
@ ORE_SCATTER
Definition mg_ore.h:28
@ ORE_VEIN
Definition mg_ore.h:32
@ ORE_SHEET
Definition mg_ore.h:29
@ ORE_BLOB
Definition mg_ore.h:31
@ ORE_STRATUM
Definition mg_ore.h:33
@ ORE_PUFF
Definition mg_ore.h:30
u16 biome_t
Definition mg_ore.h:13
FlagDesc flagdesc_ore[]
Definition mg_ore.cpp:16
Definition string.h:67
Definition noise.h:119