TrinityCore
Loading...
Searching...
No Matches
FarthestTargetSelector Struct Reference

#include <UnitAICommon.h>

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
 

Detailed Description

Definition at line 105 of file UnitAICommon.h.

Constructor & Destructor Documentation

◆ FarthestTargetSelector()

FarthestTargetSelector::FarthestTargetSelector ( Unit const *  unit,
float  dist,
bool  playerOnly,
bool  inLos 
)
inline

Definition at line 107 of file UnitAICommon.h.

107: _me(unit), _dist(dist), _playerOnly(playerOnly), _inLos(inLos) { }

Member Function Documentation

◆ operator()()

bool FarthestTargetSelector::operator() ( Unit const *  target) const

Definition at line 171 of file UnitAICommon.cpp.

172{
173 if (!_me || !target)
174 return false;
175
176 if (_playerOnly && target->GetTypeId() != TYPEID_PLAYER)
177 return false;
178
179 if (_dist > 0.0f && !_me->IsWithinCombatRange(target, _dist))
180 return false;
181
182 if (_inLos && !_me->IsWithinLOSInMap(target))
183 return false;
184
185 return true;
186}
@ TYPEID_PLAYER
Definition: ObjectGuid.h:41
bool IsWithinCombatRange(Unit const *obj, float dist2compare) const
Definition: Unit.cpp:631
bool IsWithinLOSInMap(WorldObject const *obj, LineOfSightChecks checks=LINEOFSIGHT_ALL_CHECKS, VMAP::ModelIgnoreFlags ignoreFlags=VMAP::ModelIgnoreFlags::Nothing) const
Definition: Object.cpp:1172
+ Here is the call graph for this function:

Member Data Documentation

◆ _dist

float FarthestTargetSelector::_dist
private

Definition at line 112 of file UnitAICommon.h.

◆ _inLos

bool FarthestTargetSelector::_inLos
private

Definition at line 114 of file UnitAICommon.h.

◆ _me

Unit const* FarthestTargetSelector::_me
private

Definition at line 111 of file UnitAICommon.h.

◆ _playerOnly

bool FarthestTargetSelector::_playerOnly
private

Definition at line 113 of file UnitAICommon.h.


The documentation for this struct was generated from the following files: