TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
HostileRefManager Class Reference

#include <HostileRefManager.h>

Public Member Functions

 HostileRefManager (Unit *owner)
 
 ~HostileRefManager ()
 
UnitGetOwner ()
 
void threatAssist (Unit *victim, float baseThreat, SpellInfo const *threatSpell=NULL)
 
void addTempThreat (float threat, bool apply)
 
void addThreatPercent (int32 percent)
 
void deleteReferences ()
 
void deleteReferencesForFaction (uint32 faction)
 
HostileReferencegetFirst ()
 
void updateThreatTables ()
 
void setOnlineOfflineState (bool isOnline)
 
void setOnlineOfflineState (Unit *creature, bool isOnline)
 
void deleteReference (Unit *creature)
 
void UpdateVisibility ()
 
- Public Member Functions inherited from RefManager< Unit, ThreatManager >
 RefManager ()
 
virtual ~RefManager ()
 
Reference< Unit, ThreatManager > * getFirst ()
 
Reference< Unit, ThreatManager >
const
getFirst () const
 
Reference< Unit, ThreatManager > * getLast ()
 
Reference< Unit, ThreatManager >
const
getLast () const
 
iterator begin ()
 
iterator end ()
 
iterator rbegin ()
 
iterator rend ()
 
void clearReferences ()
 
- Public Member Functions inherited from LinkedListHead
 LinkedListHead ()
 
virtual ~LinkedListHead ()
 
bool isEmpty () const
 
LinkedListElementgetFirst ()
 
LinkedListElement constgetFirst () const
 
LinkedListElementgetLast ()
 
LinkedListElement constgetLast () const
 
void insertFirst (LinkedListElement *pElem)
 
void insertLast (LinkedListElement *pElem)
 
uint32 getSize () const
 
void incSize ()
 
void decSize ()
 

Private Attributes

UnitiOwner
 

Additional Inherited Members

- Public Types inherited from RefManager< Unit, ThreatManager >
typedef
LinkedListHead::Iterator
< Reference< Unit,
ThreatManager > > 
iterator
 
- Public Types inherited from LinkedListHead
typedef Iterator
< LinkedListElement
iterator
 

Constructor & Destructor Documentation

HostileRefManager::HostileRefManager ( Unit owner)
inlineexplicit
37 { iOwner = owner; }
Unit * iOwner
Definition: HostileRefManager.h:35
HostileRefManager::~HostileRefManager ( )
26 {
28 }
void deleteReferences()
Definition: HostileRefManager.cpp:114

+ Here is the call graph for this function:

Member Function Documentation

void HostileRefManager::addTempThreat ( float  threat,
bool  apply 
)
55 {
56  HostileReference* ref = getFirst();
57 
58  while (ref)
59  {
60  if (apply)
61  {
62  if (ref->getTempThreatModifier() == 0.0f)
63  ref->addTempThreat(threat);
64  }
65  else
66  ref->resetTempThreat();
67 
68  ref = ref->next();
69  }
70 }
void apply(T *val)
Definition: ByteConverter.h:41
float getTempThreatModifier()
Definition: ThreatManager.h:92
HostileReference * next()
Definition: ThreatManager.h:116
Definition: ThreatManager.h:49
HostileReference * getFirst()
Definition: HostileRefManager.h:58
void resetTempThreat()
Definition: ThreatManager.h:83
void addTempThreat(float threat)
Definition: ThreatManager.h:76

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void HostileRefManager::addThreatPercent ( int32  percent)
75 {
76  HostileReference* ref = getFirst();
77  while (ref)
78  {
79  ref->addThreatPercent(percent);
80  ref = ref->next();
81  }
82 }
HostileReference * next()
Definition: ThreatManager.h:116
Definition: ThreatManager.h:49
HostileReference * getFirst()
Definition: HostileRefManager.h:58
void addThreatPercent(int32 percent)
Definition: ThreatManager.cpp:157

+ Here is the call graph for this function:

void HostileRefManager::deleteReference ( Unit creature)
148 {
149  HostileReference* ref = getFirst();
150  while (ref)
151  {
152  HostileReference* nextRef = ref->next();
153  if (ref->GetSource()->GetOwner() == creature)
154  {
155  ref->removeReference();
156  delete ref;
157  break;
158  }
159  ref = nextRef;
160  }
161 }
void removeReference()
Definition: ThreatManager.cpp:234
HostileReference * next()
Definition: ThreatManager.h:116
Definition: ThreatManager.h:49
HostileReference * getFirst()
Definition: HostileRefManager.h:58
FROM * GetSource() const
Definition: Reference.h:96
Unit * GetOwner() const
Definition: ThreatManager.h:228

+ Here is the call graph for this function:

void HostileRefManager::deleteReferences ( )
115 {
116  HostileReference* ref = getFirst();
117  while (ref)
118  {
119  HostileReference* nextRef = ref->next();
120  ref->removeReference();
121  delete ref;
122  ref = nextRef;
123  }
124 }
void removeReference()
Definition: ThreatManager.cpp:234
HostileReference * next()
Definition: ThreatManager.h:116
Definition: ThreatManager.h:49
HostileReference * getFirst()
Definition: HostileRefManager.h:58

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void HostileRefManager::deleteReferencesForFaction ( uint32  faction)
130 {
131  HostileReference* ref = getFirst();
132  while (ref)
133  {
134  HostileReference* nextRef = ref->next();
135  if (ref->GetSource()->GetOwner()->GetFactionTemplateEntry()->Faction == faction)
136  {
137  ref->removeReference();
138  delete ref;
139  }
140  ref = nextRef;
141  }
142 }
void removeReference()
Definition: ThreatManager.cpp:234
HostileReference * next()
Definition: ThreatManager.h:116
Definition: ThreatManager.h:49
HostileReference * getFirst()
Definition: HostileRefManager.h:58
FROM * GetSource() const
Definition: Reference.h:96
Unit * GetOwner() const
Definition: ThreatManager.h:228
FactionTemplateEntry const * GetFactionTemplateEntry() const
Definition: Unit.cpp:7019
uint32 Faction
Definition: DBCStructure.h:436

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

