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

56 lines
1.3 KiB
C++
Raw Normal View History

2021-05-15 18:22:44 +02:00
/*
* PathfindingManager.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 "PathfindingManager.h"
#include "AIPathfinder.h"
#include "AIPathfinderConfig.h"
#include "../Goals/Goals.h"
#include "../../../lib/CGameInfoCallback.h"
#include "../../../lib/mapping/CMap.h"
PathfindingManager::PathfindingManager(CPlayerSpecificInfoCallback * CB, VCAI * AI)
: ai(AI), cb(CB)
{
}
void PathfindingManager::init(CPlayerSpecificInfoCallback * CB)
{
cb = CB;
pathfinder.reset(new AIPathfinder(cb, ai));
pathfinder->init();
}
void PathfindingManager::setAI(VCAI * AI)
{
ai = AI;
}
std::vector<AIPath> PathfindingManager::getPathsToTile(const HeroPtr & hero, const int3 & tile) const
{
2021-05-15 20:56:31 +02:00
auto paths = pathfinder->getPathInfo(tile);
vstd::erase_if(paths, [&](AIPath & path) -> bool{
return path.targetHero != hero.h;
});
return paths;
}
std::vector<AIPath> PathfindingManager::getPathsToTile(const int3 & tile) const
{
return pathfinder->getPathInfo(tile);
2021-05-15 18:22:44 +02:00
}
2021-05-15 20:04:48 +02:00
void PathfindingManager::updatePaths(std::vector<HeroPtr> heroes, bool useHeroChain)
2021-05-15 18:22:44 +02:00
{
logAi->debug("AIPathfinder has been reseted.");
2021-05-15 20:04:48 +02:00
pathfinder->updatePaths(heroes, useHeroChain);
2021-05-15 18:22:44 +02:00
}