Core/Conditions: Implemented conditions for spawn groups
This commit is contained in:
1 parent
740fa9e65a
commit
cbd46b7664
7 files changed
+181
-68
No files matched your search
@@ -624,6 +624,7 @@ void Map::Update(uint32 t_diff)
|
||||
if (_respawnCheckTimer <= t_diff)
|
||||
{
|
||||
ProcessRespawns();
|
||||
UpdateSpawnGroupConditions();
|
||||
_respawnCheckTimer = sWorld->getIntConfig(CONFIG_RESPAWN_MINCHECKINTERVALMS);
|
||||
}
|
||||
else
|
||||
@@ -2191,6 +2192,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