AccessibilityInfo.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /*
  2. * AccessibilityInfo.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 "../GameConstants.h"
  13. VCMI_LIB_NAMESPACE_BEGIN
  14. namespace battle
  15. {
  16. class Unit;
  17. }
  18. //Accessibility is property of hex in battle. It doesn't depend on stack, side's perspective and so on.
  19. enum class EAccessibility
  20. {
  21. ACCESSIBLE,
  22. ALIVE_STACK,
  23. OBSTACLE,
  24. DESTRUCTIBLE_WALL,
  25. GATE, //sieges -> gate opens only for defender stacks
  26. UNAVAILABLE, //indestructible wall parts, special battlefields (like boat-to-boat)
  27. SIDE_COLUMN //used for first and last columns of hexes that are unavailable but war machines can stand there
  28. };
  29. using TAccessibilityArray = std::array<EAccessibility, GameConstants::BFIELD_SIZE>;
  30. using TBattlefieldTurnsArray = std::array<int8_t, GameConstants::BFIELD_SIZE>;
  31. struct DLL_LINKAGE AccessibilityInfo : TAccessibilityArray
  32. {
  33. std::shared_ptr<const TBattlefieldTurnsArray> destructibleEnemyTurns; //used only as a view for destructibleEnemyTurns from ReachabilityInfo::Parameters
  34. public:
  35. bool accessible(const BattleHex & tile, const battle::Unit * stack) const; //checks for both tiles if stack is double wide
  36. bool accessible(const BattleHex & tile, bool doubleWide, BattleSide side) const; //checks for both tiles if stack is double wide
  37. private:
  38. bool tileAccessibleWithGate(const BattleHex & tile, BattleSide side) const;
  39. };
  40. VCMI_LIB_NAMESPACE_END