HostileReference* HostileRefManager::getFirst ( )
inline
Definition: RefManager.h:26
Definition: ThreatManager.h:49

+ Here is the caller graph for this function:

Unit* HostileRefManager::GetOwner ( )
inline
40 { return iOwner; }
Unit * iOwner
Definition: HostileRefManager.h:35

+ Here is the caller graph for this function:

void HostileRefManager::setOnlineOfflineState ( bool  isOnline)
88 {
89  HostileReference* ref = getFirst();
90  while (ref)
91  {
92  ref->setOnlineOfflineState(isOnline);
93  ref = ref->next();
94  }
95 }
void setOnlineOfflineState(bool isOnline)
Definition: ThreatManager.cpp:204
HostileReference * next()
Definition: ThreatManager.h:116
Definition: ThreatManager.h:49
HostileReference * getFirst()
Definition: HostileRefManager.h:58

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void HostileRefManager::setOnlineOfflineState ( Unit creature,
bool  isOnline 
)
167 {
168  HostileReference* ref = getFirst();
169  while (ref)
170  {
171  HostileReference* nextRef = ref->next();
172  if (ref->GetSource()->GetOwner() == creature)
173  {
174  ref->setOnlineOfflineState(isOnline);
175  break;
176  }
177  ref = nextRef;
178  }
179 }
void setOnlineOfflineState(bool isOnline)
Definition: ThreatManager.cpp:204
HostileReference * next()
Definition: ThreatManager.h:116
Definition: ThreatManager.h:49
HostileReference * getFirst()
Definition: HostileRefManager.h:58
FROM * GetSource() const
Definition: Reference.h:96
Unit * GetOwner() const
Definition: ThreatManager.h:228

+ Here is the call graph for this function:

void HostileRefManager::threatAssist ( Unit victim,
float  baseThreat,
SpellInfo const threatSpell = NULL 
)
36 {
37  if (getSize() == 0)
38  return;
39 
40  HostileReference* ref = getFirst();
41  float threat = ThreatCalcHelper::calcThreat(victim, iOwner, baseThreat, (threatSpell ? threatSpell->GetSchoolMask() : SPELL_SCHOOL_MASK_NORMAL), threatSpell);
42  threat /= getSize();
43  while (ref)
44  {
45  if (ThreatCalcHelper::isValidProcess(victim, ref->GetSource()->GetOwner(), threatSpell))
46  ref->GetSource()->doAddThreat(victim, threat);
47 
48  ref = ref->next();
49  }
50 }
static bool isValidProcess(Unit *hatedUnit, Unit *hatingUnit, SpellInfo const *threatSpell=NULL)
Definition: ThreatManager.cpp:54
static float calcThreat(Unit *hatedUnit, Unit *hatingUnit, float threat, SpellSchoolMask schoolMask=SPELL_SCHOOL_MASK_NORMAL, SpellInfo const *threatSpell=NULL)
Definition: ThreatManager.cpp:34
uint32 getSize() const
Definition: LinkedList.h:120
void doAddThreat(Unit *victim, float threat)
Definition: ThreatManager.cpp:414
Unit * iOwner
Definition: HostileRefManager.h:35
Definition: SharedDefines.h:288
HostileReference * next()
Definition: ThreatManager.h:116
Definition: ThreatManager.h:49
HostileReference * getFirst()
Definition: HostileRefManager.h:58
FROM * GetSource() const
Definition: Reference.h:96
Unit * GetOwner() const
Definition: ThreatManager.h:228

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void HostileRefManager::updateThreatTables ( )
101 {
102  HostileReference* ref = getFirst();
103  while (ref)
104  {
105  ref->updateOnlineStatus();
106  ref = ref->next();
107  }
108 }
void updateOnlineStatus()
Definition: ThreatManager.cpp:167
HostileReference * next()
Definition: ThreatManager.h:116
Definition: ThreatManager.h:49
HostileReference * getFirst()
Definition: HostileRefManager.h:58

+ Here is the call graph for this function:

void HostileRefManager::UpdateVisibility ( )
184 {
185  HostileReference* ref = getFirst();
186  while (ref)
187  {
188  HostileReference* nextRef = ref->next();
189  if (!ref->GetSource()->GetOwner()->CanSeeOrDetect(GetOwner()))
190  {
191  nextRef = ref->next();
192  ref->removeReference();
193  delete ref;
194  }
195  ref = nextRef;
196  }
197 }
void removeReference()
Definition: ThreatManager.cpp:234
Unit * GetOwner()
Definition: HostileRefManager.h:40
HostileReference * next()
Definition: ThreatManager.h:116
Definition: ThreatManager.h:49
HostileReference * getFirst()
Definition: HostileRefManager.h:58
FROM * GetSource() const
Definition: Reference.h:96
Unit * GetOwner() const
Definition: ThreatManager.h:228
bool CanSeeOrDetect(WorldObject const *obj, bool ignoreStealth=false, bool distanceCheck=false, bool checkAlert=false) const
Definition: Object.cpp:1940

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Member Data Documentation

Unit* HostileRefManager::iOwner
private

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