2018-08-12 13:31:31 +02:00
|
|
|
/*
|
2018-12-01 10:30:37 +02:00
|
|
|
* AIPathfinderConfig.cpp, part of VCMI engine
|
2018-08-12 13:31:31 +02:00
|
|
|
*
|
|
|
|
* 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 "AIPathfinderConfig.h"
|
2019-02-06 14:51:12 +02:00
|
|
|
#include "Rules/AILayerTransitionRule.h"
|
|
|
|
#include "Rules/AIMovementAfterDestinationRule.h"
|
|
|
|
#include "Rules/AIMovementToDestinationRule.h"
|
|
|
|
#include "Rules/AIPreviousNodeRule.h"
|
2018-10-09 21:31:44 +02:00
|
|
|
|
2018-11-03 15:25:14 +02:00
|
|
|
namespace AIPathfinding
|
2018-10-09 21:31:44 +02:00
|
|
|
{
|
2018-11-03 15:25:14 +02:00
|
|
|
std::vector<std::shared_ptr<IPathfindingRule>> makeRuleset(
|
|
|
|
CPlayerSpecificInfoCallback * cb,
|
|
|
|
VCAI * ai,
|
|
|
|
std::shared_ptr<AINodeStorage> nodeStorage)
|
|
|
|
{
|
|
|
|
std::vector<std::shared_ptr<IPathfindingRule>> rules = {
|
|
|
|
std::make_shared<AILayerTransitionRule>(cb, ai, nodeStorage),
|
|
|
|
std::make_shared<DestinationActionRule>(),
|
2019-01-19 12:52:02 +02:00
|
|
|
std::make_shared<AIMovementToDestinationRule>(nodeStorage),
|
2018-11-03 15:25:14 +02:00
|
|
|
std::make_shared<MovementCostRule>(),
|
2019-01-19 12:52:02 +02:00
|
|
|
std::make_shared<AIPreviousNodeRule>(nodeStorage),
|
2018-11-03 15:25:14 +02:00
|
|
|
std::make_shared<AIMovementAfterDestinationRule>(cb, nodeStorage)
|
|
|
|
};
|
|
|
|
|
|
|
|
return rules;
|
|
|
|
}
|
2018-08-12 13:31:31 +02:00
|
|
|
|
2018-11-03 15:25:14 +02:00
|
|
|
AIPathfinderConfig::AIPathfinderConfig(
|
|
|
|
CPlayerSpecificInfoCallback * cb,
|
|
|
|
VCAI * ai,
|
|
|
|
std::shared_ptr<AINodeStorage> nodeStorage)
|
2021-05-16 19:53:11 +02:00
|
|
|
:PathfinderConfig(nodeStorage, makeRuleset(cb, ai, nodeStorage)), hero(nodeStorage->getHero())
|
2018-11-03 15:25:14 +02:00
|
|
|
{
|
|
|
|
}
|
2021-05-16 19:53:11 +02:00
|
|
|
|
|
|
|
CPathfinderHelper * AIPathfinderConfig::getOrCreatePathfinderHelper(const PathNodeInfo & source, CGameState * gs)
|
|
|
|
{
|
|
|
|
if(!helper)
|
|
|
|
{
|
|
|
|
helper.reset(new CPathfinderHelper(gs, hero, options));
|
|
|
|
}
|
|
|
|
|
|
|
|
return helper.get();
|
|
|
|
}
|
2018-10-10 15:07:28 +02:00
|
|
|
}
|