biome.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /*
  2. Minetest
  3. Copyright (C) 2010-2013 kwolekr, Ryan Kwolek <kwolekr@minetest.net>
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU Lesser General Public License as published by
  6. the Free Software Foundation; either version 2.1 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public License along
  13. with this program; if not, write to the Free Software Foundation, Inc.,
  14. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  15. */
  16. #ifndef BIOME_HEADER
  17. #define BIOME_HEADER
  18. #include <string>
  19. #include "nodedef.h"
  20. #include "gamedef.h"
  21. #include "mapnode.h"
  22. #include "noise.h"
  23. #include "mapgen.h"
  24. enum BiomeTerrainType
  25. {
  26. BIOME_TERRAIN_NORMAL,
  27. BIOME_TERRAIN_LIQUID,
  28. BIOME_TERRAIN_NETHER,
  29. BIOME_TERRAIN_AETHER,
  30. BIOME_TERRAIN_FLAT
  31. };
  32. extern NoiseParams nparams_biome_def_heat;
  33. extern NoiseParams nparams_biome_def_humidity;
  34. class Biome {
  35. public:
  36. u8 id;
  37. std::string name;
  38. u32 flags;
  39. std::string nname_top;
  40. std::string nname_filler;
  41. std::string nname_water;
  42. std::string nname_dust;
  43. std::string nname_dust_water;
  44. content_t c_top;
  45. content_t c_filler;
  46. content_t c_water;
  47. content_t c_dust;
  48. content_t c_dust_water;
  49. s16 depth_top;
  50. s16 depth_filler;
  51. s16 height_min;
  52. s16 height_max;
  53. float heat_point;
  54. float humidity_point;
  55. };
  56. struct BiomeNoiseInput {
  57. v2s16 mapsize;
  58. float *heat_map;
  59. float *humidity_map;
  60. s16 *height_map;
  61. };
  62. class BiomeDefManager {
  63. public:
  64. std::vector<Biome *> biomes;
  65. bool biome_registration_finished;
  66. NoiseParams *np_heat;
  67. NoiseParams *np_humidity;
  68. BiomeDefManager();
  69. ~BiomeDefManager();
  70. Biome *createBiome(BiomeTerrainType btt);
  71. void calcBiomes(BiomeNoiseInput *input, u8 *biomeid_map);
  72. Biome *getBiome(float heat, float humidity, s16 y);
  73. void addBiome(Biome *b);
  74. void resolveNodeNames(INodeDefManager *ndef);
  75. u8 getBiomeIdByName(const char *name);
  76. s16 calcBlockHeat(v3s16 p, u64 seed, float timeofday, float totaltime);
  77. s16 calcBlockHumidity(v3s16 p, u64 seed, float timeofday, float totaltime);
  78. };
  79. #endif