ReachabilityInfo.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*
  2. * ReachabilityInfo.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 "BattleHex.h"
  12. #include "CBattleInfoEssentials.h"
  13. #include "AccessibilityInfo.h"
  14. VCMI_LIB_NAMESPACE_BEGIN
  15. // Reachability info is result of BFS calculation. It's dependent on stack (it's owner, whether it's flying),
  16. // startPosition and perpective.
  17. struct DLL_LINKAGE ReachabilityInfo
  18. {
  19. typedef std::array<uint32_t, GameConstants::BFIELD_SIZE> TDistances;
  20. typedef std::array<BattleHex, GameConstants::BFIELD_SIZE> TPredecessors;
  21. enum { INFINITE_DIST = 1000000 };
  22. struct DLL_LINKAGE Parameters
  23. {
  24. ui8 side;
  25. bool doubleWide;
  26. bool flying;
  27. std::vector<BattleHex> knownAccessible; //hexes that will be treated as accessible, even if they're occupied by stack (by default - tiles occupied by stack we do reachability for, so it doesn't block itself)
  28. BattleHex startPosition; //assumed position of stack
  29. BattlePerspective::BattlePerspective perspective; //some obstacles (eg. quicksands) may be invisible for some side
  30. Parameters();
  31. Parameters(const battle::Unit * Stack, BattleHex StartPosition);
  32. };
  33. Parameters params;
  34. AccessibilityInfo accessibility;
  35. TDistances distances;
  36. TPredecessors predecessors;
  37. ReachabilityInfo();
  38. bool isReachable(BattleHex hex) const;
  39. uint32_t distToNearestNeighbour(
  40. const std::vector<BattleHex> & targetHexes,
  41. BattleHex * chosenHex = nullptr) const;
  42. uint32_t distToNearestNeighbour(
  43. const battle::Unit * attacker,
  44. const battle::Unit * defender,
  45. BattleHex * chosenHex = nullptr) const;
  46. };
  47. VCMI_LIB_NAMESPACE_END