AILayerTransitionRule.h 1.7 KB

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