AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
CombatReference Struct Reference

#include "CombatManager.h"

Inheritance diagram for CombatReference:
PvPCombatReference

Public Member Functions

UnitGetOther (Unit const *me) const
 
void EndCombat ()
 
void SuppressFor (Unit *who)
 
bool IsSuppressedFor (Unit const *who) const
 
 CombatReference (CombatReference const &)=delete
 
CombatReferenceoperator= (CombatReference const &)=delete
 

Public Attributes

Unit *const first
 
Unit *const second
 
bool const _isPvP
 

Protected Member Functions

 CombatReference (Unit *a, Unit *b, bool pvp=false)
 
void Refresh ()
 
void Suppress (Unit *who)
 

Protected Attributes

bool _suppressFirst = false
 
bool _suppressSecond = false
 

Friends

class CombatManager
 

Detailed Description

Constructor & Destructor Documentation

◆ CombatReference() [1/2]

CombatReference::CombatReference ( CombatReference const &  )
delete

◆ CombatReference() [2/2]

CombatReference::CombatReference ( Unit a,
Unit b,
bool  pvp = false 
)
inlineprotected
77: first(a), second(b), _isPvP(pvp) { }
bool const _isPvP
Definition CombatManager.h:63
Unit *const second
Definition CombatManager.h:62
Unit *const first
Definition CombatManager.h:61

Member Function Documentation

◆ EndCombat()

void CombatReference::EndCombat ( )
73{
74 // sequencing matters here - AI might do nasty stuff, so make sure refs are in a consistent state before you hand off!
75
76 // first, get rid of any threat that still exists...
79
80 // ...then, remove the references from both managers...
83
84 // ...update the combat state, which will potentially remove IN_COMBAT...
85 bool const needFirstAI = first->GetCombatManager().UpdateOwnerCombatState();
86 bool const needSecondAI = second->GetCombatManager().UpdateOwnerCombatState();
87
88 // ...and if that happened, also notify the AI of it...
89 if (needFirstAI)
90 if (UnitAI* firstAI = first->GetAI())
91 firstAI->JustExitedCombat();
92 if (needSecondAI)
93 if (UnitAI* secondAI = second->GetAI())
94 secondAI->JustExitedCombat();
95
96 // ...and finally clean up the reference object
97 delete this;
98}
bool UpdateOwnerCombatState() const
Definition CombatManager.cpp:408
void PurgeReference(ObjectGuid const &guid, bool pvp)
Definition CombatManager.cpp:400
static ObjectGuid GetGUID(Object const *o)
Definition Object.h:114
void ClearThreat(Unit *target)
Definition ThreatManager.cpp:560
Definition UnitAI.h:198
ThreatManager & GetThreatMgr()
Definition Unit.h:951
UnitAI * GetAI()
Definition Unit.h:693
CombatManager & GetCombatManager()
Definition Unit.h:953

References _isPvP, ThreatManager::ClearThreat(), first, Unit::GetAI(), Unit::GetCombatManager(), Object::GetGUID(), Unit::GetThreatMgr(), CombatManager::PurgeReference(), second, and CombatManager::UpdateOwnerCombatState().

Referenced by CombatManager::EndCombatBeyondRange(), CombatManager::RevalidateCombat(), and CombatManager::Update().

◆ GetOther()

Unit * CombatReference::GetOther ( Unit const *  me) const
inline
64{ return (first == me) ? second : first; }

Referenced by CombatManager::RevalidateCombat().

◆ IsSuppressedFor()

bool CombatReference::IsSuppressedFor ( Unit const *  who) const
inline
71{ return (who == first) ? _suppressFirst : _suppressSecond; }
bool _suppressSecond
Definition CombatManager.h:83
bool _suppressFirst
Definition CombatManager.h:82

◆ operator=()

CombatReference & CombatReference::operator= ( CombatReference const &  )
delete

◆ Refresh()

void CombatReference::Refresh ( )
protected
101{
102 bool needFirstAI = false, needSecondAI = false;
103 if (_suppressFirst)
104 {
105 _suppressFirst = false;
107 }
108 if (_suppressSecond)
109 {
110 _suppressSecond = false;
112 }
113
114 if (needFirstAI)
116 if (needSecondAI)
118}
static void NotifyAICombat(Unit *me, Unit *other)
Definition CombatManager.cpp:378

References _suppressFirst, _suppressSecond, first, Unit::GetCombatManager(), CombatManager::NotifyAICombat(), second, and CombatManager::UpdateOwnerCombatState().

◆ Suppress()

void CombatReference::Suppress ( Unit who)
inlineprotected
80{ (who == first ? _suppressFirst : _suppressSecond) = true; }

Referenced by CombatManager::SetInCombatWith(), and SuppressFor().

◆ SuppressFor()

void CombatReference::SuppressFor ( Unit who)
121{
122 Suppress(who);
124 if (UnitAI* ai = who->GetAI())
125 ai->JustExitedCombat();
126}
void Suppress(Unit *who)
Definition CombatManager.h:80

References Unit::GetAI(), Unit::GetCombatManager(), Suppress(), and CombatManager::UpdateOwnerCombatState().

Friends And Related Symbol Documentation

◆ CombatManager

friend class CombatManager
friend

Member Data Documentation

◆ _isPvP

bool const CombatReference::_isPvP

◆ _suppressFirst

bool CombatReference::_suppressFirst = false
protected

Referenced by Refresh().

◆ _suppressSecond

bool CombatReference::_suppressSecond = false
protected

Referenced by Refresh().

◆ first

Unit* const CombatReference::first

◆ second


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