2017-06-24 15:51:07 +02:00
/*
* ReachabilityInfo . h , part of VCMI engine
*
* Authors : listed in file AUTHORS in main folder
*
* License : GNU General Public License v2 .0 or later
* Full text of license available in license . txt file , in main folder
*
*/
# pragma once
# include "BattleHex.h"
# include "CBattleInfoEssentials.h"
# include "AccessibilityInfo.h"
2022-07-26 15:07:42 +02:00
VCMI_LIB_NAMESPACE_BEGIN
2017-06-24 15:51:07 +02:00
// Reachability info is result of BFS calculation. It's dependent on stack (it's owner, whether it's flying),
// startPosition and perpective.
struct DLL_LINKAGE ReachabilityInfo
{
2023-02-15 00:44:59 +02:00
using TDistances = std : : array < uint32_t , GameConstants : : BFIELD_SIZE > ;
using TPredecessors = std : : array < BattleHex , GameConstants : : BFIELD_SIZE > ;
2017-06-24 15:51:07 +02:00
2017-06-26 18:50:35 +02:00
enum { INFINITE_DIST = 1000000 } ;
2017-06-24 15:51:07 +02:00
struct DLL_LINKAGE Parameters
{
2023-02-15 00:44:59 +02:00
ui8 side = 0 ;
bool doubleWide = false ;
bool flying = false ;
2023-03-25 22:17:54 +02:00
bool ignoreKnownAccessible = false ; //Ignore obstacles if it is in accessible hexes
2017-06-24 15:51:07 +02:00
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)
BattleHex startPosition ; //assumed position of stack
2023-02-15 00:44:59 +02:00
BattlePerspective : : BattlePerspective perspective = BattlePerspective : : ALL_KNOWING ; //some obstacles (eg. quicksands) may be invisible for some side
2017-06-24 15:51:07 +02:00
2023-02-15 00:44:59 +02:00
Parameters ( ) = default ;
2017-07-20 06:08:49 +02:00
Parameters ( const battle : : Unit * Stack , BattleHex StartPosition ) ;
2017-06-24 15:51:07 +02:00
} ;
Parameters params ;
AccessibilityInfo accessibility ;
TDistances distances ;
TPredecessors predecessors ;
ReachabilityInfo ( ) ;
bool isReachable ( BattleHex hex ) const ;
2020-11-23 08:40:36 +02:00
2022-12-08 23:20:42 +02:00
uint32_t distToNearestNeighbour (
2020-11-28 17:11:33 +02:00
const std : : vector < BattleHex > & targetHexes ,
BattleHex * chosenHex = nullptr ) const ;
2022-12-08 23:20:42 +02:00
uint32_t distToNearestNeighbour (
2020-11-23 08:40:36 +02:00
const battle : : Unit * attacker ,
const battle : : Unit * defender ,
BattleHex * chosenHex = nullptr ) const ;
2017-06-24 15:51:07 +02:00
} ;
2022-07-26 15:07:42 +02:00
VCMI_LIB_NAMESPACE_END