mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-16 07:30:42 +01:00
Core/Conditions: Implemented conditions for spawn groups
This commit is contained in:
@@ -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)));
|
||||
|
||||
Reference in New Issue
Block a user