Core/Conditions: Implemented conditions for spawn groups

This commit is contained in:
Shauren
2022-06-24 22:20:34 +02:00
parent e2cf6d68fc
commit 5d27939667
7 changed files with 188 additions and 81 deletions

View File

@@ -853,6 +853,7 @@ void Map::Update(uint32 t_diff)
if (_respawnCheckTimer <= t_diff)
{
ProcessRespawns();
UpdateSpawnGroupConditions();
_respawnCheckTimer = sWorld->getIntConfig(CONFIG_RESPAWN_MINCHECKINTERVALMS);
}
else
@@ -3640,6 +3641,28 @@ bool Map::IsSpawnGroupActive(uint32 groupId) const
return (_toggledSpawnGroupIds.find(groupId) != _toggledSpawnGroupIds.end()) != !(data->flags & SPAWNGROUP_FLAG_MANUAL_SPAWN);
}
void Map::UpdateSpawnGroupConditions()
{
std::vector<uint32> const* spawnGroups = sObjectMgr->GetSpawnGroupsForMap(GetId());
if (!spawnGroups)
return;
for (uint32 spawnGroupId : *spawnGroups)
{
bool isActive = IsSpawnGroupActive(spawnGroupId);
bool shouldBeActive = sConditionMgr->IsMapMeetingNotGroupedConditions(CONDITION_SOURCE_TYPE_SPAWN_GROUP, spawnGroupId, this);
if (isActive == shouldBeActive)
continue;
if (shouldBeActive)
SpawnGroupSpawn(spawnGroupId);
else if (ASSERT_NOTNULL(GetSpawnGroupData(spawnGroupId))->flags & SPAWNGROUP_FLAG_DESPAWN_ON_CONDITION_FAILURE)
SpawnGroupDespawn(spawnGroupId);
else
SetSpawnGroupInactive(spawnGroupId);
}
}
void Map::AddFarSpellCallback(FarSpellCallback&& callback)
{
_farSpellCallbacks.Enqueue(new FarSpellCallback(std::move(callback)));