RmgMap.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /*
  2. * RmgMap.cpp, part of VCMI engine
  3. *
  4. * Authors: listed in file AUTHORS in main folder
  5. *
  6. * License: GNU General Public License v2.0 or later
  7. * Full text of license available in license.txt file, in main folder
  8. *
  9. */
  10. #pragma once
  11. #include "../int3.h"
  12. #include "../GameConstants.h"
  13. #include "MapProxy.h"
  14. VCMI_LIB_NAMESPACE_BEGIN
  15. class CMap;
  16. class CMapEditManager;
  17. class TileInfo;
  18. class CMapGenOptions;
  19. class Zone;
  20. class CMapGenerator;
  21. class MapProxy;
  22. class playerInfo;
  23. namespace vstd
  24. {
  25. class RNG;
  26. }
  27. class RmgMap
  28. {
  29. public:
  30. int getDecorationsPercentage() const;
  31. mutable std::unique_ptr<CMap> mapInstance;
  32. std::shared_ptr<MapProxy> getMapProxy() const;
  33. CMap & getMap(const CMapGenerator *) const; //limited access
  34. RmgMap(const CMapGenOptions& mapGenOptions, IGameInfoCallback * cb);
  35. ~RmgMap() = default;
  36. CMapEditManager* getEditManager() const;
  37. const CMapGenOptions& getMapGenOptions() const;
  38. void foreach_neighbour(const int3 & pos, const std::function<void(int3 & pos)> & foo) const;
  39. void foreachDirectNeighbour(const int3 & pos, const std::function<void(int3 & pos)> & foo) const;
  40. void foreachDiagonalNeighbour(const int3 & pos, const std::function<void(int3 & pos)> & foo) const;
  41. bool isBlocked(const int3 &tile) const;
  42. bool shouldBeBlocked(const int3 &tile) const;
  43. bool isPossible(const int3 &tile) const;
  44. bool isFree(const int3 &tile) const;
  45. bool isUsed(const int3 &tile) const;
  46. bool isRoad(const int3 &tile) const;
  47. bool isOnMap(const int3 & tile) const;
  48. int levels() const;
  49. int width() const;
  50. int height() const;
  51. PlayerInfo & getPlayer(int playerId);
  52. void setOccupied(const int3 &tile, ETileType state);
  53. void setRoad(const int3 &tile, RoadId roadType);
  54. TileInfo getTileInfo(const int3 & tile) const;
  55. TerrainTile & getTile(const int3 & tile) const;
  56. float getNearestObjectDistance(const int3 &tile) const;
  57. void setNearestObjectDistance(const int3 &tile, float value);
  58. TRmgTemplateZoneId getZoneID(const int3& tile) const;
  59. void setZoneID(const int3& tile, TRmgTemplateZoneId zid);
  60. using Zones = std::map<TRmgTemplateZoneId, std::shared_ptr<Zone>>;
  61. using ZonePair = std::pair<TRmgTemplateZoneId, std::shared_ptr<Zone>>;
  62. using ZoneVector = std::vector<ZonePair>;
  63. Zones & getZones();
  64. Zones getZonesOnLevel(int level) const;
  65. void registerZone(FactionID faction);
  66. ui32 getZoneCount(FactionID faction);
  67. ui32 getTotalZoneCount() const;
  68. void initTiles(CMapGenerator & generator, vstd::RNG & rand);
  69. void addModificators();
  70. bool isAllowedSpell(const SpellID & sid) const;
  71. void dump(bool zoneId) const;
  72. private:
  73. void assertOnMap(const int3 &tile) const; //throws
  74. private:
  75. std::shared_ptr<MapProxy> mapProxy;
  76. Zones zones;
  77. std::map<FactionID, ui32> zonesPerFaction;
  78. ui32 zonesTotal; //zones that have their main town only
  79. const CMapGenOptions& mapGenOptions;
  80. boost::multi_array<TileInfo, 3> tiles; //[x][y][z]
  81. boost::multi_array<TRmgTemplateZoneId, 3> zoneColouring; //[x][y][z]
  82. };
  83. VCMI_LIB_NAMESPACE_END