AILayerTransitionRule.h 1.8 KB

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