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