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

#include "GridNotifiers.h"

Public Member Functions

 NearestHostileUnitInAttackDistanceCheck (Creature const *creature, float dist)
 
bool operator() (Unit *u)
 

Private Member Functions

 NearestHostileUnitInAttackDistanceCheck (NearestHostileUnitInAttackDistanceCheck const &)
 

Private Attributes

Creature const * me
 
float m_range
 

Detailed Description

Constructor & Destructor Documentation

◆ NearestHostileUnitInAttackDistanceCheck() [1/2]

Acore::NearestHostileUnitInAttackDistanceCheck::NearestHostileUnitInAttackDistanceCheck ( Creature const *  creature,
float  dist 
)
inlineexplicit
1223: me(creature), m_range(dist) {}
Creature const * me
Definition: GridNotifiers.h:1236
float m_range
Definition: GridNotifiers.h:1237

◆ NearestHostileUnitInAttackDistanceCheck() [2/2]

Acore::NearestHostileUnitInAttackDistanceCheck::NearestHostileUnitInAttackDistanceCheck ( NearestHostileUnitInAttackDistanceCheck const &  )
private

Member Function Documentation

◆ operator()()

bool Acore::NearestHostileUnitInAttackDistanceCheck::operator() ( Unit u)
inline
1225 {
1226 if (!me->IsWithinDistInMap(u, m_range, true, false))
1227 return false;
1228
1229 if (!me->CanStartAttack(u))
1230 return false;
1231
1232 m_range = me->GetDistance(u); // use found unit range as new range limit for next check
1233 return true;
1234 }
bool CanStartAttack(Unit const *u) const
Definition: Creature.cpp:1903
bool IsWithinDistInMap(WorldObject const *obj, float dist2compare, bool is3D=true, bool useBoundingRadius=true) const
Definition: Object.cpp:1321
float GetDistance(WorldObject const *obj) const
Definition: Object.cpp:1245

References Creature::CanStartAttack(), WorldObject::GetDistance(), WorldObject::IsWithinDistInMap(), m_range, and me.

Member Data Documentation

◆ m_range

float Acore::NearestHostileUnitInAttackDistanceCheck::m_range
private

Referenced by operator()().

◆ me

Creature const* Acore::NearestHostileUnitInAttackDistanceCheck::me
private

Referenced by operator()().