RmgMap.h 2.8 KB

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