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

#include "UnitAI.h"

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

Public Member Functions

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

Public Attributes

Unit const * me
 
float m_dist
 
Unit const * except
 
bool m_playerOnly
 
int32 m_aura
 

Additional Inherited Members

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

Detailed Description

Constructor & Destructor Documentation

◆ DefaultTargetSelector()

DefaultTargetSelector::DefaultTargetSelector ( Unit const *  unit,
float  dist,
bool  playerOnly,
bool  withMainTank,
int32  aura 
)
inline
66: me(unit), m_dist(dist), except(!withMainTank ? me->GetThreatMgr().GetCurrentVictim() : nullptr), m_playerOnly(playerOnly), m_aura(aura) {}
Unit const * me
Definition: UnitAI.h:55
float m_dist
Definition: UnitAI.h:56
int32 m_aura
Definition: UnitAI.h:59
bool m_playerOnly
Definition: UnitAI.h:58
Unit const * except
Definition: UnitAI.h:57
Unit * GetCurrentVictim() const
Definition: ThreatMgr.h:213
ThreatMgr & GetThreatMgr()
Definition: Unit.h:839

Member Function Documentation

◆ operator()()

bool DefaultTargetSelector::operator() ( Unit const *  target) const
inline
69 {
70 if (!me)
71 return false;
72
73 if (!target)
74 return false;
75
76 if (target == except)
77 return false;
78
79 if (m_playerOnly && (!target->IsPlayer()))
80 return false;
81
82 if (m_dist > 0.0f && !me->IsWithinCombatRange(target, m_dist))
83 return false;
84
85 if (m_dist < 0.0f && me->IsWithinCombatRange(target, -m_dist))
86 return false;
87
88 if (m_aura)
89 {
90 if (m_aura > 0)
91 {
92 if (!target->HasAura(m_aura))
93 return false;
94 }
95 else
96 {
97 if (target->HasAura(-m_aura))
98 return false;
99 }
100 }
101
102 return true;
103 }
bool IsWithinCombatRange(Unit const *obj, float dist2compare) const
Definition: Unit.cpp:649

References except, Unit::HasAura(), Object::IsPlayer(), Unit::IsWithinCombatRange(), m_aura, m_dist, m_playerOnly, and me.

Member Data Documentation

◆ except

Unit const* DefaultTargetSelector::except

Referenced by operator()().

◆ m_aura

int32 DefaultTargetSelector::m_aura

Referenced by operator()().

◆ m_dist

float DefaultTargetSelector::m_dist

Referenced by operator()().

◆ m_playerOnly

bool DefaultTargetSelector::m_playerOnly

Referenced by operator()().

◆ me

Unit const* DefaultTargetSelector::me

Referenced by operator()().