feat(Core/Grids): Implement visibility notifier (#15919)

* Cherry-picked from TrinityCore (unable to find author)
This commit is contained in:
AG
2023-09-28 22:28:28 +02:00
committed by GitHub
parent 29af6cc886
commit 2779833768
33 changed files with 1254 additions and 510 deletions

View File

@@ -26,6 +26,35 @@
#include "Transport.h"
#include "Vehicle.h"
void ObjectGridEvacuator::Visit(CreatureMapType& m)
{
// creature in unloading grid can have respawn point in another grid
// if it will be unloaded then it will not respawn in original grid until unload/load original grid
// move to respawn point to prevent this case. For player view in respawn grid this will be normal respawn.
for (CreatureMapType::iterator iter = m.begin(); iter != m.end();)
{
Creature* c = iter->GetSource();
++iter;
ASSERT(!c->IsPet() && "ObjectGridRespawnMover must not be called for pets");
c->GetMap()->CreatureRespawnRelocation(c, true);
}
}
void ObjectGridEvacuator::Visit(GameObjectMapType& m)
{
// gameobject in unloading grid can have respawn point in another grid
// if it will be unloaded then it will not respawn in original grid until unload/load original grid
// move to respawn point to prevent this case. For player view in respawn grid this will be normal respawn.
for (GameObjectMapType::iterator iter = m.begin(); iter != m.end();)
{
GameObject* go = iter->GetSource();
++iter;
go->GetMap()->GameObjectRespawnRelocation(go, true);
}
}
// for loading world object at grid loading (Corpses)
//TODO: to implement npc on transport, also need to load npcs at grid loading
class ObjectWorldLoader
@@ -229,6 +258,17 @@ void ObjectGridUnloader::Visit(GridRefMgr<T>& m)
}
}
void ObjectGridStoper::Visit(CreatureMapType& m)
{
// stop any fights at grid de-activation and remove dynobjects created at cast by creatures
for (CreatureMapType::iterator iter = m.begin(); iter != m.end(); ++iter)
{
iter->GetSource()->RemoveAllDynObjects();
if (iter->GetSource()->IsInCombat())
iter->GetSource()->CombatStop();
}
}
template<class T>
void ObjectGridCleaner::Visit(GridRefMgr<T>& m)
{