]> git.lizzy.rs Git - dragonfireclient.git/blob - src/mg_ore.h
Merge pull request #1825 from Zeno-/control_key_cache
[dragonfireclient.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 "mapnode.h"
25
26 class NoiseParams;
27 class Noise;
28 class Mapgen;
29 class ManualMapVoxelManipulator;
30
31 /////////////////// Ore generation flags
32 // Use absolute value of height to determine ore placement
33 #define OREFLAG_ABSHEIGHT 0x01
34 // Use 3d noise to get density of ore placement, instead of just the position
35 #define OREFLAG_DENSITY   0x02 // not yet implemented
36 // For claylike ore types, place ore if the number of surrounding
37 // nodes isn't the specified node
38 #define OREFLAG_NODEISNT  0x04 // not yet implemented
39
40 #define ORE_RANGE_ACTUAL 1
41 #define ORE_RANGE_MIRROR 2
42
43 extern FlagDesc flagdesc_ore[];
44
45 enum OreType {
46         ORE_SCATTER,
47         ORE_SHEET,
48         ORE_CLAYLIKE
49 };
50
51 class Ore {
52 public:
53         content_t c_ore;                  // the node to place
54         std::vector<content_t> c_wherein; // the nodes to be placed in
55         u32 clust_scarcity; // ore cluster has a 1-in-clust_scarcity chance of appearing at a node
56         s16 clust_num_ores; // how many ore nodes are in a chunk
57         s16 clust_size;     // how large (in nodes) a chunk of ore is
58         s16 height_min;
59         s16 height_max;
60         u8 ore_param2;          // to set node-specific attributes
61         u32 flags;          // attributes for this ore
62         float nthresh;      // threshhold for noise at which an ore is placed
63         NoiseParams *np;    // noise for distribution of clusters (NULL for uniform scattering)
64         Noise *noise;
65
66         Ore() {
67                 c_ore   = CONTENT_IGNORE;
68                 np      = NULL;
69                 noise   = NULL;
70         }
71
72         virtual ~Ore();
73
74         void placeOre(Mapgen *mg, u32 blockseed, v3s16 nmin, v3s16 nmax);
75         virtual void generate(ManualMapVoxelManipulator *vm, int seed,
76                                                 u32 blockseed, v3s16 nmin, v3s16 nmax) = 0;
77 };
78
79 class OreScatter : public Ore {
80         ~OreScatter() {}
81         virtual void generate(ManualMapVoxelManipulator *vm, int seed,
82                                                 u32 blockseed, v3s16 nmin, v3s16 nmax);
83 };
84
85 class OreSheet : public Ore {
86         ~OreSheet() {}
87         virtual void generate(ManualMapVoxelManipulator *vm, int seed,
88                                                 u32 blockseed, v3s16 nmin, v3s16 nmax);
89 };
90
91 Ore *createOre(OreType type);
92
93
94 #endif