PathfinderOptions.cpp 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /*
  2. * CPathfinder.cpp, part of VCMI engine
  3. *
  4. * Authors: listed in file AUTHORS in main folder
  5. *
  6. * License: GNU General Public License v2.0 or later
  7. * Full text of license available in license.txt file, in main folder
  8. *
  9. */
  10. #include "StdInc.h"
  11. #include "PathfinderOptions.h"
  12. #include "../CConfigHandler.h"
  13. #include "NodeStorage.h"
  14. #include "PathfindingRules.h"
  15. #include "CPathfinder.h"
  16. VCMI_LIB_NAMESPACE_BEGIN
  17. PathfinderOptions::PathfinderOptions()
  18. {
  19. useFlying = settings["pathfinder"]["layers"]["flying"].Bool();
  20. useWaterWalking = settings["pathfinder"]["layers"]["waterWalking"].Bool();
  21. useEmbarkAndDisembark = settings["pathfinder"]["layers"]["sailing"].Bool();
  22. useTeleportTwoWay = settings["pathfinder"]["teleports"]["twoWay"].Bool();
  23. useTeleportOneWay = settings["pathfinder"]["teleports"]["oneWay"].Bool();
  24. useTeleportOneWayRandom = settings["pathfinder"]["teleports"]["oneWayRandom"].Bool();
  25. useTeleportWhirlpool = settings["pathfinder"]["teleports"]["whirlpool"].Bool();
  26. useCastleGate = settings["pathfinder"]["teleports"]["castleGate"].Bool();
  27. lightweightFlyingMode = settings["pathfinder"]["lightweightFlyingMode"].Bool();
  28. oneTurnSpecialLayersLimit = settings["pathfinder"]["oneTurnSpecialLayersLimit"].Bool();
  29. originalMovementRules = settings["pathfinder"]["originalMovementRules"].Bool();
  30. }
  31. PathfinderConfig::PathfinderConfig(std::shared_ptr<INodeStorage> nodeStorage, std::vector<std::shared_ptr<IPathfindingRule>> rules):
  32. nodeStorage(std::move(nodeStorage)),
  33. rules(std::move(rules))
  34. {
  35. }
  36. std::vector<std::shared_ptr<IPathfindingRule>> SingleHeroPathfinderConfig::buildRuleSet()
  37. {
  38. return std::vector<std::shared_ptr<IPathfindingRule>>{
  39. std::make_shared<LayerTransitionRule>(),
  40. std::make_shared<DestinationActionRule>(),
  41. std::make_shared<MovementToDestinationRule>(),
  42. std::make_shared<MovementCostRule>(),
  43. std::make_shared<MovementAfterDestinationRule>()
  44. };
  45. }
  46. SingleHeroPathfinderConfig::~SingleHeroPathfinderConfig() = default;
  47. SingleHeroPathfinderConfig::SingleHeroPathfinderConfig(CPathsInfo & out, CGameState * gs, const CGHeroInstance * hero)
  48. : PathfinderConfig(std::make_shared<NodeStorage>(out, hero), buildRuleSet())
  49. {
  50. pathfinderHelper = std::make_unique<CPathfinderHelper>(gs, hero, options);
  51. }
  52. CPathfinderHelper * SingleHeroPathfinderConfig::getOrCreatePathfinderHelper(const PathNodeInfo & source, CGameState * gs)
  53. {
  54. return pathfinderHelper.get();
  55. }
  56. VCMI_LIB_NAMESPACE_END