AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
GlobalCooldownMgr Class Reference

#include "CharmInfo.h"

Public Member Functions

 GlobalCooldownMgr ()=default
 
bool HasGlobalCooldown (SpellInfo const *spellInfo) const
 
uint32 GetGlobalCooldown (SpellInfo const *spellInfo) const
 
void AddGlobalCooldown (SpellInfo const *spellInfo, uint32 gcd)
 
void CancelGlobalCooldown (SpellInfo const *spellInfo)
 

Private Attributes

GlobalCooldownList m_GlobalCooldowns
 

Detailed Description

Constructor & Destructor Documentation

◆ GlobalCooldownMgr()

GlobalCooldownMgr::GlobalCooldownMgr ( )
default

Member Function Documentation

◆ AddGlobalCooldown()

void GlobalCooldownMgr::AddGlobalCooldown ( SpellInfo const *  spellInfo,
uint32  gcd 
)
420{
421 m_GlobalCooldowns[spellInfo->StartRecoveryCategory] = GlobalCooldown(gcd, GameTime::GetGameTimeMS().count());
422}
GlobalCooldownList m_GlobalCooldowns
Definition CharmInfo.h:91
Milliseconds GetGameTimeMS()
Definition GameTime.cpp:43
Definition CharmInfo.h:70

References GameTime::GetGameTimeMS(), m_GlobalCooldowns, and SpellInfo::StartRecoveryCategory.

Referenced by Player::EquipItem(), and Spell::TriggerGlobalCooldown().

◆ CancelGlobalCooldown()

void GlobalCooldownMgr::CancelGlobalCooldown ( SpellInfo const *  spellInfo)
425{
426 m_GlobalCooldowns[spellInfo->StartRecoveryCategory].duration = 0;
427}

References m_GlobalCooldowns, and SpellInfo::StartRecoveryCategory.

Referenced by Spell::CancelGlobalCooldown().

◆ GetGlobalCooldown()

uint32 GlobalCooldownMgr::GetGlobalCooldown ( SpellInfo const *  spellInfo) const
404{
405 if (!spellInfo)
406 return 0;
407
408 auto itr = m_GlobalCooldowns.find(spellInfo->StartRecoveryCategory);
409 if (itr == m_GlobalCooldowns.end() || itr->second.duration == 0)
410 return 0;
411
412 uint32 start = itr->second.cast_time;
413 uint32 delay = itr->second.duration;
414 uint32 now = getMSTime();
415
416 return (start + delay > now) ? (start + delay) - now : 0;
417}
std::uint32_t uint32
Definition Define.h:107
uint32 getMSTime()
Definition Timer.h:103

References getMSTime(), m_GlobalCooldowns, and SpellInfo::StartRecoveryCategory.

◆ HasGlobalCooldown()

bool GlobalCooldownMgr::HasGlobalCooldown ( SpellInfo const *  spellInfo) const
398{
399 GlobalCooldownList::const_iterator itr = m_GlobalCooldowns.find(spellInfo->StartRecoveryCategory);
400 return itr != m_GlobalCooldowns.end() && itr->second.duration && getMSTimeDiff(itr->second.cast_time, GameTime::GetGameTimeMS().count()) < itr->second.duration;
401}
uint32 getMSTimeDiff(uint32 oldMSTime, uint32 newMSTime)
Definition Timer.h:110

References GameTime::GetGameTimeMS(), getMSTimeDiff(), m_GlobalCooldowns, and SpellInfo::StartRecoveryCategory.

Referenced by Spell::CheckPetCast(), Spell::HasGlobalCooldown(), and PetAI::UpdateAI().

Member Data Documentation

◆ m_GlobalCooldowns

GlobalCooldownList GlobalCooldownMgr::m_GlobalCooldowns
private

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