feat(Core/Instance): Add TaskScheduler to the InstanceScript class (#17284)
feat(Core/Instance): Add TaskScheduler to the instancescript class
This commit is contained in:
@@ -218,6 +218,11 @@ void InstanceScript::UpdateMinionState(Creature* minion, EncounterState state)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void InstanceScript::Update(uint32 diff)
|
||||||
|
{
|
||||||
|
scheduler.Update(diff);
|
||||||
|
}
|
||||||
|
|
||||||
void InstanceScript::UpdateDoorState(GameObject* door)
|
void InstanceScript::UpdateDoorState(GameObject* door)
|
||||||
{
|
{
|
||||||
DoorInfoMapBounds range = doors.equal_range(door->GetEntry());
|
DoorInfoMapBounds range = doors.equal_range(door->GetEntry());
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
#include "CreatureAI.h"
|
#include "CreatureAI.h"
|
||||||
#include "ObjectMgr.h"
|
#include "ObjectMgr.h"
|
||||||
|
#include "TaskScheduler.h"
|
||||||
#include "World.h"
|
#include "World.h"
|
||||||
#include "ZoneScript.h"
|
#include "ZoneScript.h"
|
||||||
#include <set>
|
#include <set>
|
||||||
@@ -159,7 +160,7 @@ public:
|
|||||||
|
|
||||||
void SaveToDB();
|
void SaveToDB();
|
||||||
|
|
||||||
virtual void Update(uint32 /*diff*/) {}
|
virtual void Update(uint32 /*diff*/);
|
||||||
|
|
||||||
//Used by the map's CanEnter function.
|
//Used by the map's CanEnter function.
|
||||||
//This is to prevent players from entering during boss encounters.
|
//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
|
// Allows executing code using all creatures registered in the instance script as minions
|
||||||
void DoForAllMinions(uint32 id, std::function<void(Creature*)> exec);
|
void DoForAllMinions(uint32 id, std::function<void(Creature*)> exec);
|
||||||
|
|
||||||
|
TaskScheduler scheduler;
|
||||||
protected:
|
protected:
|
||||||
void SetHeaders(std::string const& dataHeaders);
|
void SetHeaders(std::string const& dataHeaders);
|
||||||
void SetBossNumber(uint32 number) { bosses.resize(number); }
|
void SetBossNumber(uint32 number) { bosses.resize(number); }
|
||||||
|
|||||||
@@ -154,8 +154,8 @@ public:
|
|||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
case DATA_RAJAXX_WAVE_ENGAGED:
|
case DATA_RAJAXX_WAVE_ENGAGED:
|
||||||
_scheduler.CancelGroup(GROUP_RAJAXX_WAVE_TIMER);
|
scheduler.CancelGroup(GROUP_RAJAXX_WAVE_TIMER);
|
||||||
_scheduler.Schedule(2min, [this](TaskContext context)
|
scheduler.Schedule(2min, [this](TaskContext context)
|
||||||
{
|
{
|
||||||
CallNextRajaxxLeader();
|
CallNextRajaxxLeader();
|
||||||
context.SetGroup(GROUP_RAJAXX_WAVE_TIMER);
|
context.SetGroup(GROUP_RAJAXX_WAVE_TIMER);
|
||||||
@@ -195,8 +195,8 @@ public:
|
|||||||
case NPC_YEGGETH:
|
case NPC_YEGGETH:
|
||||||
case NPC_PAKKON:
|
case NPC_PAKKON:
|
||||||
case NPC_ZERRAN:
|
case NPC_ZERRAN:
|
||||||
_scheduler.CancelAll();
|
scheduler.CancelAll();
|
||||||
_scheduler.Schedule(1s, [this, formation](TaskContext /*context*/)
|
scheduler.Schedule(1s, [this, formation](TaskContext /*context*/)
|
||||||
{
|
{
|
||||||
if (!formation->IsAnyMemberAlive())
|
if (!formation->IsAnyMemberAlive())
|
||||||
{
|
{
|
||||||
@@ -212,11 +212,6 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Update(uint32 diff) override
|
|
||||||
{
|
|
||||||
_scheduler.Update(diff);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SetGuidData(uint32 type, ObjectGuid data) override
|
void SetGuidData(uint32 type, ObjectGuid data) override
|
||||||
{
|
{
|
||||||
if (type == DATA_PARALYZED)
|
if (type == DATA_PARALYZED)
|
||||||
@@ -285,7 +280,7 @@ public:
|
|||||||
void ResetRajaxxWaves()
|
void ResetRajaxxWaves()
|
||||||
{
|
{
|
||||||
_rajaxWaveCounter = 0;
|
_rajaxWaveCounter = 0;
|
||||||
_scheduler.CancelAll();
|
scheduler.CancelAll();
|
||||||
for (auto const& data : RajaxxWavesData)
|
for (auto const& data : RajaxxWavesData)
|
||||||
{
|
{
|
||||||
if (Creature* creature = GetCreature(data.at(0)))
|
if (Creature* creature = GetCreature(data.at(0)))
|
||||||
@@ -308,7 +303,6 @@ public:
|
|||||||
ObjectGuid _andorovGUID;
|
ObjectGuid _andorovGUID;
|
||||||
uint32 _rajaxWaveCounter;
|
uint32 _rajaxWaveCounter;
|
||||||
uint8 _buruPhase;
|
uint8 _buruPhase;
|
||||||
TaskScheduler _scheduler;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
InstanceScript* GetInstanceScript(InstanceMap* map) const override
|
InstanceScript* GetInstanceScript(InstanceMap* map) const override
|
||||||
|
|||||||
@@ -210,15 +210,9 @@ public:
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Update(uint32 diff) override
|
|
||||||
{
|
|
||||||
scheduler.Update(diff);
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
GuidVector CThunGraspGUIDs;
|
GuidVector CThunGraspGUIDs;
|
||||||
uint32 BugTrioDeathCount;
|
uint32 BugTrioDeathCount;
|
||||||
TaskScheduler scheduler;
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user