ReachabilityInfo.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. class CStack;
  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<int, 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. const CStack * stack; //stack for which calculation is mage => not required (kept for debugging mostly), following variables are enough
  25. ui8 side;
  26. bool doubleWide;
  27. bool flying;
  28. 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)
  29. BattleHex startPosition; //assumed position of stack
  30. BattlePerspective::BattlePerspective perspective; //some obstacles (eg. quicksands) may be invisible for some side
  31. Parameters();
  32. Parameters(const CStack * Stack);
  33. };
  34. Parameters params;
  35. AccessibilityInfo accessibility;
  36. TDistances distances;
  37. TPredecessors predecessors;
  38. ReachabilityInfo();
  39. bool isReachable(BattleHex hex) const;
  40. };