Core/Objects: Cleanup SmoothPhasing code - move to separate files and better integrate it with visibility system

Port From (https://github.com/TrinityCore/TrinityCore/commit/70442041300bb0a1146717497fd5f771d874befa)
This commit is contained in:
hondacrx
2022-03-09 14:51:55 -05:00
parent f0d1a632ff
commit ffd0f4280b
9 changed files with 219 additions and 137 deletions
+40 -1
View File
@@ -20,6 +20,7 @@ using Framework.Dynamic;
using Game.DataStorage;
using System;
using System.Collections.Generic;
using Game.Maps;
namespace Game.Entities
{
@@ -241,7 +242,45 @@ namespace Game.Entities
public override void UpdateObjectVisibilityOnCreate()
{
UpdateObjectVisibility(true);
List<WorldObject> objectsToUpdate = new();
objectsToUpdate.Add(this);
SmoothPhasing smoothPhasing = GetSmoothPhasing();
WorldObject original = GetSummoner();
if (original != null)
if (smoothPhasing != null && smoothPhasing.IsReplacing(original.GetGUID()))
objectsToUpdate.Add(original);
VisibleChangesNotifier notifier = new(objectsToUpdate);
Cell.VisitWorldObjects(this, notifier, GetVisibilityRange());
}
public override void UpdateObjectVisibilityOnDestroy()
{
List<WorldObject> objectsToUpdate = new();
objectsToUpdate.Add(this);
WorldObject original = GetSummoner();
SmoothPhasing smoothPhasing = GetSmoothPhasing();
if (original != null && smoothPhasing != null && smoothPhasing.IsReplacing(original.GetGUID()))
{
objectsToUpdate.Add(original);
// disable replacement without removing - it is still needed for next step (visibility update)
SmoothPhasing originalSmoothPhasing = original.GetSmoothPhasing();
if (originalSmoothPhasing != null)
originalSmoothPhasing.DisableReplacementForSeer(GetDemonCreatorGUID());
}
VisibleChangesNotifier notifier = new(objectsToUpdate);
Cell.VisitWorldObjects(this, notifier, GetVisibilityRange());
if (original != null && smoothPhasing != null && smoothPhasing.IsReplacing(original.GetGUID()))
{
SmoothPhasing originalSmoothPhasing = original.GetSmoothPhasing();
if (originalSmoothPhasing != null)
originalSmoothPhasing.ClearViewerDependentInfo(GetDemonCreatorGUID());
}
}
public void SetTempSummonType(TempSummonType type)