Nullkiller.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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 "../Analyzers/ObjectClusterizer.h"
  15. #include "../Goals/AbstractGoal.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. const CGHeroInstance * activeHero;
  29. int3 targetTile;
  30. std::map<const CGHeroInstance *, HeroLockedReason> lockedHeroes;
  31. public:
  32. std::unique_ptr<DangerHitMapAnalyzer> dangerHitMap;
  33. std::unique_ptr<BuildAnalyzer> buildAnalyzer;
  34. std::unique_ptr<ObjectClusterizer> objectClusterizer;
  35. std::unique_ptr<PriorityEvaluator> priorityEvaluator;
  36. Nullkiller();
  37. void makeTurn();
  38. bool isActive(const CGHeroInstance * hero) const { return activeHero == hero; }
  39. bool isHeroLocked(const CGHeroInstance * hero) const;
  40. HeroPtr getActiveHero() { return activeHero; }
  41. HeroLockedReason getHeroLockedReason(const CGHeroInstance * hero) const;
  42. int3 getTargetTile() const { return targetTile; }
  43. void setActive(const CGHeroInstance * hero, int3 tile) { activeHero = hero; targetTile = tile; }
  44. void lockHero(const CGHeroInstance * hero, HeroLockedReason lockReason) { lockedHeroes[hero] = lockReason; }
  45. void unlockHero(const CGHeroInstance * hero) { lockedHeroes.erase(hero); }
  46. bool arePathHeroesLocked(const AIPath & path) const;
  47. private:
  48. void resetAiState();
  49. void updateAiState();
  50. Goals::TTask choseBestTask(Goals::TSubgoal behavior) const;
  51. Goals::TTask choseBestTask(Goals::TTaskVec & tasks) const;
  52. };