refactor(Core/Creature): More functions capitalized (#10012)

* GetLeader

* IsFormed

* build
This commit is contained in:
Kitzunu
2022-02-10 18:40:00 +01:00
committed by GitHub
parent 0fa4a90aa8
commit 9d166722c4
5 changed files with 11 additions and 9 deletions
@@ -993,12 +993,12 @@ void Creature::Motion_Initialize()
{ {
if (!m_formation) if (!m_formation)
GetMotionMaster()->Initialize(); GetMotionMaster()->Initialize();
else if (m_formation->getLeader() == this) else if (m_formation->GetLeader() == this)
{ {
m_formation->FormationReset(false, true); m_formation->FormationReset(false, true);
GetMotionMaster()->Initialize(); GetMotionMaster()->Initialize();
} }
else if (m_formation->isFormed()) else if (m_formation->IsFormed())
GetMotionMaster()->MoveIdle(); //wait the order of leader GetMotionMaster()->MoveIdle(); //wait the order of leader
else else
GetMotionMaster()->Initialize(); GetMotionMaster()->Initialize();
@@ -1849,7 +1849,7 @@ void Creature::setDeathState(DeathState s, bool despawn)
} }
//Dismiss group if is leader //Dismiss group if is leader
if (m_formation && m_formation->getLeader() == this) if (m_formation && m_formation->GetLeader() == this)
m_formation->FormationReset(true, false); m_formation->FormationReset(true, false);
bool needsFalling = !despawn && (IsFlying() || IsHovering()) && !IsUnderWater(); bool needsFalling = !despawn && (IsFlying() || IsHovering()) && !IsUnderWater();
@@ -91,10 +91,12 @@ public:
explicit CreatureGroup(uint32 id) : m_leader(nullptr), m_groupID(id), m_Formed(false) {} explicit CreatureGroup(uint32 id) : m_leader(nullptr), m_groupID(id), m_Formed(false) {}
~CreatureGroup() {} ~CreatureGroup() {}
Creature* getLeader() const { return m_leader; } Creature* GetLeader() const { return m_leader; }
uint32 GetId() const { return m_groupID; } uint32 GetId() const { return m_groupID; }
bool IsEmpty() const { return m_members.empty(); } bool IsEmpty() const { return m_members.empty(); }
bool isFormed() const { return m_Formed; } bool IsFormed() const { return m_Formed; }
const CreatureGroupMemberType& GetMembers() const { return m_members; } const CreatureGroupMemberType& GetMembers() const { return m_members; }
void AddMember(Creature* member); void AddMember(Creature* member);
@@ -53,7 +53,7 @@ void RandomMovementGenerator<Creature>::_setRandomLocation(Creature* creature)
init.MoveTo(_currDestPosition.GetPositionX(), _currDestPosition.GetPositionY(), _currDestPosition.GetPositionZ()); init.MoveTo(_currDestPosition.GetPositionX(), _currDestPosition.GetPositionY(), _currDestPosition.GetPositionZ());
init.SetWalk(true); init.SetWalk(true);
init.Launch(); init.Launch();
if (creature->GetFormation() && creature->GetFormation()->getLeader() == creature) if (creature->GetFormation() && creature->GetFormation()->GetLeader() == creature)
creature->GetFormation()->LeaderMoveTo(_currDestPosition.GetPositionX(), _currDestPosition.GetPositionY(), _currDestPosition.GetPositionZ(), false); creature->GetFormation()->LeaderMoveTo(_currDestPosition.GetPositionX(), _currDestPosition.GetPositionY(), _currDestPosition.GetPositionZ(), false);
return; return;
} }
@@ -223,7 +223,7 @@ void RandomMovementGenerator<Creature>::_setRandomLocation(Creature* creature)
_preComputedPaths.erase(pathIdx); _preComputedPaths.erase(pathIdx);
//Call for creature group update //Call for creature group update
if (creature->GetFormation() && creature->GetFormation()->getLeader() == creature) if (creature->GetFormation() && creature->GetFormation()->GetLeader() == creature)
creature->GetFormation()->LeaderMoveTo(finalPoint.x, finalPoint.y, finalPoint.z, false); creature->GetFormation()->LeaderMoveTo(finalPoint.x, finalPoint.y, finalPoint.z, false);
} }
@@ -200,7 +200,7 @@ bool WaypointMovementGenerator<Creature>::StartMove(Creature* creature)
init.Launch(); init.Launch();
//Call for creature group update //Call for creature group update
if (creature->GetFormation() && creature->GetFormation()->getLeader() == creature) if (creature->GetFormation() && creature->GetFormation()->GetLeader() == creature)
creature->GetFormation()->LeaderMoveTo(formationDest.x, formationDest.y, formationDest.z, node->move_type == WAYPOINT_MOVE_TYPE_RUN); creature->GetFormation()->LeaderMoveTo(formationDest.x, formationDest.y, formationDest.z, node->move_type == WAYPOINT_MOVE_TYPE_RUN);
return true; return true;
@@ -227,7 +227,7 @@ struct npc_cameron : public ScriptedAI
_childrenGUIDs.push_back(jose->GetGUID()); _childrenGUIDs.push_back(jose->GetGUID());
// If Formation was disbanded, remake. // If Formation was disbanded, remake.
if (!me->GetFormation()->isFormed()) if (!me->GetFormation()->IsFormed())
for (auto guid : _childrenGUIDs) for (auto guid : _childrenGUIDs)
if (Creature* child = ObjectAccessor::GetCreature(*me, guid)) if (Creature* child = ObjectAccessor::GetCreature(*me, guid))
child->SearchFormation(); child->SearchFormation();