]> git.lizzy.rs Git - dragonfireclient.git/blob - src/biome.h
Add NodeResolver and clean up node name -> content ID resolution system
[dragonfireclient.git] / src / 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 BIOME_HEADER
21 #define 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 /*
49         std::string nname_top;
50         std::string nname_filler;
51         std::string nname_water;
52         std::string nname_dust;
53         std::string nname_dust_water;
54 */
55
56         content_t c_top;
57         content_t c_filler;
58         content_t c_water;
59         content_t c_dust;
60         content_t c_dust_water;
61         
62         s16 depth_top;
63         s16 depth_filler;
64         
65         s16 height_min;
66         s16 height_max;
67         float heat_point;
68         float humidity_point;
69 };
70
71 struct BiomeNoiseInput {
72         v2s16 mapsize;
73         float *heat_map;
74         float *humidity_map;
75         s16 *height_map;
76 };
77
78 class BiomeDefManager {
79 public:
80         std::vector<Biome *> biomes;
81
82         bool biome_registration_finished;
83         NoiseParams *np_heat;
84         NoiseParams *np_humidity;
85
86         BiomeDefManager(NodeResolver *resolver);
87         ~BiomeDefManager();
88         
89         Biome *createBiome(BiomeTerrainType btt);
90         void  calcBiomes(BiomeNoiseInput *input, u8 *biomeid_map);
91         Biome *getBiome(float heat, float humidity, s16 y);
92
93         void addBiome(Biome *b);
94         void resolveNodeNames(INodeDefManager *ndef);
95         u8 getBiomeIdByName(const char *name);
96         
97         s16 calcBlockHeat(v3s16 p, u64 seed, float timeofday, float totaltime);
98         s16 calcBlockHumidity(v3s16 p, u64 seed, float timeofday, float totaltime);
99 };
100
101 #endif