AIhelper.cpp 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. /*
  2. * AIhelper.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. #include "StdInc.h"
  11. #include "AIhelper.h"
  12. #include "ResourceManager.h"
  13. #include "BuildingManager.h"
  14. AIhelper::AIhelper()
  15. {
  16. resourceManager.reset(new ResourceManager());
  17. buildingManager.reset(new BuildingManager());
  18. pathfindingManager.reset(new PathfindingManager());
  19. }
  20. AIhelper::~AIhelper()
  21. {
  22. }
  23. bool AIhelper::notifyGoalCompleted(Goals::TSubgoal goal)
  24. {
  25. return resourceManager->notifyGoalCompleted(goal);
  26. }
  27. void AIhelper::init(CPlayerSpecificInfoCallback * CB)
  28. {
  29. resourceManager->init(CB);
  30. buildingManager->init(CB);
  31. pathfindingManager->init(CB);
  32. }
  33. void AIhelper::setAI(VCAI * AI)
  34. {
  35. resourceManager->setAI(AI);
  36. buildingManager->setAI(AI);
  37. pathfindingManager->setAI(AI);
  38. }
  39. bool AIhelper::getBuildingOptions(const CGTownInstance * t)
  40. {
  41. return buildingManager->getBuildingOptions(t);
  42. }
  43. BuildingID AIhelper::getMaxPossibleGoldBuilding(const CGTownInstance * t)
  44. {
  45. return buildingManager->getMaxPossibleGoldBuilding(t);
  46. }
  47. boost::optional<PotentialBuilding> AIhelper::immediateBuilding() const
  48. {
  49. return buildingManager->immediateBuilding();
  50. }
  51. boost::optional<PotentialBuilding> AIhelper::expensiveBuilding() const
  52. {
  53. return buildingManager->expensiveBuilding();
  54. }
  55. boost::optional<BuildingID> AIhelper::canBuildAnyStructure(const CGTownInstance * t, const std::vector<BuildingID> & buildList, unsigned int maxDays) const
  56. {
  57. return buildingManager->canBuildAnyStructure(t, buildList, maxDays);
  58. }
  59. Goals::TSubgoal AIhelper::whatToDo(TResources & res, Goals::TSubgoal goal)
  60. {
  61. return resourceManager->whatToDo(res, goal);
  62. }
  63. Goals::TSubgoal AIhelper::whatToDo() const
  64. {
  65. return resourceManager->whatToDo();
  66. }
  67. bool AIhelper::containsObjective(Goals::TSubgoal goal) const
  68. {
  69. return resourceManager->containsObjective(goal);
  70. }
  71. bool AIhelper::hasTasksLeft() const
  72. {
  73. return resourceManager->hasTasksLeft();
  74. }
  75. bool AIhelper::canAfford(const TResources & cost) const
  76. {
  77. return resourceManager->canAfford(cost);
  78. }
  79. TResources AIhelper::reservedResources() const
  80. {
  81. return resourceManager->reservedResources();
  82. }
  83. TResources AIhelper::freeResources() const
  84. {
  85. return resourceManager->freeResources();
  86. }
  87. TResource AIhelper::freeGold() const
  88. {
  89. return resourceManager->freeGold();
  90. }
  91. TResources AIhelper::allResources() const
  92. {
  93. return resourceManager->allResources();
  94. }
  95. TResource AIhelper::allGold() const
  96. {
  97. return resourceManager->allGold();
  98. }
  99. Goals::TGoalVec AIhelper::howToVisitTile(int3 tile)
  100. {
  101. return pathfindingManager->howToVisitTile(tile);
  102. }
  103. Goals::TGoalVec AIhelper::howToVisitObj(ObjectIdRef obj)
  104. {
  105. return pathfindingManager->howToVisitObj(obj);
  106. }
  107. Goals::TGoalVec AIhelper::howToVisitTile(HeroPtr hero, int3 tile, bool allowGatherArmy)
  108. {
  109. return pathfindingManager->howToVisitTile(hero, tile, allowGatherArmy);
  110. }
  111. Goals::TGoalVec AIhelper::howToVisitObj(HeroPtr hero, ObjectIdRef obj, bool allowGatherArmy)
  112. {
  113. return pathfindingManager->howToVisitObj(hero, obj, allowGatherArmy);
  114. }
  115. std::vector<AIPath> AIhelper::getPathsToTile(HeroPtr hero, int3 tile)
  116. {
  117. return pathfindingManager->getPathsToTile(hero, tile);
  118. }
  119. bool AIhelper::isTileAccessible(HeroPtr hero, int3 tile)
  120. {
  121. return pathfindingManager->isTileAccessible(hero, tile);
  122. }
  123. void AIhelper::resetPaths()
  124. {
  125. pathfindingManager->resetPaths();
  126. }