]> git.lizzy.rs Git - minetest.git/blob - src/mg_ore.h
Make limiting of the reflow liquids queue size optional
[minetest.git] / src / mg_ore.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_ORE_HEADER
21 #define MG_ORE_HEADER
22
23 #include "util/string.h"
24 #include "mapgen.h"
25
26 struct NoiseParams;
27 class Noise;
28 class Mapgen;
29 class ManualMapVoxelManipulator;
30
31 /////////////////// Ore generation flags
32
33 // Use absolute value of height to determine ore placement
34 #define OREFLAG_ABSHEIGHT 0x01
35
36 // Use 3d noise to get density of ore placement, instead of just the position
37 #define OREFLAG_DENSITY   0x02 // not yet implemented
38
39 // For claylike ore types, place ore if the number of surrounding
40 // nodes isn't the specified node
41 #define OREFLAG_NODEISNT  0x04 // not yet implemented
42
43 #define OREFLAG_USE_NOISE 0x08
44
45 #define ORE_RANGE_ACTUAL 1
46 #define ORE_RANGE_MIRROR 2
47
48
49 enum OreType {
50         ORE_SCATTER,
51         ORE_SHEET,
52         ORE_CLAYLIKE
53 };
54
55 extern FlagDesc flagdesc_ore[];
56
57 class Ore : public GenElement {
58 public:
59         static const bool NEEDS_NOISE = false;
60
61         content_t c_ore;                  // the node to place
62         std::vector<content_t> c_wherein; // the nodes to be placed in
63         u32 clust_scarcity; // ore cluster has a 1-in-clust_scarcity chance of appearing at a node
64         s16 clust_num_ores; // how many ore nodes are in a chunk
65         s16 clust_size;     // how large (in nodes) a chunk of ore is
66         s16 height_min;
67         s16 height_max;
68         u8 ore_param2;          // to set node-specific attributes
69         u32 flags;          // attributes for this ore
70         float nthresh;      // threshhold for noise at which an ore is placed
71         NoiseParams np;     // noise for distribution of clusters (NULL for uniform scattering)
72         Noise *noise;
73
74         Ore();
75
76         size_t placeOre(Mapgen *mg, u32 blockseed, v3s16 nmin, v3s16 nmax);
77         virtual void generate(ManualMapVoxelManipulator *vm, int seed,
78                                                 u32 blockseed, v3s16 nmin, v3s16 nmax) = 0;
79 };
80
81 class OreScatter : public Ore {
82 public:
83         static const bool NEEDS_NOISE = false;
84
85         virtual void generate(ManualMapVoxelManipulator *vm, int seed,
86                                                 u32 blockseed, v3s16 nmin, v3s16 nmax);
87 };
88
89 class OreSheet : public Ore {
90 public:
91         static const bool NEEDS_NOISE = true;
92
93         virtual void generate(ManualMapVoxelManipulator *vm, int seed,
94                                                 u32 blockseed, v3s16 nmin, v3s16 nmax);
95 };
96
97 class OreManager : public GenElementManager {
98 public:
99         static const char *ELEMENT_TITLE;
100         static const size_t ELEMENT_LIMIT = 0x10000;
101
102         OreManager(IGameDef *gamedef);
103         ~OreManager() {}
104
105         Ore *create(int type)
106         {
107                 switch (type) {
108                 case ORE_SCATTER:
109                         return new OreScatter;
110                 case ORE_SHEET:
111                         return new OreSheet;
112                 //case ORE_CLAYLIKE: //TODO: implement this!
113                 //      return new OreClaylike;
114                 default:
115                         return NULL;
116                 }
117         }
118
119         void clear();
120
121         size_t placeAllOres(Mapgen *mg, u32 seed, v3s16 nmin, v3s16 nmax);
122 };
123
124 #endif