2023-06-21 12:46:09 +02:00
|
|
|
/*
|
|
|
|
* CPathfinder.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 "PathfinderOptions.h"
|
|
|
|
|
2024-08-31 13:00:36 +02:00
|
|
|
#include "../gameState/CGameState.h"
|
|
|
|
#include "../IGameSettings.h"
|
2023-06-22 16:03:18 +02:00
|
|
|
#include "../VCMI_Lib.h"
|
2023-06-21 12:46:09 +02:00
|
|
|
#include "NodeStorage.h"
|
|
|
|
#include "PathfindingRules.h"
|
|
|
|
#include "CPathfinder.h"
|
|
|
|
|
2023-06-21 12:51:31 +02:00
|
|
|
VCMI_LIB_NAMESPACE_BEGIN
|
|
|
|
|
2024-08-31 13:00:36 +02:00
|
|
|
PathfinderOptions::PathfinderOptions(const CGameInfoCallback * cb)
|
2023-06-22 16:03:18 +02:00
|
|
|
: useFlying(true)
|
|
|
|
, useWaterWalking(true)
|
2024-08-31 13:00:36 +02:00
|
|
|
, ignoreGuards(cb->getSettings().getBoolean(EGameSettings::PATHFINDER_IGNORE_GUARDS))
|
|
|
|
, useEmbarkAndDisembark(cb->getSettings().getBoolean(EGameSettings::PATHFINDER_USE_BOAT))
|
|
|
|
, useTeleportTwoWay(cb->getSettings().getBoolean(EGameSettings::PATHFINDER_USE_MONOLITH_TWO_WAY))
|
|
|
|
, useTeleportOneWay(cb->getSettings().getBoolean(EGameSettings::PATHFINDER_USE_MONOLITH_ONE_WAY_UNIQUE))
|
|
|
|
, useTeleportOneWayRandom(cb->getSettings().getBoolean(EGameSettings::PATHFINDER_USE_MONOLITH_ONE_WAY_RANDOM))
|
|
|
|
, useTeleportWhirlpool(cb->getSettings().getBoolean(EGameSettings::PATHFINDER_USE_WHIRLPOOL))
|
|
|
|
, originalFlyRules(cb->getSettings().getBoolean(EGameSettings::PATHFINDER_ORIGINAL_FLY_RULES))
|
2023-06-22 16:03:18 +02:00
|
|
|
, useCastleGate(false)
|
|
|
|
, lightweightFlyingMode(false)
|
|
|
|
, oneTurnSpecialLayersLimit(true)
|
2023-09-19 21:26:38 +02:00
|
|
|
, turnLimit(std::numeric_limits<uint8_t>::max())
|
2023-09-16 11:33:02 +02:00
|
|
|
, canUseCast(false)
|
2024-05-05 12:52:57 +02:00
|
|
|
, allowLayerTransitioningAfterBattle(false)
|
2024-07-20 17:36:07 +02:00
|
|
|
, forceUseTeleportWhirlpool(false)
|
2023-06-21 12:46:09 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2024-08-31 13:00:36 +02:00
|
|
|
PathfinderConfig::PathfinderConfig(std::shared_ptr<INodeStorage> nodeStorage, const CGameInfoCallback * callback, std::vector<std::shared_ptr<IPathfindingRule>> rules):
|
2023-06-21 12:46:09 +02:00
|
|
|
nodeStorage(std::move(nodeStorage)),
|
2024-08-31 13:00:36 +02:00
|
|
|
rules(std::move(rules)),
|
|
|
|
options(callback)
|
2023-06-21 12:46:09 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
std::vector<std::shared_ptr<IPathfindingRule>> SingleHeroPathfinderConfig::buildRuleSet()
|
|
|
|
{
|
|
|
|
return std::vector<std::shared_ptr<IPathfindingRule>>{
|
|
|
|
std::make_shared<LayerTransitionRule>(),
|
|
|
|
std::make_shared<DestinationActionRule>(),
|
|
|
|
std::make_shared<MovementToDestinationRule>(),
|
|
|
|
std::make_shared<MovementCostRule>(),
|
|
|
|
std::make_shared<MovementAfterDestinationRule>()
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
SingleHeroPathfinderConfig::~SingleHeroPathfinderConfig() = default;
|
|
|
|
|
|
|
|
SingleHeroPathfinderConfig::SingleHeroPathfinderConfig(CPathsInfo & out, CGameState * gs, const CGHeroInstance * hero)
|
2024-08-31 13:00:36 +02:00
|
|
|
: PathfinderConfig(std::make_shared<NodeStorage>(out, hero), gs, buildRuleSet())
|
2023-06-21 12:46:09 +02:00
|
|
|
{
|
|
|
|
pathfinderHelper = std::make_unique<CPathfinderHelper>(gs, hero, options);
|
|
|
|
}
|
|
|
|
|
|
|
|
CPathfinderHelper * SingleHeroPathfinderConfig::getOrCreatePathfinderHelper(const PathNodeInfo & source, CGameState * gs)
|
|
|
|
{
|
|
|
|
return pathfinderHelper.get();
|
|
|
|
}
|
2023-06-21 12:51:31 +02:00
|
|
|
|
|
|
|
VCMI_LIB_NAMESPACE_END
|