TurnInfo.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /*
  2. * TurnInfo.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 "../bonuses/Bonus.h"
  12. #include "../bonuses/BonusSelector.h"
  13. #include "../bonuses/BonusCache.h"
  14. VCMI_LIB_NAMESPACE_BEGIN
  15. class CGHeroInstance;
  16. class TurnInfoBonusList
  17. {
  18. TConstBonusListPtr bonusList;
  19. std::mutex bonusListMutex;
  20. std::atomic<int64_t> bonusListVersion = 0;
  21. public:
  22. TConstBonusListPtr getBonusList(const CGHeroInstance * target, const CSelector & bonusSelector);
  23. };
  24. struct TurnInfoCache
  25. {
  26. TurnInfoBonusList waterWalking;
  27. TurnInfoBonusList flyingMovement;
  28. TurnInfoBonusList noTerrainPenalty;
  29. TurnInfoBonusList freeShipBoarding;
  30. TurnInfoBonusList roughTerrainDiscount;
  31. TurnInfoBonusList baseTileMovementCost;
  32. TurnInfoBonusList movementPointsLimitLand;
  33. TurnInfoBonusList movementPointsLimitWater;
  34. const CGHeroInstance * target;
  35. mutable std::atomic<int64_t> heroLowestSpeedVersion = 0;
  36. mutable std::atomic<int64_t> heroLowestSpeedValue = 0;
  37. explicit TurnInfoCache(const CGHeroInstance * target):
  38. target(target)
  39. {}
  40. };
  41. class DLL_LINKAGE TurnInfo
  42. {
  43. private:
  44. const CGHeroInstance * target;
  45. // stores cached values per each terrain
  46. std::vector<bool> noterrainPenalty;
  47. int flyingMovementValue;
  48. int waterWalkingValue;
  49. int roughTerrainDiscountValue;
  50. int moveCostBaseValue;
  51. int movePointsLimitLand;
  52. int movePointsLimitWater;
  53. bool waterWalkingTest;
  54. bool flyingMovementTest;
  55. bool freeShipBoardingTest;
  56. public:
  57. int hasWaterWalking() const;
  58. int hasFlyingMovement() const;
  59. int hasNoTerrainPenalty(const TerrainId & terrain) const;
  60. int hasFreeShipBoarding() const;
  61. int getFlyingMovementValue() const;
  62. int getWaterWalkingValue() const;
  63. int getRoughTerrainDiscountValue() const;
  64. int getMovementCostBase() const;
  65. int getMovePointsLimitLand() const;
  66. int getMovePointsLimitWater() const;
  67. TurnInfo(TurnInfoCache * sharedCache, const CGHeroInstance * target, int Turn);
  68. bool isLayerAvailable(const EPathfindingLayer & layer) const;
  69. int getMaxMovePoints(const EPathfindingLayer & layer) const;
  70. };
  71. VCMI_LIB_NAMESPACE_END