AILayerTransitionRule.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /*
  2. * AILayerTransitionRule.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 "../AINodeStorage.h"
  12. #include "../../AIGateway.h"
  13. #include "../Actions/BoatActions.h"
  14. #include "../Actions/AdventureSpellCastMovementActions.h"
  15. #include "../../../../CCallback.h"
  16. #include "../../../../lib/mapObjects/MapObjects.h"
  17. #include "../../../../lib/pathfinder/PathfindingRules.h"
  18. namespace NKAI
  19. {
  20. namespace AIPathfinding
  21. {
  22. class AILayerTransitionRule : public LayerTransitionRule
  23. {
  24. private:
  25. CPlayerSpecificInfoCallback * cb;
  26. Nullkiller * ai;
  27. std::map<int3, std::shared_ptr<const BuildBoatAction>> virtualBoats;
  28. std::shared_ptr<AINodeStorage> nodeStorage;
  29. std::map<const CGHeroInstance *, std::shared_ptr<const SummonBoatAction>> summonableVirtualBoats;
  30. std::map<const CGHeroInstance *, std::shared_ptr<const WaterWalkingAction>> waterWalkingActions;
  31. std::map<const CGHeroInstance *, std::shared_ptr<const AirWalkingAction>> airWalkingActions;
  32. public:
  33. AILayerTransitionRule(
  34. CPlayerSpecificInfoCallback * cb,
  35. Nullkiller * ai,
  36. std::shared_ptr<AINodeStorage> nodeStorage);
  37. virtual void process(
  38. const PathNodeInfo & source,
  39. CDestinationNodeInfo & destination,
  40. const PathfinderConfig * pathfinderConfig,
  41. CPathfinderHelper * pathfinderHelper) const override;
  42. private:
  43. void setup();
  44. void collectVirtualBoats();
  45. std::shared_ptr<const VirtualBoatAction> findVirtualBoat(
  46. CDestinationNodeInfo & destination,
  47. const PathNodeInfo & source) const;
  48. bool tryUseSpecialAction(
  49. CDestinationNodeInfo & destination,
  50. const PathNodeInfo & source,
  51. std::shared_ptr<const SpecialAction> specialAction,
  52. EPathNodeAction targetAction) const;
  53. };
  54. }
  55. }