AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
FarthestTargetSelector Struct Reference

#include "UnitAI.h"

Inheritance diagram for FarthestTargetSelector:
Acore::unary_function< Unit *, bool >

Public Member Functions

 FarthestTargetSelector (Unit const *unit, float maxDist, bool playerOnly, bool inLos, float minDist=0.f)
 
bool operator() (Unit const *target) const
 

Private Attributes

Unit const * _me
 
float _minDist
 
float _maxDist
 
bool _playerOnly
 
bool _inLos
 

Additional Inherited Members

- Public Types inherited from Acore::unary_function< Unit *, bool >
typedef Unitargument_type
 
typedef bool result_type
 

Detailed Description

Constructor & Destructor Documentation

◆ FarthestTargetSelector()

FarthestTargetSelector::FarthestTargetSelector ( Unit const *  unit,
float  maxDist,
bool  playerOnly,
bool  inLos,
float  minDist = 0.f 
)
inline
166: _me(unit), _minDist(minDist), _maxDist(maxDist), _playerOnly(playerOnly), _inLos(inLos) {}
Unit const * _me
Definition: UnitAI.h:186
float _maxDist
Definition: UnitAI.h:187
bool _playerOnly
Definition: UnitAI.h:188
bool _inLos
Definition: UnitAI.h:189
float _minDist
Definition: UnitAI.h:187

Member Function Documentation

◆ operator()()

bool FarthestTargetSelector::operator() ( Unit const *  target) const
inline
169 {
170 if (!_me || !target)
171 return false;
172
173 if (_playerOnly && !target->IsPlayer())
174 return false;
175
176 if (_maxDist > 0.0f && !_me->IsInRange(target, _minDist, _maxDist))
177 return false;
178
179 if (_inLos && !_me->IsWithinLOSInMap(target))
180 return false;
181
182 return true;
183 }
bool IsWithinLOSInMap(WorldObject const *obj, VMAP::ModelIgnoreFlags ignoreFlags=VMAP::ModelIgnoreFlags::Nothing, LineOfSightChecks checks=LINEOFSIGHT_ALL_CHECKS, Optional< float > collisionHeight={ }, Optional< float > combatReach={ }) const
Definition: Object.cpp:1347
bool IsInRange(WorldObject const *obj, float minRange, float maxRange, bool is3D=true) const
Definition: Object.cpp:1404

References _inLos, _maxDist, _me, _minDist, _playerOnly, WorldObject::IsInRange(), Object::IsPlayer(), and WorldObject::IsWithinLOSInMap().

Member Data Documentation

◆ _inLos

bool FarthestTargetSelector::_inLos
private

Referenced by operator()().

◆ _maxDist

float FarthestTargetSelector::_maxDist
private

Referenced by operator()().

◆ _me

Unit const* FarthestTargetSelector::_me
private

Referenced by operator()().

◆ _minDist

float FarthestTargetSelector::_minDist
private

Referenced by operator()().

◆ _playerOnly

bool FarthestTargetSelector::_playerOnly
private

Referenced by operator()().