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 dist, bool playerOnly, bool inLos)
 
bool operator() (Unit const *target) const
 

Private Attributes

Unit const * _me
 
float _dist
 
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  dist,
bool  playerOnly,
bool  inLos 
)
inline
155: _me(unit), _dist(dist), _playerOnly(playerOnly), _inLos(inLos) {}
Unit const * _me
Definition: UnitAI.h:175
float _dist
Definition: UnitAI.h:176
bool _playerOnly
Definition: UnitAI.h:177
bool _inLos
Definition: UnitAI.h:178

Member Function Documentation

◆ operator()()

bool FarthestTargetSelector::operator() ( Unit const *  target) const
inline
158 {
159 if (!_me || !target)
160 return false;
161
162 if (_playerOnly && target->GetTypeId() != TYPEID_PLAYER)
163 return false;
164
165 if (_dist > 0.0f && !_me->IsWithinCombatRange(target, _dist))
166 return false;
167
168 if (_inLos && !_me->IsWithinLOSInMap(target))
169 return false;
170
171 return true;
172 }
@ TYPEID_PLAYER
Definition: ObjectGuid.h:38
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 IsWithinCombatRange(Unit const *obj, float dist2compare) const
Definition: Unit.cpp:667

References _dist, _inLos, _me, _playerOnly, Object::GetTypeId(), Unit::IsWithinCombatRange(), WorldObject::IsWithinLOSInMap(), and TYPEID_PLAYER.

Member Data Documentation

◆ _dist

float FarthestTargetSelector::_dist
private

Referenced by operator()().

◆ _inLos

bool FarthestTargetSelector::_inLos
private

Referenced by operator()().

◆ _me

Unit const* FarthestTargetSelector::_me
private

Referenced by operator()().

◆ _playerOnly

bool FarthestTargetSelector::_playerOnly
private

Referenced by operator()().