2023-10-19 16:19:09 +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
2024-09-28 20:50:26 +02:00
# include "BattleHexArray.h"
2023-10-19 16:19:09 +02:00
# include "CBattleInfoEssentials.h"
# include "AccessibilityInfo.h"
VCMI_LIB_NAMESPACE_BEGIN
2024-09-28 20:50:26 +02:00
class BattleHexArray ;
2023-10-19 16:19:09 +02:00
// Reachability info is result of BFS calculation. It's dependent on stack (it's owner, whether it's flying),
2024-06-24 03:23:26 +02:00
// startPosition and perspective.
2023-10-19 16:19:09 +02:00
struct DLL_LINKAGE ReachabilityInfo
{
using TDistances = std : : array < uint32_t , GameConstants : : BFIELD_SIZE > ;
using TPredecessors = std : : array < BattleHex , GameConstants : : BFIELD_SIZE > ;
enum { INFINITE_DIST = 1000000 } ;
struct DLL_LINKAGE Parameters
{
2024-08-11 20:22:35 +00:00
BattleSide side = BattleSide : : NONE ;
2023-10-19 16:19:09 +02:00
bool doubleWide = false ;
bool flying = false ;
bool ignoreKnownAccessible = false ; //Ignore obstacles if it is in accessible hexes
2024-07-19 13:44:44 +03:00
bool bypassEnemyStacks = false ; // in case of true will count amount of turns needed to kill enemy and thus move forward
2024-12-04 21:37:31 +01:00
const BattleHexArray * 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)
2025-01-06 23:05:45 +01:00
TBattlefieldTurnsArray destructibleEnemyTurns ; // how many turns it is needed to kill enemy on specific hex (index <=> hex)
2023-10-19 16:19:09 +02:00
BattleHex startPosition ; //assumed position of stack
2024-08-11 20:22:35 +00:00
BattleSide perspective = BattleSide : : ALL_KNOWING ; //some obstacles (eg. quicksands) may be invisible for some side
2023-10-19 16:19:09 +02:00
2024-12-02 13:06:58 +01:00
Parameters ( )
{
destructibleEnemyTurns . fill ( - 1 ) ;
}
2023-10-19 16:19:09 +02:00
Parameters ( const battle : : Unit * Stack , BattleHex StartPosition ) ;
} ;
Parameters params ;
AccessibilityInfo accessibility ;
TDistances distances ;
TPredecessors predecessors ;
ReachabilityInfo ( ) ;
bool isReachable ( BattleHex hex ) const ;
uint32_t distToNearestNeighbour (
2024-09-28 20:50:26 +02:00
const BattleHexArray & targetHexes ,
2023-10-19 16:19:09 +02:00
BattleHex * chosenHex = nullptr ) const ;
uint32_t distToNearestNeighbour (
const battle : : Unit * attacker ,
const battle : : Unit * defender ,
BattleHex * chosenHex = nullptr ) const ;
} ;
VCMI_LIB_NAMESPACE_END