AIhelper.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. #pragma once
  11. /*
  12. !!! Note: Include THIS file at the end of include list to avoid "undefined base class" error
  13. */
  14. #include "ResourceManager.h"
  15. #include "BuildingManager.h"
  16. #include "Pathfinding/PathfindingManager.h"
  17. class ResourceManager;
  18. class BuildingManager;
  19. //indirection interface for various modules
  20. class DLL_EXPORT AIhelper : public IResourceManager, public IBuildingManager, public IPathfindingManager
  21. {
  22. friend class VCAI;
  23. friend struct SetGlobalState; //mess?
  24. std::shared_ptr<ResourceManager> resourceManager;
  25. std::shared_ptr<BuildingManager> buildingManager;
  26. std::shared_ptr<PathfindingManager> pathfindingManager;
  27. //TODO: vector<IAbstractManager>
  28. public:
  29. AIhelper();
  30. ~AIhelper();
  31. bool canAfford(const TResources & cost) const;
  32. TResources reservedResources() const override;
  33. TResources freeResources() const override;
  34. TResource freeGold() const override;
  35. TResources allResources() const override;
  36. TResource allGold() const override;
  37. Goals::TSubgoal whatToDo(TResources &res, Goals::TSubgoal goal) override;
  38. Goals::TSubgoal whatToDo() const override;
  39. bool containsObjective(Goals::TSubgoal goal) const override;
  40. bool hasTasksLeft() const override;
  41. bool removeOutdatedObjectives(std::function<bool(const Goals::TSubgoal &)> predicate) override;
  42. bool getBuildingOptions(const CGTownInstance * t) override;
  43. BuildingID getMaxPossibleGoldBuilding(const CGTownInstance * t);
  44. boost::optional<PotentialBuilding> immediateBuilding() const override;
  45. boost::optional<PotentialBuilding> expensiveBuilding() const override;
  46. boost::optional<BuildingID> canBuildAnyStructure(const CGTownInstance * t, const std::vector<BuildingID> & buildList, unsigned int maxDays = 7) const override;
  47. Goals::TGoalVec howToVisitTile(HeroPtr hero, int3 tile, bool allowGatherArmy = true) override;
  48. Goals::TGoalVec howToVisitObj(HeroPtr hero, ObjectIdRef obj, bool allowGatherArmy = true) override;
  49. Goals::TGoalVec howToVisitTile(int3 tile) override;
  50. Goals::TGoalVec howToVisitObj(ObjectIdRef obj) override;
  51. std::vector<AIPath> getPathsToTile(HeroPtr hero, int3 tile) override;
  52. bool isTileAccessible(HeroPtr hero, int3 tile) override;
  53. void resetPaths() override;
  54. private:
  55. bool notifyGoalCompleted(Goals::TSubgoal goal) override;
  56. void init(CPlayerSpecificInfoCallback * CB) override;
  57. void setAI(VCAI * AI) override;
  58. };