feat(Core/Instance): Add TaskScheduler to the InstanceScript class (#17284)

feat(Core/Instance): Add TaskScheduler to the instancescript class
This commit is contained in:
Skjalf
2023-09-17 10:56:02 -03:00
committed by GitHub
parent 655f2bb15b
commit 0bf559f975
4 changed files with 14 additions and 18 deletions

View File

@@ -218,6 +218,11 @@ void InstanceScript::UpdateMinionState(Creature* minion, EncounterState state)
}
}
void InstanceScript::Update(uint32 diff)
{
scheduler.Update(diff);
}
void InstanceScript::UpdateDoorState(GameObject* door)
{
DoorInfoMapBounds range = doors.equal_range(door->GetEntry());

View File

@@ -20,6 +20,7 @@
#include "CreatureAI.h"
#include "ObjectMgr.h"
#include "TaskScheduler.h"
#include "World.h"
#include "ZoneScript.h"
#include <set>
@@ -159,7 +160,7 @@ public:
void SaveToDB();
virtual void Update(uint32 /*diff*/) {}
virtual void Update(uint32 /*diff*/);
//Used by the map's CanEnter function.
//This is to prevent players from entering during boss encounters.
@@ -263,6 +264,8 @@ public:
// Allows executing code using all creatures registered in the instance script as minions
void DoForAllMinions(uint32 id, std::function<void(Creature*)> exec);
TaskScheduler scheduler;
protected:
void SetHeaders(std::string const& dataHeaders);
void SetBossNumber(uint32 number) { bosses.resize(number); }

View File

@@ -154,8 +154,8 @@ public:
switch (type)
{
case DATA_RAJAXX_WAVE_ENGAGED:
_scheduler.CancelGroup(GROUP_RAJAXX_WAVE_TIMER);
_scheduler.Schedule(2min, [this](TaskContext context)
scheduler.CancelGroup(GROUP_RAJAXX_WAVE_TIMER);
scheduler.Schedule(2min, [this](TaskContext context)
{
CallNextRajaxxLeader();
context.SetGroup(GROUP_RAJAXX_WAVE_TIMER);
@@ -195,8 +195,8 @@ public:
case NPC_YEGGETH:
case NPC_PAKKON:
case NPC_ZERRAN:
_scheduler.CancelAll();
_scheduler.Schedule(1s, [this, formation](TaskContext /*context*/)
scheduler.CancelAll();
scheduler.Schedule(1s, [this, formation](TaskContext /*context*/)
{
if (!formation->IsAnyMemberAlive())
{
@@ -212,11 +212,6 @@ public:
}
}
void Update(uint32 diff) override
{
_scheduler.Update(diff);
}
void SetGuidData(uint32 type, ObjectGuid data) override
{
if (type == DATA_PARALYZED)
@@ -285,7 +280,7 @@ public:
void ResetRajaxxWaves()
{
_rajaxWaveCounter = 0;
_scheduler.CancelAll();
scheduler.CancelAll();
for (auto const& data : RajaxxWavesData)
{
if (Creature* creature = GetCreature(data.at(0)))
@@ -308,7 +303,6 @@ public:
ObjectGuid _andorovGUID;
uint32 _rajaxWaveCounter;
uint8 _buruPhase;
TaskScheduler _scheduler;
};
InstanceScript* GetInstanceScript(InstanceMap* map) const override

View File

@@ -210,15 +210,9 @@ public:
return true;
}
void Update(uint32 diff) override
{
scheduler.Update(diff);
}
private:
GuidVector CThunGraspGUIDs;
uint32 BugTrioDeathCount;
TaskScheduler scheduler;
};
};