RmgMap.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. Zones & getZones();
  48. void registerZone(FactionID faction);
  49. ui32 getZoneCount(FactionID faction);
  50. ui32 getTotalZoneCount() const;
  51. void initTiles(CMapGenerator & generator);
  52. void addModificators();
  53. bool isAllowedSpell(const SpellID & sid) const;
  54. void dump(bool zoneId) const;
  55. private:
  56. void assertOnMap(const int3 &tile) const; //throws
  57. private:
  58. Zones zones;
  59. std::map<FactionID, ui32> zonesPerFaction;
  60. ui32 zonesTotal; //zones that have their main town only
  61. const CMapGenOptions& mapGenOptions;
  62. boost::multi_array<TileInfo, 3> tiles; //[x][y][z]
  63. boost::multi_array<TRmgTemplateZoneId, 3> zoneColouring; //[x][y][z]
  64. };
  65. VCMI_LIB_NAMESPACE_END