Core/Spawn: Move spawn group state management from sObjectMgr to the Map object, which makes it actually function as intended with instances.

Port From (https://github.com/TrinityCore/TrinityCore/commit/27806eeac9d2588d2f7a3b8a0852d45b15a6a241)
This commit is contained in:
hondacrx
2020-08-24 21:21:27 -04:00
parent 15f0aebb23
commit 18d7144ca6
9 changed files with 190 additions and 173 deletions
+10 -4
View File
@@ -243,13 +243,13 @@ namespace Game.Maps
{
uint groupId = pair.Key;
bool doSpawn = pair.Value == states.Spawn;
if (Global.ObjectMgr.IsSpawnGroupActive(groupId) == doSpawn)
if (instance.IsSpawnGroupActive(groupId) == doSpawn)
continue; // nothing to do here
// if we should spawn group, then spawn it...
if (doSpawn)
Global.ObjectMgr.SpawnGroupSpawn(groupId, instance);
instance.SpawnGroupSpawn(groupId, instance);
else // otherwise, set it as inactive so it no longer respawns (but don't despawn it)
Global.ObjectMgr.SetSpawnGroupActive(groupId, false);
instance.SetSpawnGroupActive(groupId, false);
}
}
@@ -331,7 +331,7 @@ namespace Game.Maps
if (bossInfo.state == EncounterState.ToBeDecided) // loading
{
bossInfo.state = state;
Log.outDebug(LogFilter.Scripts, $"InstanceScript: Inialize boss {id} state as {state}.");
Log.outDebug(LogFilter.Scripts, $"InstanceScript: Initialize boss {id} state as {state} (map {instance.GetId()}, {instance.GetInstanceId()}).");
return false;
}
else
@@ -339,6 +339,12 @@ namespace Game.Maps
if (bossInfo.state == state)
return false;
if (bossInfo.state == EncounterState.Done)
{
Log.outError(LogFilter.Maps, $"InstanceScript: Tried to set instance state from {bossInfo.state} back to {state} for map {instance.GetId()}, instance id {instance.GetInstanceId()}. Blocked!");
return false;
}
if (state == EncounterState.Done)
{
foreach (var guid in bossInfo.minion)