Replaces AnchoredChanged C# event with ComponentMessage (#2905)
* Replaces AnchoredChanged C# event with ComponentMessage * Removes unneeded fields Co-authored-by: py01 <pyronetics01@gmail.com>
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using Content.Server.GameObjects.Components.NodeContainer.NodeGroups;
|
||||
@@ -66,17 +66,29 @@ namespace Content.Server.GameObjects.Components.NodeContainer.Nodes
|
||||
if (Owner.TryGetComponent<IPhysicsComponent>(out var physics))
|
||||
{
|
||||
AnchorUpdate();
|
||||
physics.AnchoredChanged += AnchorUpdate;
|
||||
}
|
||||
}
|
||||
|
||||
public void AnchorUpdate()
|
||||
{
|
||||
if (Anchored)
|
||||
{
|
||||
if (_needsGroup)
|
||||
{
|
||||
TryAssignGroupIfNeeded();
|
||||
CombineGroupWithReachable();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
NodeGroup.RemoveNode(this);
|
||||
ClearNodeGroup();
|
||||
}
|
||||
}
|
||||
|
||||
public void OnContainerRemove()
|
||||
{
|
||||
_deleting = true;
|
||||
if (Owner.TryGetComponent<IPhysicsComponent>(out var physics))
|
||||
{
|
||||
physics.AnchoredChanged -= AnchorUpdate;
|
||||
}
|
||||
NodeGroup.RemoveNode(this);
|
||||
}
|
||||
|
||||
@@ -153,22 +165,5 @@ namespace Content.Server.GameObjects.Components.NodeContainer.Nodes
|
||||
{
|
||||
return _nodeGroupFactory.MakeNodeGroup(this);
|
||||
}
|
||||
|
||||
private void AnchorUpdate()
|
||||
{
|
||||
if (Anchored)
|
||||
{
|
||||
if (_needsGroup)
|
||||
{
|
||||
TryAssignGroupIfNeeded();
|
||||
CombineGroupWithReachable();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
NodeGroup.RemoveNode(this);
|
||||
ClearNodeGroup();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user