TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Trinity::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 constme
 
float m_range
 
bool i_playerOnly
 

Constructor & Destructor Documentation

Trinity::NearestHostileUnitCheck::NearestHostileUnitCheck ( Creature const creature,
float  dist = 0,
bool  playerOnly = false 
)
inlineexplicit
1008  : me(creature), i_playerOnly(playerOnly)
1009  {
1010  m_range = (dist == 0 ? 9999 : dist);
1011  }
Creature const * me
Definition: GridNotifiers.h:1028
bool i_playerOnly
Definition: GridNotifiers.h:1030
float m_range
Definition: GridNotifiers.h:1029
Trinity::NearestHostileUnitCheck::NearestHostileUnitCheck ( NearestHostileUnitCheck const )
private

Member Function Documentation

bool Trinity::NearestHostileUnitCheck::operator() ( Unit u)
inline
1013  {
1014  if (!me->IsWithinDistInMap(u, m_range))
1015  return false;
1016 
1017  if (!me->IsValidAttackTarget(u))
1018  return false;
1019 
1020  if (i_playerOnly && u->GetTypeId() != TYPEID_PLAYER)
1021  return false;
1022 
1023  m_range = me->GetDistance(u); // use found unit range as new range limit for next check
1024  return true;
1025  }
bool IsValidAttackTarget(Unit const *target) const
Definition: Unit.cpp:10002
bool IsWithinDistInMap(WorldObject const *obj, float dist2compare, bool is3D=true) const
Definition: Object.cpp:1663
TypeID GetTypeId() const
Definition: Object.h:113
float GetDistance(WorldObject const *obj) const
Definition: Object.cpp:1594
Creature const * me
Definition: GridNotifiers.h:1028
bool i_playerOnly
Definition: GridNotifiers.h:1030
float m_range
Definition: GridNotifiers.h:1029
Definition: ObjectGuid.h:33

+ Here is the call graph for this function:

Member Data Documentation

bool Trinity::NearestHostileUnitCheck::i_playerOnly
private
float Trinity::NearestHostileUnitCheck::m_range
private
Creature const* Trinity::NearestHostileUnitCheck::me
private

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