dungeongen.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /*
  2. Minetest
  3. Copyright (C) 2010-2013 celeron55, Perttu Ahola <celeron55@gmail.com>
  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 DUNGEONGEN_HEADER
  17. #define DUNGEONGEN_HEADER
  18. #include "voxel.h"
  19. #include "noise.h"
  20. #define VMANIP_FLAG_DUNGEON_INSIDE VOXELFLAG_CHECKED1
  21. #define VMANIP_FLAG_DUNGEON_PRESERVE VOXELFLAG_CHECKED2
  22. #define VMANIP_FLAG_DUNGEON_UNTOUCHABLE (\
  23. VMANIP_FLAG_DUNGEON_INSIDE|VMANIP_FLAG_DUNGEON_PRESERVE)
  24. class ManualMapVoxelManipulator;
  25. class INodeDefManager;
  26. class Mapgen;
  27. v3s16 rand_ortho_dir(PseudoRandom &random, bool diagonal_dirs);
  28. v3s16 turn_xz(v3s16 olddir, int t);
  29. v3s16 random_turn(PseudoRandom &random, v3s16 olddir);
  30. int dir_to_facedir(v3s16 d);
  31. struct DungeonParams {
  32. content_t c_water;
  33. content_t c_cobble;
  34. content_t c_moss;
  35. content_t c_stair;
  36. int notifytype;
  37. bool diagonal_dirs;
  38. float mossratio;
  39. v3s16 holesize;
  40. v3s16 roomsize;
  41. NoiseParams np_rarity;
  42. NoiseParams np_wetness;
  43. NoiseParams np_density;
  44. };
  45. class DungeonGen {
  46. public:
  47. ManualMapVoxelManipulator *vm;
  48. Mapgen *mg;
  49. u32 blockseed;
  50. PseudoRandom random;
  51. v3s16 csize;
  52. content_t c_torch;
  53. DungeonParams dp;
  54. //RoomWalker
  55. v3s16 m_pos;
  56. v3s16 m_dir;
  57. DungeonGen(Mapgen *mg, DungeonParams *dparams);
  58. void generate(u32 bseed, v3s16 full_node_min, v3s16 full_node_max);
  59. void makeDungeon(v3s16 start_padding);
  60. void makeRoom(v3s16 roomsize, v3s16 roomplace);
  61. void makeCorridor(v3s16 doorplace, v3s16 doordir,
  62. v3s16 &result_place, v3s16 &result_dir);
  63. void makeDoor(v3s16 doorplace, v3s16 doordir);
  64. void makeFill(v3s16 place, v3s16 size, u8 avoid_flags, MapNode n, u8 or_flags);
  65. void makeHole(v3s16 place);
  66. bool findPlaceForDoor(v3s16 &result_place, v3s16 &result_dir);
  67. bool findPlaceForRoomDoor(v3s16 roomsize, v3s16 &result_doorplace,
  68. v3s16 &result_doordir, v3s16 &result_roomplace);
  69. void randomizeDir()
  70. {
  71. m_dir = rand_ortho_dir(random, dp.diagonal_dirs);
  72. }
  73. };
  74. extern NoiseParams nparams_dungeon_rarity;
  75. extern NoiseParams nparams_dungeon_wetness;
  76. extern NoiseParams nparams_dungeon_density;
  77. #endif