CRmgTemplateZone.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. /*
  2. * CRmgTemplateZone.h, 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 "../GameConstants.h"
  12. #include "CMapGenerator.h"
  13. class CMapgenerator;
  14. namespace ETemplateZoneType
  15. {
  16. enum ETemplateZoneType
  17. {
  18. PLAYER_START,
  19. CPU_START,
  20. TREASURE,
  21. JUNCTION
  22. };
  23. }
  24. /// The CRmgTemplateZone describes a zone in a template.
  25. class DLL_LINKAGE CRmgTemplateZone
  26. {
  27. public:
  28. class DLL_LINKAGE CTownInfo
  29. {
  30. public:
  31. CTownInfo();
  32. int getTownCount() const; /// Default: 0
  33. void setTownCount(int value);
  34. int getCastleCount() const; /// Default: 0
  35. void setCastleCount(int value);
  36. int getTownDensity() const; /// Default: 0
  37. void setTownDensity(int value);
  38. int getCastleDensity() const; /// Default: 0
  39. void setCastleDensity(int value);
  40. private:
  41. int townCount, castleCount, townDensity, castleDensity;
  42. };
  43. class DLL_LINKAGE CTileInfo
  44. {
  45. public:
  46. CTileInfo();
  47. int getNearestObjectDistance() const;
  48. void setNearestObjectDistance(int value);
  49. bool isObstacle() const;
  50. void setObstacle(bool value);
  51. bool isOccupied() const;
  52. void setOccupied(bool value);
  53. ETerrainType getTerrainType() const;
  54. void setTerrainType(ETerrainType value);
  55. private:
  56. int nearestObjectDistance;
  57. bool obstacle;
  58. bool occupied;
  59. ETerrainType terrain;
  60. };
  61. CRmgTemplateZone();
  62. TRmgTemplateZoneId getId() const; /// Default: 0
  63. void setId(TRmgTemplateZoneId value);
  64. ETemplateZoneType::ETemplateZoneType getType() const; /// Default: ETemplateZoneType::PLAYER_START
  65. void setType(ETemplateZoneType::ETemplateZoneType value);
  66. int getSize() const; /// Default: 1
  67. void setSize(int value);
  68. boost::optional<int> getOwner() const;
  69. void setOwner(boost::optional<int> value);
  70. const CTownInfo & getPlayerTowns() const;
  71. void setPlayerTowns(const CTownInfo & value);
  72. const CTownInfo & getNeutralTowns() const;
  73. void setNeutralTowns(const CTownInfo & value);
  74. bool getTownsAreSameType() const; /// Default: false
  75. void setTownsAreSameType(bool value);
  76. const std::set<TFaction> & getTownTypes() const; /// Default: all
  77. void setTownTypes(const std::set<TFaction> & value);
  78. std::set<TFaction> getDefaultTownTypes() const;
  79. bool getMatchTerrainToTown() const; /// Default: true
  80. void setMatchTerrainToTown(bool value);
  81. const std::set<ETerrainType> & getTerrainTypes() const; /// Default: all
  82. void setTerrainTypes(const std::set<ETerrainType> & value);
  83. std::set<ETerrainType> getDefaultTerrainTypes() const;
  84. boost::optional<TRmgTemplateZoneId> getTerrainTypeLikeZone() const;
  85. void setTerrainTypeLikeZone(boost::optional<TRmgTemplateZoneId> value);
  86. boost::optional<TRmgTemplateZoneId> getTownTypeLikeZone() const;
  87. void setTownTypeLikeZone(boost::optional<TRmgTemplateZoneId> value);
  88. void setShape(std::vector<int3> shape);
  89. bool fill(CMapGenerator* gen);
  90. private:
  91. TRmgTemplateZoneId id;
  92. ETemplateZoneType::ETemplateZoneType type;
  93. int size;
  94. boost::optional<int> owner;
  95. CTownInfo playerTowns, neutralTowns;
  96. bool townsAreSameType;
  97. std::set<TFaction> townTypes;
  98. bool matchTerrainToTown;
  99. std::set<ETerrainType> terrainTypes;
  100. boost::optional<TRmgTemplateZoneId> terrainTypeLikeZone, townTypeLikeZone;
  101. std::vector<int3> shape;
  102. std::map<int3, CTileInfo> tileinfo;
  103. std::vector<CGObjectInstance*> objects;
  104. int3 getCenter();
  105. bool pointIsIn(int x, int y);
  106. bool findPlaceForObject(CMapGenerator* gen, CGObjectInstance* obj, si32 min_dist, int3 &pos);
  107. void checkAndPlaceObject(CMapGenerator* gen, CGObjectInstance* object, const int3 &pos);
  108. void placeObject(CMapGenerator* gen, CGObjectInstance* object, const int3 &pos);
  109. bool guardObject(CMapGenerator* gen, CGObjectInstance* object, si32 str);
  110. };