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

#include "UnitAI.h"

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

Public Member Functions

 PowerUsersSelector (Unit const *unit, Powers power, float dist, bool playerOnly)
 
bool operator() (Unit const *target) const
 

Public Attributes

Unit const * _me
 
Powers const _power
 
float const _dist
 
bool const _playerOnly
 

Additional Inherited Members

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

Detailed Description

Constructor & Destructor Documentation

◆ PowerUsersSelector()

PowerUsersSelector::PowerUsersSelector ( Unit const *  unit,
Powers  power,
float  dist,
bool  playerOnly 
)
inline
141: _me(unit), _power(power), _dist(dist), _playerOnly(playerOnly) { }
float const _dist
Definition: UnitAI.h:138
Unit const * _me
Definition: UnitAI.h:136
Powers const _power
Definition: UnitAI.h:137
bool const _playerOnly
Definition: UnitAI.h:139

Member Function Documentation

◆ operator()()

bool PowerUsersSelector::operator() ( Unit const *  target) const
inline
144 {
145 if (!_me || !target)
146 return false;
147
148 if (target->getPowerType() != _power)
149 return false;
150
151 if (_playerOnly && !target->IsPlayer())
152 return false;
153
154 if (_dist > 0.0f && !_me->IsWithinCombatRange(target, _dist))
155 return false;
156
157 if (_dist < 0.0f && _me->IsWithinCombatRange(target, -_dist))
158 return false;
159
160 return true;
161 }
bool IsWithinCombatRange(Unit const *obj, float dist2compare) const
Definition: Unit.cpp:648

References _dist, _me, _playerOnly, _power, Unit::getPowerType(), Object::IsPlayer(), and Unit::IsWithinCombatRange().

Member Data Documentation

◆ _dist

float const PowerUsersSelector::_dist

Referenced by operator()().

◆ _me

Unit const* PowerUsersSelector::_me

Referenced by operator()().

◆ _playerOnly

bool const PowerUsersSelector::_playerOnly

Referenced by operator()().

◆ _power

Powers const PowerUsersSelector::_power

Referenced by operator()().