AIhelper.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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;
  40. bool hasTasksLeft() const override;
  41. bool getBuildingOptions(const CGTownInstance * t) override;
  42. BuildingID getMaxPossibleGoldBuilding(const CGTownInstance * t);
  43. boost::optional<PotentialBuilding> immediateBuilding() const override;
  44. boost::optional<PotentialBuilding> expensiveBuilding() const override;
  45. boost::optional<BuildingID> canBuildAnyStructure(const CGTownInstance * t, const std::vector<BuildingID> & buildList, unsigned int maxDays = 7) const override;
  46. Goals::TGoalVec howToVisitTile(HeroPtr hero, int3 tile, bool allowGatherArmy = true) override;
  47. Goals::TGoalVec howToVisitObj(HeroPtr hero, ObjectIdRef obj, bool allowGatherArmy = true) override;
  48. Goals::TGoalVec howToVisitTile(int3 tile) override;
  49. Goals::TGoalVec howToVisitObj(ObjectIdRef obj) override;
  50. std::vector<AIPath> getPathsToTile(HeroPtr hero, int3 tile) override;
  51. void resetPaths() override;
  52. private:
  53. bool notifyGoalCompleted(Goals::TSubgoal goal);
  54. void setCB(CPlayerSpecificInfoCallback * CB) override;
  55. void setAI(VCAI * AI) override;
  56. };