RmgMap.h 2.9 KB

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