2014-11-01 18:16:23 +01:00
|
|
|
/*
|
|
|
|
Minetest
|
2018-01-15 03:26:15 +01:00
|
|
|
Copyright (C) 2014-2018 kwolekr, Ryan Kwolek <kwolekr@minetest.net>
|
|
|
|
Copyright (C) 2015-2018 paramat
|
2014-11-01 18:16:23 +01:00
|
|
|
|
|
|
|
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.
|
|
|
|
*/
|
|
|
|
|
2017-08-17 22:19:39 +02:00
|
|
|
#pragma once
|
2014-11-01 18:16:23 +01:00
|
|
|
|
2017-06-04 21:00:04 +02:00
|
|
|
#include <unordered_set>
|
2015-05-19 04:30:25 +02:00
|
|
|
#include "objdef.h"
|
|
|
|
#include "noise.h"
|
|
|
|
#include "nodedef.h"
|
2014-11-01 18:16:23 +01:00
|
|
|
|
|
|
|
class Noise;
|
|
|
|
class Mapgen;
|
2015-01-05 08:42:27 +01:00
|
|
|
class MMVManip;
|
2014-11-01 18:16:23 +01:00
|
|
|
|
|
|
|
/////////////////// Ore generation flags
|
2014-11-13 05:01:13 +01:00
|
|
|
|
2017-06-22 07:50:22 +02:00
|
|
|
#define OREFLAG_ABSHEIGHT 0x01 // Non-functional but kept to not break flags
|
2015-09-16 03:28:16 +02:00
|
|
|
#define OREFLAG_PUFF_CLIFFS 0x02
|
|
|
|
#define OREFLAG_PUFF_ADDITIVE 0x04
|
|
|
|
#define OREFLAG_USE_NOISE 0x08
|
2017-11-18 21:37:00 +01:00
|
|
|
#define OREFLAG_USE_NOISE2 0x10
|
2014-12-10 06:37:09 +01:00
|
|
|
|
2014-11-01 18:16:23 +01:00
|
|
|
enum OreType {
|
2015-04-01 05:27:19 +02:00
|
|
|
ORE_SCATTER,
|
|
|
|
ORE_SHEET,
|
2015-09-16 03:28:16 +02:00
|
|
|
ORE_PUFF,
|
2015-04-01 05:27:19 +02:00
|
|
|
ORE_BLOB,
|
|
|
|
ORE_VEIN,
|
2017-09-03 22:32:21 +02:00
|
|
|
ORE_STRATUM,
|
2014-11-01 18:16:23 +01:00
|
|
|
};
|
|
|
|
|
2014-11-13 05:01:13 +01:00
|
|
|
extern FlagDesc flagdesc_ore[];
|
|
|
|
|
2015-03-31 05:40:35 +02:00
|
|
|
class Ore : public ObjDef, public NodeResolver {
|
2014-11-01 18:16:23 +01:00
|
|
|
public:
|
2014-12-10 06:37:09 +01:00
|
|
|
static const bool NEEDS_NOISE = false;
|
|
|
|
|
2014-11-01 18:16:23 +01:00
|
|
|
content_t c_ore; // the node to place
|
|
|
|
std::vector<content_t> c_wherein; // the nodes to be placed in
|
|
|
|
u32 clust_scarcity; // ore cluster has a 1-in-clust_scarcity chance of appearing at a node
|
|
|
|
s16 clust_num_ores; // how many ore nodes are in a chunk
|
|
|
|
s16 clust_size; // how large (in nodes) a chunk of ore is
|
2014-12-30 07:48:20 +01:00
|
|
|
s16 y_min;
|
|
|
|
s16 y_max;
|
2014-11-01 18:16:23 +01:00
|
|
|
u8 ore_param2; // to set node-specific attributes
|
2017-06-18 19:55:15 +02:00
|
|
|
u32 flags = 0; // attributes for this ore
|
2015-12-05 14:00:11 +01:00
|
|
|
float nthresh; // threshold for noise at which an ore is placed
|
2014-12-10 06:37:09 +01:00
|
|
|
NoiseParams np; // noise for distribution of clusters (NULL for uniform scattering)
|
2017-06-18 19:55:15 +02:00
|
|
|
Noise *noise = nullptr;
|
2017-06-04 21:00:04 +02:00
|
|
|
std::unordered_set<u8> biomes;
|
2014-11-01 18:16:23 +01:00
|
|
|
|
2017-08-19 09:29:55 +02:00
|
|
|
Ore() = default;;
|
2014-12-17 09:20:17 +01:00
|
|
|
virtual ~Ore();
|
|
|
|
|
2015-04-16 10:12:26 +02:00
|
|
|
virtual void resolveNodeNames();
|
2014-12-10 06:56:44 +01:00
|
|
|
|
2017-09-17 01:26:20 +02:00
|
|
|
size_t placeOre(Mapgen *mg, u32 blockseed, v3s16 nmin, v3s16 nmax);
|
2015-01-05 08:42:27 +01:00
|
|
|
virtual void generate(MMVManip *vm, int mapseed, u32 blockseed,
|
2015-04-21 02:25:33 +02:00
|
|
|
v3s16 nmin, v3s16 nmax, u8 *biomemap) = 0;
|
2020-04-09 23:40:12 +02:00
|
|
|
|
|
|
|
protected:
|
|
|
|
void cloneTo(Ore *def) const;
|
2014-11-01 18:16:23 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
class OreScatter : public Ore {
|
2014-12-10 06:37:09 +01:00
|
|
|
public:
|
|
|
|
static const bool NEEDS_NOISE = false;
|
|
|
|
|
2020-04-09 23:40:12 +02:00
|
|
|
ObjDef *clone() const;
|
|
|
|
|
2015-01-05 08:42:27 +01:00
|
|
|
virtual void generate(MMVManip *vm, int mapseed, u32 blockseed,
|
2015-04-21 02:25:33 +02:00
|
|
|
v3s16 nmin, v3s16 nmax, u8 *biomemap);
|
2014-11-01 18:16:23 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
class OreSheet : public Ore {
|
2014-12-10 06:37:09 +01:00
|
|
|
public:
|
|
|
|
static const bool NEEDS_NOISE = true;
|
|
|
|
|
2020-04-09 23:40:12 +02:00
|
|
|
ObjDef *clone() const;
|
|
|
|
|
2015-09-13 06:09:00 +02:00
|
|
|
u16 column_height_min;
|
|
|
|
u16 column_height_max;
|
|
|
|
float column_midpoint_factor;
|
|
|
|
|
2015-01-05 08:42:27 +01:00
|
|
|
virtual void generate(MMVManip *vm, int mapseed, u32 blockseed,
|
2015-04-21 02:25:33 +02:00
|
|
|
v3s16 nmin, v3s16 nmax, u8 *biomemap);
|
2014-12-28 09:11:00 +01:00
|
|
|
};
|
|
|
|
|
2015-09-16 03:28:16 +02:00
|
|
|
class OrePuff : public Ore {
|
|
|
|
public:
|
|
|
|
static const bool NEEDS_NOISE = true;
|
|
|
|
|
2020-04-09 23:40:12 +02:00
|
|
|
ObjDef *clone() const;
|
|
|
|
|
2015-09-16 03:28:16 +02:00
|
|
|
NoiseParams np_puff_top;
|
|
|
|
NoiseParams np_puff_bottom;
|
2017-06-18 19:55:15 +02:00
|
|
|
Noise *noise_puff_top = nullptr;
|
|
|
|
Noise *noise_puff_bottom = nullptr;
|
2015-09-16 03:28:16 +02:00
|
|
|
|
2017-08-18 18:18:25 +02:00
|
|
|
OrePuff() = default;
|
2015-09-16 03:28:16 +02:00
|
|
|
virtual ~OrePuff();
|
|
|
|
|
|
|
|
virtual void generate(MMVManip *vm, int mapseed, u32 blockseed,
|
|
|
|
v3s16 nmin, v3s16 nmax, u8 *biomemap);
|
|
|
|
};
|
|
|
|
|
2014-12-28 09:11:00 +01:00
|
|
|
class OreBlob : public Ore {
|
|
|
|
public:
|
|
|
|
static const bool NEEDS_NOISE = true;
|
|
|
|
|
2020-04-09 23:40:12 +02:00
|
|
|
ObjDef *clone() const;
|
|
|
|
|
2015-01-05 08:42:27 +01:00
|
|
|
virtual void generate(MMVManip *vm, int mapseed, u32 blockseed,
|
2015-04-21 02:25:33 +02:00
|
|
|
v3s16 nmin, v3s16 nmax, u8 *biomemap);
|
2014-11-01 18:16:23 +01:00
|
|
|
};
|
|
|
|
|
2014-12-29 03:17:12 +01:00
|
|
|
class OreVein : public Ore {
|
|
|
|
public:
|
|
|
|
static const bool NEEDS_NOISE = true;
|
|
|
|
|
2020-04-09 23:40:12 +02:00
|
|
|
ObjDef *clone() const;
|
|
|
|
|
2014-12-29 03:17:12 +01:00
|
|
|
float random_factor;
|
2017-06-18 19:55:15 +02:00
|
|
|
Noise *noise2 = nullptr;
|
2018-05-24 23:20:06 +02:00
|
|
|
int sizey_prev = 0;
|
2014-12-29 03:17:12 +01:00
|
|
|
|
2017-08-18 18:18:25 +02:00
|
|
|
OreVein() = default;
|
2014-12-29 03:17:12 +01:00
|
|
|
virtual ~OreVein();
|
|
|
|
|
2015-01-05 08:42:27 +01:00
|
|
|
virtual void generate(MMVManip *vm, int mapseed, u32 blockseed,
|
2015-04-21 02:25:33 +02:00
|
|
|
v3s16 nmin, v3s16 nmax, u8 *biomemap);
|
2014-12-29 03:17:12 +01:00
|
|
|
};
|
|
|
|
|
2017-09-03 22:32:21 +02:00
|
|
|
class OreStratum : public Ore {
|
|
|
|
public:
|
2017-09-30 11:23:57 +02:00
|
|
|
static const bool NEEDS_NOISE = false;
|
2017-09-03 22:32:21 +02:00
|
|
|
|
2020-04-09 23:40:12 +02:00
|
|
|
ObjDef *clone() const;
|
|
|
|
|
2017-09-03 22:32:21 +02:00
|
|
|
NoiseParams np_stratum_thickness;
|
|
|
|
Noise *noise_stratum_thickness = nullptr;
|
2017-11-18 21:37:00 +01:00
|
|
|
u16 stratum_thickness;
|
2017-09-03 22:32:21 +02:00
|
|
|
|
|
|
|
OreStratum() = default;
|
|
|
|
virtual ~OreStratum();
|
|
|
|
|
|
|
|
virtual void generate(MMVManip *vm, int mapseed, u32 blockseed,
|
|
|
|
v3s16 nmin, v3s16 nmax, u8 *biomemap);
|
|
|
|
};
|
|
|
|
|
2015-03-31 05:40:35 +02:00
|
|
|
class OreManager : public ObjDefManager {
|
2014-11-13 05:01:13 +01:00
|
|
|
public:
|
2014-12-12 20:07:49 +01:00
|
|
|
OreManager(IGameDef *gamedef);
|
2017-08-19 09:29:55 +02:00
|
|
|
virtual ~OreManager() = default;
|
2014-11-13 05:01:13 +01:00
|
|
|
|
2020-04-09 23:40:12 +02:00
|
|
|
OreManager *clone() const;
|
|
|
|
|
2015-03-31 05:40:35 +02:00
|
|
|
const char *getObjectTitle() const
|
|
|
|
{
|
|
|
|
return "ore";
|
|
|
|
}
|
|
|
|
|
2015-04-01 05:27:19 +02:00
|
|
|
static Ore *create(OreType type)
|
2014-11-13 05:01:13 +01:00
|
|
|
{
|
|
|
|
switch (type) {
|
2015-04-01 05:27:19 +02:00
|
|
|
case ORE_SCATTER:
|
2014-11-13 05:01:13 +01:00
|
|
|
return new OreScatter;
|
2015-04-01 05:27:19 +02:00
|
|
|
case ORE_SHEET:
|
2014-11-13 05:01:13 +01:00
|
|
|
return new OreSheet;
|
2015-09-16 03:28:16 +02:00
|
|
|
case ORE_PUFF:
|
|
|
|
return new OrePuff;
|
2015-04-01 05:27:19 +02:00
|
|
|
case ORE_BLOB:
|
2014-12-28 09:11:00 +01:00
|
|
|
return new OreBlob;
|
2015-04-01 05:27:19 +02:00
|
|
|
case ORE_VEIN:
|
2014-12-29 03:17:12 +01:00
|
|
|
return new OreVein;
|
2017-09-03 22:32:21 +02:00
|
|
|
case ORE_STRATUM:
|
|
|
|
return new OreStratum;
|
2014-11-13 05:01:13 +01:00
|
|
|
default:
|
2017-06-18 19:55:15 +02:00
|
|
|
return nullptr;
|
2014-11-13 05:01:13 +01:00
|
|
|
}
|
|
|
|
}
|
2014-11-01 18:16:23 +01:00
|
|
|
|
2014-12-12 20:07:49 +01:00
|
|
|
void clear();
|
|
|
|
|
2017-09-17 01:26:20 +02:00
|
|
|
size_t placeAllOres(Mapgen *mg, u32 blockseed, v3s16 nmin, v3s16 nmax);
|
2020-04-09 23:40:12 +02:00
|
|
|
|
|
|
|
private:
|
|
|
|
OreManager() {};
|
2014-11-13 05:01:13 +01:00
|
|
|
};
|