Core/Objects: Add overridable function UpdateObjectVisibilityOnDestroy

Port From (https://github.com/TrinityCore/TrinityCore/commit/472384e75781ce362af9721fc16928da9eea82dd)
This commit is contained in:
hondacrx
2022-03-09 12:26:16 -05:00
parent b1de89a781
commit 510a1a0208
4 changed files with 11 additions and 9 deletions
+3 -3
View File
@@ -167,7 +167,7 @@ namespace Game.Entities
ai.CorpseRemoved(respawnDelay); ai.CorpseRemoved(respawnDelay);
if (destroyForNearbyPlayers) if (destroyForNearbyPlayers)
DestroyForNearbyPlayers(); UpdateObjectVisibilityOnDestroy();
// Should get removed later, just keep "compatibility" with scripts // Should get removed later, just keep "compatibility" with scripts
if (setSpawnTime) if (setSpawnTime)
@@ -1907,7 +1907,7 @@ namespace Game.Entities
if (m_respawnCompatibilityMode) if (m_respawnCompatibilityMode)
{ {
DestroyForNearbyPlayers(); UpdateObjectVisibilityOnDestroy();
RemoveCorpse(false, false); RemoveCorpse(false, false);
if (GetDeathState() == DeathState.Dead) if (GetDeathState() == DeathState.Dead)
@@ -1971,7 +1971,7 @@ namespace Game.Entities
uint respawnDelay = GetRespawnDelay(); uint respawnDelay = GetRespawnDelay();
// do it before killing creature // do it before killing creature
DestroyForNearbyPlayers(); UpdateObjectVisibilityOnDestroy();
bool overrideRespawnTime = false; bool overrideRespawnTime = false;
if (IsAlive()) if (IsAlive())
@@ -865,7 +865,7 @@ namespace Game.Entities
m_respawnTime = 0; m_respawnTime = 0;
if (m_spawnId != 0) if (m_spawnId != 0)
DestroyForNearbyPlayers(); UpdateObjectVisibilityOnDestroy();
else else
Delete(); Delete();
@@ -883,7 +883,7 @@ namespace Game.Entities
SaveRespawnTime(); SaveRespawnTime();
if (m_respawnCompatibilityMode) if (m_respawnCompatibilityMode)
DestroyForNearbyPlayers(); UpdateObjectVisibilityOnDestroy();
else else
AddObjectToRemoveList(); AddObjectToRemoveList();
+3 -1
View File
@@ -107,7 +107,7 @@ namespace Game.Entities
return; return;
if (!ObjectTypeMask.HasAnyFlag(TypeMask.Item | TypeMask.Container)) if (!ObjectTypeMask.HasAnyFlag(TypeMask.Item | TypeMask.Container))
DestroyForNearbyPlayers(); UpdateObjectVisibilityOnDestroy();
IsInWorld = false; IsInWorld = false;
ClearUpdateMask(true); ClearUpdateMask(true);
@@ -2813,6 +2813,8 @@ namespace Game.Entities
UpdateObjectVisibility(true); UpdateObjectVisibility(true);
} }
public virtual void UpdateObjectVisibilityOnDestroy() { DestroyForNearbyPlayers(); }
public virtual void BuildUpdate(Dictionary<Player, UpdateData> data) public virtual void BuildUpdate(Dictionary<Player, UpdateData> data)
{ {
var notifier = new WorldObjectChangeAccumulator(this, data); var notifier = new WorldObjectChangeAccumulator(this, data);
+3 -3
View File
@@ -956,7 +956,7 @@ namespace Game.Maps
SendRemoveTransports(player); SendRemoveTransports(player);
if (!inWorld) // if was in world, RemoveFromWorld() called DestroyForNearbyPlayers() if (!inWorld) // if was in world, RemoveFromWorld() called DestroyForNearbyPlayers()
player.DestroyForNearbyPlayers(); // previous player.UpdateObjectVisibility(true) player.UpdateObjectVisibilityOnDestroy();
Cell cell = player.GetCurrentCell(); Cell cell = player.GetCurrentCell();
RemoveFromGrid(player, cell); RemoveFromGrid(player, cell);
@@ -977,7 +977,7 @@ namespace Game.Maps
GetMultiPersonalPhaseTracker().UnregisterTrackedObject(obj); GetMultiPersonalPhaseTracker().UnregisterTrackedObject(obj);
if (!inWorld) // if was in world, RemoveFromWorld() called DestroyForNearbyPlayers() if (!inWorld) // if was in world, RemoveFromWorld() called DestroyForNearbyPlayers()
obj.DestroyForNearbyPlayers(); // previous obj.UpdateObjectVisibility(true) obj.UpdateObjectVisibilityOnDestroy();
Cell cell = obj.GetCurrentCell(); Cell cell = obj.GetCurrentCell();
RemoveFromGrid(obj, cell); RemoveFromGrid(obj, cell);
@@ -3323,7 +3323,7 @@ namespace Game.Maps
{ {
Cypher.Assert(corpse); Cypher.Assert(corpse);
corpse.DestroyForNearbyPlayers(); corpse.UpdateObjectVisibilityOnDestroy();
if (corpse.GetCurrentCell() != null) if (corpse.GetCurrentCell() != null)
RemoveFromMap(corpse, false); RemoveFromMap(corpse, false);
else else