refactor(Core/Combat): Code style and improvement of ThreatMgr (#12992)

This commit is contained in:
Maelthyr
2022-09-25 20:20:34 +02:00
committed by GitHub
parent ddcf0e79b6
commit 1f472bddd3
61 changed files with 212 additions and 196 deletions

View File

@@ -116,7 +116,7 @@ public:
{
me->CastSpell(me, SPELL_INCITE_CHAOS, false);
std::list<HostileReference*> t_list = me->GetThreatMgr().getThreatList();
std::list<HostileReference*> t_list = me->GetThreatMgr().GetThreatList();
for (std::list<HostileReference*>::const_iterator itr = t_list.begin(); itr != t_list.end(); ++itr)
{
Unit* target = ObjectAccessor::GetUnit(*me, (*itr)->getUnitGuid());

View File

@@ -150,7 +150,7 @@ public:
if (!me->IsWithinMeleeRange(me->GetVictim()))
{
ThreatContainer::StorageType threatlist = me->GetThreatMgr().getThreatList();
ThreatContainer::StorageType threatlist = me->GetThreatMgr().GetThreatList();
for (ThreatContainer::StorageType::const_iterator i = threatlist.begin(); i != threatlist.end(); ++i)
if (Unit* target = ObjectAccessor::GetUnit(*me, (*i)->getUnitGuid()))
if (target->IsAlive() && me->IsWithinMeleeRange(target))

View File

@@ -245,7 +245,7 @@ public:
{
PreventHitEffect(effIndex);
if (Unit* target = GetHitUnit())
GetCaster()->GetThreatMgr().modifyThreatPercent(target, -20);
GetCaster()->GetThreatMgr().ModifyThreatByPercent(target, -20);
}
void Register() override

View File

@@ -126,7 +126,7 @@ public:
Unit* FindHatefulStrikeTarget()
{
Unit* target = nullptr;
ThreatContainer::StorageType const& threatlist = me->GetThreatMgr().getThreatList();
ThreatContainer::StorageType const& threatlist = me->GetThreatMgr().GetThreatList();
for (ThreatContainer::StorageType::const_iterator i = threatlist.begin(); i != threatlist.end(); ++i)
{
Unit* unit = ObjectAccessor::GetUnit(*me, (*i)->getUnitGuid());

View File

@@ -187,7 +187,7 @@ public:
target = me->GetVictim();
else
{
ThreatContainer::StorageType const& t_list = me->GetThreatMgr().getThreatList();
ThreatContainer::StorageType const& t_list = me->GetThreatMgr().GetThreatList();
for (ThreatContainer::StorageType::const_iterator itr = t_list.begin(); itr != t_list.end(); ++itr)
if (Unit* threatTarget = ObjectAccessor::GetUnit(*me, (*itr)->getUnitGuid()))
if (me->IsWithinMeleeRange(threatTarget))

View File

@@ -221,7 +221,7 @@ public:
// Xinef: if we have target we currently follow, return
if (Unit* target = GetCaster()->GetVictim())
if (GetCaster()->GetThreatMgr().getThreat(target) >= 100000.0f)
if (GetCaster()->GetThreatMgr().GetThreat(target) >= 100000.0f)
return;
// Xinef: acquire new target

View File

@@ -323,7 +323,7 @@ public:
else
{
me->resetAttackTimer();
ThreatContainer::StorageType const& threatList = me->GetThreatMgr().getThreatList();
ThreatContainer::StorageType const& threatList = me->GetThreatMgr().GetThreatList();
for (ThreatContainer::StorageType::const_iterator itr = threatList.begin(); itr != threatList.end(); ++itr)
if (Unit* unit = ObjectAccessor::GetUnit(*me, (*itr)->getUnitGuid()))
if (me->IsWithinMeleeRange(unit))

View File

@@ -994,7 +994,7 @@ public:
{
PreventHitEffect(effIndex);
ThreatContainer::StorageType const& ThreatList = GetCaster()-> GetThreatMgr().getThreatList();
ThreatContainer::StorageType const& ThreatList = GetCaster()-> GetThreatMgr().GetThreatList();
std::list<Unit*> targetList;
for (ThreatContainer::StorageType::const_iterator itr = ThreatList.begin(); itr != ThreatList.end(); ++itr)
{

View File

@@ -1741,7 +1741,7 @@ public:
// some code to cast spell Mana Burn on random target which has mana
if (ManaBurnTimer <= diff)
{
std::list<HostileReference*> AggroList = me->GetThreatMgr().getThreatList();
std::list<HostileReference*> AggroList = me->GetThreatMgr().GetThreatList();
std::list<Unit*> UnitsWithMana;
for (std::list<HostileReference*>::const_iterator itr = AggroList.begin(); itr != AggroList.end(); ++itr)

View File

@@ -489,7 +489,7 @@ public:
AttackStart(Dragonmaw);
}
HostileReference* ref = me->GetThreatMgr().getOnlineContainer().getReferenceByTarget(caster);
HostileReference* ref = me->GetThreatMgr().GetOnlineContainer().getReferenceByTarget(caster);
if (ref)
ref->removeReference();
}