123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- /*
- * AIMovementToDestinationRule.cpp, part of VCMI engine
- *
- * Authors: listed in file AUTHORS in main folder
- *
- * License: GNU General Public License v2.0 or later
- * Full text of license available in license.txt file, in main folder
- *
- */
- #include "StdInc.h"
- #include "AIMovementToDestinationRule.h"
- namespace AIPathfinding
- {
- AIMovementToDestinationRule::AIMovementToDestinationRule(std::shared_ptr<AINodeStorage> nodeStorage)
- : nodeStorage(nodeStorage)
- {
- }
- void AIMovementToDestinationRule::process(
- const PathNodeInfo & source,
- CDestinationNodeInfo & destination,
- const PathfinderConfig * pathfinderConfig,
- CPathfinderHelper * pathfinderHelper) const
- {
- auto blocker = getBlockingReason(source, destination, pathfinderConfig, pathfinderHelper);
- if(blocker == BlockingReason::NONE)
- return;
- if(blocker == BlockingReason::DESTINATION_BLOCKED
- && destination.action == EPathNodeAction::EMBARK
- && nodeStorage->getAINode(destination.node)->specialAction)
- {
- return;
- }
- if(blocker == BlockingReason::SOURCE_GUARDED && nodeStorage->isBattleNode(source.node))
- {
- #ifdef VCMI_TRACE_PATHFINDER
- logAi->trace(
- "Bypass src guard while moving from %s to %s",
- source.coord.toString(),
- destination.coord.toString());
- #endif
- return;
- }
- destination.blocked = true;
- }
- }
|