ReachabilityInfo.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. // Reachability info is result of BFS calculation. It's dependent on stack (it's owner, whether it's flying),
  15. // startPosition and perpective.
  16. struct DLL_LINKAGE ReachabilityInfo
  17. {
  18. typedef std::array<int, GameConstants::BFIELD_SIZE> TDistances;
  19. typedef std::array<BattleHex, GameConstants::BFIELD_SIZE> TPredecessors;
  20. enum { INFINITE_DIST = 1000000 };
  21. struct DLL_LINKAGE Parameters
  22. {
  23. ui8 side;
  24. bool doubleWide;
  25. bool flying;
  26. 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)
  27. BattleHex startPosition; //assumed position of stack
  28. BattlePerspective::BattlePerspective perspective; //some obstacles (eg. quicksands) may be invisible for some side
  29. Parameters();
  30. Parameters(const battle::Unit * Stack, BattleHex StartPosition);
  31. };
  32. Parameters params;
  33. AccessibilityInfo accessibility;
  34. TDistances distances;
  35. TPredecessors predecessors;
  36. ReachabilityInfo();
  37. bool isReachable(BattleHex hex) const;
  38. int distToNearestNeighbour(
  39. const battle::Unit * attacker,
  40. const battle::Unit * defender,
  41. BattleHex * chosenHex = nullptr) const;
  42. };