Readded and optimized mapgen V6
[oweals/minetest.git] / src / biome.h
1 /*
2 Minetest-c55
3 Copyright (C) 2010-2011 kwolekr, Ryan Kwolek <kwolekr2@cs.scranton.edu>
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
31 enum BiomeTerrainType
32 {
33         BIOME_TERRAIN_NORMAL,
34         BIOME_TERRAIN_LIQUID,
35         BIOME_TERRAIN_NETHER,
36         BIOME_TERRAIN_AETHER,
37         BIOME_TERRAIN_FLAT
38 };
39
40 class Biome {
41 public:
42         MapNode n_top;
43         MapNode n_filler;
44         s16 ntopnodes;
45         s8 groupid;
46         s8 flags;
47         s16 height_min;
48         s16 height_max;
49         float heat_min;
50         float heat_max;
51         float humidity_min;
52         float humidity_max;
53         std::string name;
54         NoiseParams *np;
55
56         virtual void genColumn(MapgenV7 *mg, int x, int z, int y1, int y2);
57         virtual int getSurfaceHeight(float noise_terrain);
58 };
59
60 class BiomeLiquid : public Biome {
61         virtual void genColumn(MapgenV7 *mg, int x, int z, int y1, int y2);
62 };
63
64 class BiomeHell : public Biome {
65         virtual void genColumn(MapgenV7 *mg, int x, int z, int y1, int y2);
66         virtual int getSurfaceHeight(float noise_terrain);
67 };
68
69 class BiomeAether : public Biome {
70         virtual void genColumn(MapgenV7 *mg, int x, int z, int y1, int y2);
71         virtual int getSurfaceHeight(float noise_terrain);
72 };
73
74 class BiomeSuperflat : public Biome {
75         virtual void genColumn(MapgenV7 *mg, int x, int z, int y1, int y2);
76         virtual int getSurfaceHeight(float noise_terrain);
77 };
78
79 class BiomeDefManager {
80 public:
81         std::vector<float> bgroup_freqs;
82         std::vector<std::vector<Biome *> *> bgroups;
83         Biome *biome_default;
84         IGameDef *m_gamedef;
85         INodeDefManager *ndef;
86
87         BiomeDefManager(IGameDef *gamedef);
88         ~BiomeDefManager();
89
90         Biome *createBiome(BiomeTerrainType btt);
91         Biome *getBiome(float bgfreq, float heat, float humidity);
92
93         void addBiomeGroup(float freq);
94         void addBiome(Biome *b);
95         void addDefaultBiomes();
96 };
97
98 #endif