RmgMap.h 2.2 KB

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