Add minetest.clear_registered_biomes() api
[oweals/minetest.git] / src / mg_biome.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_BIOME_HEADER
21 #define MG_BIOME_HEADER
22
23 #include "mapgen.h"
24 #include "noise.h"
25
26 enum BiomeType
27 {
28         BIOME_TYPE_NORMAL,
29         BIOME_TYPE_LIQUID,
30         BIOME_TYPE_NETHER,
31         BIOME_TYPE_AETHER,
32         BIOME_TYPE_FLAT
33 };
34
35 extern NoiseParams nparams_biome_def_heat;
36 extern NoiseParams nparams_biome_def_humidity;
37
38
39 class Biome : public GenElement {
40 public:
41         u32 flags;
42
43         content_t c_top;
44         content_t c_filler;
45         content_t c_stone;
46         content_t c_water;
47         content_t c_dust;
48         content_t c_dust_water;
49
50         s16 depth_top;
51         s16 depth_filler;
52
53         s16 height_min;
54         s16 height_max;
55         float heat_point;
56         float humidity_point;
57 };
58
59 class BiomeManager : public GenElementManager {
60 public:
61         static const char *ELEMENT_TITLE;
62         static const size_t ELEMENT_LIMIT = 0x100;
63
64         NoiseParams *np_heat;
65         NoiseParams *np_humidity;
66
67         BiomeManager(IGameDef *gamedef);
68         ~BiomeManager();
69
70         Biome *create(int btt)
71         {
72                 return new Biome;
73         }
74
75         void clear();
76
77         void calcBiomes(s16 sx, s16 sy, float *heat_map, float *humidity_map,
78                 s16 *height_map, u8 *biomeid_map);
79         Biome *getBiome(float heat, float humidity, s16 y);
80
81 private:
82         NodeResolver *m_resolver;
83 };
84
85 #endif
86