Nullkiller.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /*
  2. * Nullkiller.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 "PriorityEvaluator.h"
  12. #include "DangerHitMapAnalyzer.h"
  13. #include "../Goals/AbstractGoal.h"
  14. #include "../Behaviors/Behavior.h"
  15. class Nullkiller
  16. {
  17. private:
  18. std::unique_ptr<PriorityEvaluator> priorityEvaluator;
  19. const CGHeroInstance * activeHero;
  20. std::set<const CGHeroInstance *> lockedHeroes;
  21. public:
  22. std::unique_ptr<DangerHitMapAnalyzer> dangerHitMap;
  23. Nullkiller();
  24. void makeTurn();
  25. bool isActive(const CGHeroInstance * hero) const { return activeHero == hero; }
  26. bool isHeroLocked(const CGHeroInstance * hero) const { return vstd::contains(lockedHeroes, hero); }
  27. void setActive(const CGHeroInstance * hero) { activeHero = hero; }
  28. void lockHero(const CGHeroInstance * hero) { lockedHeroes.insert(hero); }
  29. void unlockHero(const CGHeroInstance * hero) { lockedHeroes.erase(hero); }
  30. bool canMove(const CGHeroInstance * hero) { return hero->movement; }
  31. private:
  32. void resetAiState();
  33. void updateAiState();
  34. Goals::TSubgoal choseBestTask(std::shared_ptr<Behavior> behavior) const;
  35. Goals::TSubgoal choseBestTask(Goals::TGoalVec & tasks) const;
  36. };