RmgPath.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /*
  2. * RmgPath.h, 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. #pragma once
  11. #include "../GameConstants.h"
  12. #include "../int3.h"
  13. #include "RmgArea.h"
  14. VCMI_LIB_NAMESPACE_BEGIN
  15. namespace rmg
  16. {
  17. class Path
  18. {
  19. public:
  20. using MoveCostFunction = std::function<float(const int3 &, const int3 &)>;
  21. const static MoveCostFunction DEFAULT_MOVEMENT_FUNCTION;
  22. Path(const Area & area);
  23. Path(const Area & area, const int3 & src);
  24. Path(const Path & path) = default;
  25. Path & operator= (const Path & path);
  26. bool valid() const;
  27. Path search(const Tileset & dst, bool straight, std::function<float(const int3 &, const int3 &)> moveCostFunction = DEFAULT_MOVEMENT_FUNCTION) const;
  28. Path search(const int3 & dst, bool straight, std::function<float(const int3 &, const int3 &)> moveCostFunction = DEFAULT_MOVEMENT_FUNCTION) const;
  29. Path search(const Area & dst, bool straight, std::function<float(const int3 &, const int3 &)> moveCostFunction = DEFAULT_MOVEMENT_FUNCTION) const;
  30. Path search(const Path & dst, bool straight, std::function<float(const int3 &, const int3 &)> moveCostFunction = DEFAULT_MOVEMENT_FUNCTION) const;
  31. void connect(const Path & path);
  32. void connect(const int3 & path); //TODO: force connection?
  33. void connect(const Area & path); //TODO: force connection?
  34. void connect(const Tileset & path); //TODO: force connection?
  35. const Area & getPathArea() const;
  36. static Path invalid();
  37. static MoveCostFunction createCurvedCostFunction(const Area & border);
  38. static float nonEuclideanCostFunction(const int3& src, const int3& dst, const int3& center);
  39. private:
  40. const Area * dArea = nullptr;
  41. Area dPath;
  42. };
  43. }
  44. VCMI_LIB_NAMESPACE_END