TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
DefaultTargetSelector Struct Reference

#include <UnitAI.h>

Public Member Functions

 DefaultTargetSelector (Unit const *unit, float dist, bool playerOnly, int32 aura)
 
bool operator() (Unit const *target) const
 

Public Attributes

const Unitme
 
float m_dist
 
bool m_playerOnly
 
int32 m_aura
 

Constructor & Destructor Documentation

DefaultTargetSelector::DefaultTargetSelector ( Unit const unit,
float  dist,
bool  playerOnly,
int32  aura 
)
inline
54 : me(unit), m_dist(dist), m_playerOnly(playerOnly), m_aura(aura) { }
const Unit * me
Definition: UnitAI.h:45
float m_dist
Definition: UnitAI.h:46
int32 m_aura
Definition: UnitAI.h:48
bool m_playerOnly
Definition: UnitAI.h:47

Member Function Documentation

bool DefaultTargetSelector::operator() ( Unit const target) const
inline
57  {
58  if (!me)
59  return false;
60 
61  if (!target)
62  return false;
63 
64  if (m_playerOnly && (target->GetTypeId() != TYPEID_PLAYER))
65  return false;
66 
67  if (m_dist > 0.0f && !me->IsWithinCombatRange(target, m_dist))
68  return false;
69 
70  if (m_dist < 0.0f && me->IsWithinCombatRange(target, -m_dist))
71  return false;
72 
73  if (m_aura)
74  {
75  if (m_aura > 0)
76  {
77  if (!target->HasAura(m_aura))
78  return false;
79  }
80  else
81  {
82  if (target->HasAura(-m_aura))
83  return false;
84  }
85  }
86 
87  return true;
88  }
bool IsWithinCombatRange(const Unit *obj, float dist2compare) const
Definition: Unit.cpp:492
const Unit * me
Definition: UnitAI.h:45
float m_dist
Definition: UnitAI.h:46
int32 m_aura
Definition: UnitAI.h:48
Definition: ObjectGuid.h:33
bool m_playerOnly
Definition: UnitAI.h:47

+ Here is the call graph for this function:

Member Data Documentation

int32 DefaultTargetSelector::m_aura
float DefaultTargetSelector::m_dist
bool DefaultTargetSelector::m_playerOnly
const Unit* DefaultTargetSelector::me

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