AIPreviousNodeRule.cpp 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. /*
  2. * AIPreviousNodeRule.cpp, 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. #include "StdInc.h"
  11. #include "AIPreviousNodeRule.h"
  12. namespace AIPathfinding
  13. {
  14. AIPreviousNodeRule::AIPreviousNodeRule(std::shared_ptr<AINodeStorage> nodeStorage)
  15. : nodeStorage(nodeStorage)
  16. {
  17. }
  18. void AIPreviousNodeRule::process(
  19. const PathNodeInfo & source,
  20. CDestinationNodeInfo & destination,
  21. const PathfinderConfig * pathfinderConfig,
  22. CPathfinderHelper * pathfinderHelper) const
  23. {
  24. if(source.node->action == CGPathNode::ENodeAction::BLOCKING_VISIT || source.node->action == CGPathNode::ENodeAction::VISIT)
  25. {
  26. // we can not directly bypass objects, we need to interact with them first
  27. destination.node->theNodeBefore = source.node;
  28. #ifdef VCMI_TRACE_PATHFINDER
  29. logAi->trace(
  30. "Link src node %s to destination node %s while bypassing visitable obj",
  31. source.coord.toString(),
  32. destination.coord.toString());
  33. #endif
  34. return;
  35. }
  36. }
  37. }