Nullkiller.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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 "../Analyzers/DangerHitMapAnalyzer.h"
  13. #include "../Analyzers/BuildAnalyzer.h"
  14. #include "../Goals/AbstractGoal.h"
  15. #include "../Behaviors/Behavior.h"
  16. const float MAX_GOLD_PEASURE = 0.3f;
  17. const float MIN_PRIORITY = 0.01f;
  18. enum class HeroLockedReason
  19. {
  20. NOT_LOCKED = 0,
  21. STARTUP = 1,
  22. DEFENCE = 2,
  23. HERO_CHAIN = 3
  24. };
  25. class Nullkiller
  26. {
  27. private:
  28. std::unique_ptr<PriorityEvaluator> priorityEvaluator;
  29. const CGHeroInstance * activeHero;
  30. int3 targetTile;
  31. std::map<const CGHeroInstance *, HeroLockedReason> lockedHeroes;
  32. public:
  33. std::unique_ptr<DangerHitMapAnalyzer> dangerHitMap;
  34. std::unique_ptr<BuildAnalyzer> buildAnalyzer;
  35. Nullkiller();
  36. void makeTurn();
  37. bool isActive(const CGHeroInstance * hero) const { return activeHero == hero; }
  38. bool isHeroLocked(const CGHeroInstance * hero) const;
  39. HeroPtr getActiveHero() { return activeHero; }
  40. HeroLockedReason getHeroLockedReason(const CGHeroInstance * hero) const;
  41. int3 getTargetTile() const { return targetTile; }
  42. void setActive(const CGHeroInstance * hero, int3 tile) { activeHero = hero; targetTile = tile; }
  43. void lockHero(const CGHeroInstance * hero, HeroLockedReason lockReason) { lockedHeroes[hero] = lockReason; }
  44. void unlockHero(const CGHeroInstance * hero) { lockedHeroes.erase(hero); }
  45. bool arePathHeroesLocked(const AIPath & path) const;
  46. private:
  47. void resetAiState();
  48. void updateAiState();
  49. Goals::TSubgoal choseBestTask(std::shared_ptr<Behavior> behavior) const;
  50. Goals::TSubgoal choseBestTask(Goals::TGoalVec & tasks) const;
  51. };