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
130: _me(unit), _power(power), _dist(dist), _playerOnly(playerOnly) { }
float const _dist
Definition: UnitAI.h:127
Unit const * _me
Definition: UnitAI.h:125
Powers const _power
Definition: UnitAI.h:126
bool const _playerOnly
Definition: UnitAI.h:128

Member Function Documentation

◆ operator()()

bool PowerUsersSelector::operator() ( Unit const *  target) const
inline
133 {
134 if (!_me || !target)
135 return false;
136
137 if (target->getPowerType() != _power)
138 return false;
139
140 if (_playerOnly && target->GetTypeId() != TYPEID_PLAYER)
141 return false;
142
143 if (_dist > 0.0f && !_me->IsWithinCombatRange(target, _dist))
144 return false;
145
146 if (_dist < 0.0f && _me->IsWithinCombatRange(target, -_dist))
147 return false;
148
149 return true;
150 }
@ TYPEID_PLAYER
Definition: ObjectGuid.h:38
bool IsWithinCombatRange(Unit const *obj, float dist2compare) const
Definition: Unit.cpp:667

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

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()().