]> git.lizzy.rs Git - dragonfireclient.git/blob - src/mg_biome.h
Merge pull request #1825 from Zeno-/control_key_cache
[dragonfireclient.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 <string>
24 #include "nodedef.h"
25 #include "gamedef.h"
26 #include "mapnode.h"
27 #include "noise.h"
28 #include "mapgen.h"
29
30 enum BiomeTerrainType
31 {
32         BIOME_TERRAIN_NORMAL,
33         BIOME_TERRAIN_LIQUID,
34         BIOME_TERRAIN_NETHER,
35         BIOME_TERRAIN_AETHER,
36         BIOME_TERRAIN_FLAT
37 };
38
39 extern NoiseParams nparams_biome_def_heat;
40 extern NoiseParams nparams_biome_def_humidity;
41
42 class Biome {
43 public:
44         u8 id;
45         std::string name;
46         u32 flags;
47
48         content_t c_top;
49         content_t c_filler;
50         content_t c_water;
51         content_t c_dust;
52         content_t c_dust_water;
53
54         s16 depth_top;
55         s16 depth_filler;
56
57         s16 height_min;
58         s16 height_max;
59         float heat_point;
60         float humidity_point;
61 };
62
63 struct BiomeNoiseInput {
64         v2s16 mapsize;
65         float *heat_map;
66         float *humidity_map;
67         s16 *height_map;
68 };
69
70 class BiomeDefManager {
71 public:
72         std::vector<Biome *> biomes;
73
74         bool biome_registration_finished;
75         NoiseParams *np_heat;
76         NoiseParams *np_humidity;
77
78         BiomeDefManager(NodeResolver *resolver);
79         ~BiomeDefManager();
80
81         Biome *createBiome(BiomeTerrainType btt);
82         void  calcBiomes(BiomeNoiseInput *input, u8 *biomeid_map);
83         Biome *getBiome(float heat, float humidity, s16 y);
84
85         bool addBiome(Biome *b);
86         u8 getBiomeIdByName(const char *name);
87
88         s16 calcBlockHeat(v3s16 p, u64 seed, float timeofday, float totaltime);
89         s16 calcBlockHumidity(v3s16 p, u64 seed, float timeofday, float totaltime);
90 };
91
92 #endif