1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-04 09:42:40 +02:00
vcmi/AI/Nullkiller/Pathfinding/AIPathfinder.h

70 lines
1.7 KiB
C++
Raw Normal View History

2021-05-15 18:22:44 +02:00
/*
* AIPathfinder.h, 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
*
*/
#pragma once
#include "AINodeStorage.h"
#include "ObjectGraph.h"
2021-05-15 18:22:44 +02:00
#include "../AIUtility.h"
2022-09-26 20:01:07 +02:00
namespace NKAI
{
class Nullkiller;
2021-05-15 18:22:44 +02:00
struct PathfinderSettings
{
bool useHeroChain;
uint8_t scoutTurnDistanceLimit;
2021-05-16 14:01:34 +02:00
uint8_t mainTurnDistanceLimit;
bool allowBypassObjects;
PathfinderSettings()
:useHeroChain(false),
2021-05-16 14:01:34 +02:00
scoutTurnDistanceLimit(255),
mainTurnDistanceLimit(255),
allowBypassObjects(true)
{ }
};
2021-05-15 18:22:44 +02:00
class AIPathfinder
{
private:
std::shared_ptr<AINodeStorage> storage;
2021-05-15 18:22:44 +02:00
CPlayerSpecificInfoCallback * cb;
Nullkiller * ai;
2024-03-31 17:39:00 +02:00
static std::map<ObjectInstanceID, std::unique_ptr<GraphPaths>> heroGraphs;
2021-05-15 18:22:44 +02:00
public:
AIPathfinder(CPlayerSpecificInfoCallback * cb, Nullkiller * ai);
void calculatePathInfo(std::vector<AIPath> & paths, const int3 & tile, bool includeGraph = false) const;
2021-05-15 18:22:44 +02:00
bool isTileAccessible(const HeroPtr & hero, const int3 & tile) const;
2024-03-09 16:20:00 +02:00
void updatePaths(const std::map<const CGHeroInstance *, HeroRole> & heroes, PathfinderSettings pathfinderSettings);
2024-03-29 20:39:03 +02:00
void updateGraphs(const std::map<const CGHeroInstance *, HeroRole> & heroes, uint8_t mainScanDepth, uint8_t scoutScanDepth);
void calculateQuickPathsWithBlocker(std::vector<AIPath> & result, const std::vector<const CGHeroInstance *> & heroes, const int3 & tile);
2021-05-15 18:22:44 +02:00
void init();
std::shared_ptr<AINodeStorage>getStorage()
{
return storage;
}
std::vector<AIPath> getPathInfo(const int3 & tile, bool includeGraph = false)
{
std::vector<AIPath> result;
calculatePathInfo(result, tile, includeGraph);
return result;
}
2021-05-15 18:22:44 +02:00
};
2022-09-26 20:01:07 +02:00
}