AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
Acore::NearestHostileUnitCheck Class Reference

#include "GridNotifiers.h"

Public Member Functions

 NearestHostileUnitCheck (Creature const *creature, float dist=0, bool playerOnly=false)
 
bool operator() (Unit *u)
 

Private Member Functions

 NearestHostileUnitCheck (NearestHostileUnitCheck const &)
 

Private Attributes

Creature const * me
 
float m_range
 
bool i_playerOnly
 

Detailed Description

Constructor & Destructor Documentation

◆ NearestHostileUnitCheck() [1/2]

Acore::NearestHostileUnitCheck::NearestHostileUnitCheck ( Creature const *  creature,
float  dist = 0,
bool  playerOnly = false 
)
inlineexplicit
1188 : me(creature), i_playerOnly(playerOnly)
1189 {
1190 m_range = (dist == 0 ? 9999 : dist);
1191 }
bool i_playerOnly
Definition GridNotifiers.h:1210
Creature const * me
Definition GridNotifiers.h:1208
float m_range
Definition GridNotifiers.h:1209

References m_range.

◆ NearestHostileUnitCheck() [2/2]

Acore::NearestHostileUnitCheck::NearestHostileUnitCheck ( NearestHostileUnitCheck const &  )
private

Member Function Documentation

◆ operator()()

bool Acore::NearestHostileUnitCheck::operator() ( Unit u)
inline
1193 {
1194 if (!me->IsWithinDistInMap(u, m_range, true, false, false))
1195 return false;
1196
1197 if (!me->IsValidAttackTarget(u))
1198 return false;
1199
1200 if (i_playerOnly && !u->IsPlayer())
1201 return false;
1202
1203 m_range = me->GetDistance(u); // use found unit range as new range limit for next check
1204 return true;
1205 }
bool IsPlayer() const
Definition Object.h:201
bool IsValidAttackTarget(Unit const *target, SpellInfo const *bySpell=nullptr) const
Definition Unit.cpp:13959
bool IsWithinDistInMap(WorldObject const *obj, float dist2compare, bool is3D=true, bool incOwnRadius=true, bool incTargetRadius=true) const
Definition Object.cpp:1354
float GetDistance(WorldObject const *obj) const
Definition Object.cpp:1278

References WorldObject::GetDistance(), i_playerOnly, Object::IsPlayer(), Unit::IsValidAttackTarget(), WorldObject::IsWithinDistInMap(), m_range, and me.

Member Data Documentation

◆ i_playerOnly

bool Acore::NearestHostileUnitCheck::i_playerOnly
private

Referenced by operator()().

◆ m_range

float Acore::NearestHostileUnitCheck::m_range
private

◆ me

Creature const* Acore::NearestHostileUnitCheck::me
private

Referenced by operator()().


The documentation for this class was generated from the following file: