RmgMap.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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 "threadpool/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. class RmgMap
  24. {
  25. public:
  26. mutable std::unique_ptr<CMap> mapInstance;
  27. std::shared_ptr<MapProxy> getMapProxy() const;
  28. CMap & getMap(const CMapGenerator *) const; //limited access
  29. RmgMap(const CMapGenOptions& mapGenOptions);
  30. ~RmgMap() = default;
  31. CMapEditManager* getEditManager() const;
  32. const CMapGenOptions& getMapGenOptions() const;
  33. void foreach_neighbour(const int3 & pos, const std::function<void(int3 & pos)> & foo) const;
  34. void foreachDirectNeighbour(const int3 & pos, const std::function<void(int3 & pos)> & foo) const;
  35. void foreachDiagonalNeighbour(const int3 & pos, const std::function<void(int3 & pos)> & foo) const;
  36. bool isBlocked(const int3 &tile) const;
  37. bool shouldBeBlocked(const int3 &tile) const;
  38. bool isPossible(const int3 &tile) const;
  39. bool isFree(const int3 &tile) const;
  40. bool isUsed(const int3 &tile) const;
  41. bool isRoad(const int3 &tile) const;
  42. bool isOnMap(const int3 & tile) const;
  43. int levels() const;
  44. int width() const;
  45. int height() const;
  46. PlayerInfo & getPlayer(int playerId);
  47. void setOccupied(const int3 &tile, ETileType state);
  48. void setRoad(const int3 &tile, RoadId roadType);
  49. TileInfo getTileInfo(const int3 & tile) const;
  50. TerrainTile & getTile(const int3 & tile) const;
  51. float getNearestObjectDistance(const int3 &tile) const;
  52. void setNearestObjectDistance(const int3 &tile, float value);
  53. TRmgTemplateZoneId getZoneID(const int3& tile) const;
  54. void setZoneID(const int3& tile, TRmgTemplateZoneId zid);
  55. using Zones = std::map<TRmgTemplateZoneId, std::shared_ptr<Zone>>;
  56. using ZonePair = std::pair<TRmgTemplateZoneId, std::shared_ptr<Zone>>;
  57. using ZoneVector = std::vector<ZonePair>;
  58. Zones & getZones();
  59. void registerZone(FactionID faction);
  60. ui32 getZoneCount(FactionID faction);
  61. ui32 getTotalZoneCount() const;
  62. void initTiles(CMapGenerator & generator, CRandomGenerator & rand);
  63. void addModificators();
  64. bool isAllowedSpell(const SpellID & sid) const;
  65. void dump(bool zoneId) const;
  66. private:
  67. void assertOnMap(const int3 &tile) const; //throws
  68. private:
  69. std::shared_ptr<MapProxy> mapProxy;
  70. Zones zones;
  71. std::map<FactionID, ui32> zonesPerFaction;
  72. ui32 zonesTotal; //zones that have their main town only
  73. const CMapGenOptions& mapGenOptions;
  74. boost::multi_array<TileInfo, 3> tiles; //[x][y][z]
  75. boost::multi_array<TRmgTemplateZoneId, 3> zoneColouring; //[x][y][z]
  76. };
  77. VCMI_LIB_NAMESPACE_END