Core/Objects: Broadcast object destroy packets to players using Far Sight and Mind Vision
Port From (https://github.com/TrinityCore/TrinityCore/commit/223be4c4eb937cc3a68c09c93d81faf930155adf)
This commit is contained in:
@@ -3114,24 +3114,9 @@ namespace Game.Entities
|
|||||||
if (!IsInWorld)
|
if (!IsInWorld)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
void destroyer(Player player)
|
WorldObjectClientDestroyWork destroyer = new() { obj = this };
|
||||||
{
|
WorldObjectVisibleChangeVisitor visitor = new(destroyer);
|
||||||
if (player == this)
|
Cell.VisitWorldObjects(this, visitor, GetVisibilityRange());
|
||||||
return;
|
|
||||||
|
|
||||||
if (!player.HaveAtClient(this))
|
|
||||||
return;
|
|
||||||
|
|
||||||
Unit unit = ToUnit();
|
|
||||||
if (unit != null && unit.GetCharmerGUID() == player.GetGUID())// @todo this is for puppet
|
|
||||||
return;
|
|
||||||
|
|
||||||
DestroyForPlayer(player);
|
|
||||||
player.m_clientGUIDs.Remove(GetGUID());
|
|
||||||
}
|
|
||||||
|
|
||||||
PlayerDistWorker worker = new(this, GetVisibilityRange(), destroyer);
|
|
||||||
Cell.VisitWorldObjects(this, worker, GetVisibilityRange());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void UpdateObjectVisibility(bool force = true)
|
public virtual void UpdateObjectVisibility(bool force = true)
|
||||||
@@ -3151,7 +3136,8 @@ namespace Game.Entities
|
|||||||
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);
|
||||||
Cell.VisitWorldObjects(this, notifier, GetVisibilityRange());
|
WorldObjectVisibleChangeVisitor visitor = new(notifier);
|
||||||
|
Cell.VisitWorldObjects(this, visitor, GetVisibilityRange());
|
||||||
|
|
||||||
ClearUpdateMask(false);
|
ClearUpdateMask(false);
|
||||||
}
|
}
|
||||||
@@ -4346,4 +4332,75 @@ namespace Game.Entities
|
|||||||
public bool DistanceCheck;
|
public bool DistanceCheck;
|
||||||
public bool AlertCheck;
|
public bool AlertCheck;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class WorldObjectVisibleChangeVisitor : Notifier
|
||||||
|
{
|
||||||
|
IDoWork<Player> work;
|
||||||
|
|
||||||
|
public WorldObjectVisibleChangeVisitor(IDoWork<Player> _work)
|
||||||
|
{
|
||||||
|
work = _work;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Visit(IList<Player> objs)
|
||||||
|
{
|
||||||
|
for (var i = 0; i < objs.Count; ++i)
|
||||||
|
{
|
||||||
|
Player player = objs[i];
|
||||||
|
|
||||||
|
work.Invoke(player);
|
||||||
|
|
||||||
|
foreach (Player viewer in player.GetSharedVisionList())
|
||||||
|
work.Invoke(viewer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Visit(IList<Creature> objs)
|
||||||
|
{
|
||||||
|
for (var i = 0; i < objs.Count; ++i)
|
||||||
|
{
|
||||||
|
Creature creature = objs[i];
|
||||||
|
foreach (Player viewer in creature.GetSharedVisionList())
|
||||||
|
work.Invoke(viewer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Visit(IList<DynamicObject> objs)
|
||||||
|
{
|
||||||
|
for (var i = 0; i < objs.Count; ++i)
|
||||||
|
{
|
||||||
|
DynamicObject dynamicObject = objs[i];
|
||||||
|
ObjectGuid guid = dynamicObject.GetCasterGUID();
|
||||||
|
|
||||||
|
if (guid.IsPlayer())
|
||||||
|
{
|
||||||
|
//GetCaster() will be nullptr if DynObj is in removelist
|
||||||
|
Player caster = Global.ObjAccessor.GetPlayer(dynamicObject, guid);
|
||||||
|
if (caster != null && caster.m_activePlayerData.FarsightObject == dynamicObject.GetGUID())
|
||||||
|
work.Invoke(caster);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
struct WorldObjectClientDestroyWork : IDoWork<Player>
|
||||||
|
{
|
||||||
|
public WorldObject obj;
|
||||||
|
|
||||||
|
public void Invoke(Player player)
|
||||||
|
{
|
||||||
|
if (player == obj)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!player.HaveAtClient(obj))
|
||||||
|
return;
|
||||||
|
|
||||||
|
Unit unit = obj.ToUnit();
|
||||||
|
if (unit != null && unit.GetCharmerGUID() == player.GetGUID()) /// @todo this is for puppet
|
||||||
|
return;
|
||||||
|
|
||||||
|
obj.DestroyForPlayer(player);
|
||||||
|
player.m_clientGUIDs.Remove(obj.GetGUID());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user