1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-14 10:12:59 +02:00
vcmi/AI/Nullkiller/Pathfinding/Rules/AIMovementToDestinationRule.cpp

56 lines
1.3 KiB
C++
Raw Normal View History

2021-05-15 18:22:44 +02:00
/*
* 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"
2022-09-26 20:01:07 +02:00
namespace NKAI
{
2021-05-15 18:22:44 +02:00
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
2021-05-15 18:22:44 +02:00
&& nodeStorage->getAINode(destination.node)->specialAction)
{
return;
}
2021-05-15 18:22:49 +02:00
if(blocker == BlockingReason::SOURCE_GUARDED && nodeStorage->getAINode(source.node)->actor->allowBattle)
2021-05-15 18:22:44 +02:00
{
2022-09-26 20:01:07 +02:00
#if NKAI_PATHFINDER_TRACE_LEVEL >= 1
2021-05-15 18:22:44 +02:00
logAi->trace(
"Bypass src guard while moving from %s to %s",
source.coord.toString(),
destination.coord.toString());
#endif
return;
}
destination.blocked = true;
}
}
2022-09-26 20:01:07 +02:00
}