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

#include <UnitAICommon.h>

Public Member Functions

 DefaultTargetSelector (Unit const *unit, float dist, bool playerOnly, bool withMainTank, int32 aura)
 
bool operator() (Unit const *target) const
 

Private Attributes

Unit const * _me
 
float _dist
 
bool _playerOnly
 
Unit const * _exception
 
int32 _aura
 

Constructor & Destructor Documentation

◆ DefaultTargetSelector()

DefaultTargetSelector::DefaultTargetSelector ( Unit const *  unit,
float  dist,
bool  playerOnly,
bool  withMainTank,
int32  aura 
)
26 : _me(unit), _dist(dist), _playerOnly(playerOnly), _exception(!withTank ? unit->GetThreatManager().GetLastVictim() : nullptr), _aura(aura)
27{
28}
bool _playerOnly
Definition: UnitAICommon.h:62
float _dist
Definition: UnitAICommon.h:61
Unit const * _me
Definition: UnitAICommon.h:60
int32 _aura
Definition: UnitAICommon.h:64
Unit const * _exception
Definition: UnitAICommon.h:63

Member Function Documentation

◆ operator()()

bool DefaultTargetSelector::operator() ( Unit const *  target) const
31{
32 if (!_me)
33 return false;
34
35 if (!target)
36 return false;
37
38 if (_exception && target == _exception)
39 return false;
40
41 if (_playerOnly && (target->GetTypeId() != TYPEID_PLAYER))
42 return false;
43
44 if (_dist > 0.0f && !_me->IsWithinCombatRange(target, _dist))
45 return false;
46
47 if (_dist < 0.0f && _me->IsWithinCombatRange(target, -_dist))
48 return false;
49
50 if (_aura)
51 {
52 if (_aura > 0)
53 {
54 if (!target->HasAura(_aura))
55 return false;
56 }
57 else
58 {
59 if (target->HasAura(-_aura))
60 return false;
61 }
62 }
63
64 return true;
65}
@ TYPEID_PLAYER
Definition: ObjectGuid.h:39
bool IsWithinCombatRange(Unit const *obj, float dist2compare) const
Definition: Unit.cpp:617
+ Here is the call graph for this function:

Member Data Documentation

◆ _aura

int32 DefaultTargetSelector::_aura
private

◆ _dist

float DefaultTargetSelector::_dist
private

◆ _exception

Unit const* DefaultTargetSelector::_exception
private

◆ _me

Unit const* DefaultTargetSelector::_me
private

◆ _playerOnly

bool DefaultTargetSelector::_playerOnly
private

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