RmgMap.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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. VCMI_LIB_NAMESPACE_BEGIN
  14. class CMap;
  15. class CMapEditManager;
  16. class TileInfo;
  17. class CMapGenOptions;
  18. class Zone;
  19. class CMapGenerator;
  20. class RmgMap
  21. {
  22. public:
  23. mutable std::unique_ptr<CMap> mapInstance;
  24. CMap & map() const;
  25. RmgMap(const CMapGenOptions& mapGenOptions);
  26. ~RmgMap() = default;
  27. CMapEditManager* getEditManager() const;
  28. const CMapGenOptions& getMapGenOptions() const;
  29. void foreach_neighbour(const int3 & pos, const std::function<void(int3 & pos)> & foo) const;
  30. void foreachDirectNeighbour(const int3 & pos, const std::function<void(int3 & pos)> & foo) const;
  31. void foreachDiagonalNeighbour(const int3 & pos, const std::function<void(int3 & pos)> & foo) const;
  32. bool isBlocked(const int3 &tile) const;
  33. bool shouldBeBlocked(const int3 &tile) const;
  34. bool isPossible(const int3 &tile) const;
  35. bool isFree(const int3 &tile) const;
  36. bool isUsed(const int3 &tile) const;
  37. bool isRoad(const int3 &tile) const;
  38. bool isOnMap(const int3 & tile) const;
  39. void setOccupied(const int3 &tile, ETileType::ETileType state);
  40. void setRoad(const int3 &tile, RoadId roadType);
  41. TileInfo getTile(const int3 & tile) const;
  42. float getNearestObjectDistance(const int3 &tile) const;
  43. void setNearestObjectDistance(int3 &tile, float value);
  44. TRmgTemplateZoneId getZoneID(const int3& tile) const;
  45. void setZoneID(const int3& tile, TRmgTemplateZoneId zid);
  46. using Zones = std::map<TRmgTemplateZoneId, std::shared_ptr<Zone>>;
  47. using ZonePair = std::pair<TRmgTemplateZoneId, std::shared_ptr<Zone>>;
  48. using ZoneVector = std::vector<ZonePair>;
  49. Zones & getZones();
  50. void registerZone(FactionID faction);
  51. ui32 getZoneCount(FactionID faction);
  52. ui32 getTotalZoneCount() const;
  53. void initTiles(CMapGenerator & generator);
  54. void addModificators();
  55. bool isAllowedSpell(const SpellID & sid) const;
  56. void dump(bool zoneId) const;
  57. private:
  58. void assertOnMap(const int3 &tile) const; //throws
  59. private:
  60. Zones zones;
  61. std::map<FactionID, ui32> zonesPerFaction;
  62. ui32 zonesTotal; //zones that have their main town only
  63. const CMapGenOptions& mapGenOptions;
  64. boost::multi_array<TileInfo, 3> tiles; //[x][y][z]
  65. boost::multi_array<TRmgTemplateZoneId, 3> zoneColouring; //[x][y][z]
  66. };
  67. VCMI_LIB_NAMESPACE_END