diff --git a/Content.Server/GameObjects/Components/NodeContainer/NodeGroups/BaseNetConnectorNodeGroup.cs b/Content.Server/GameObjects/Components/NodeContainer/NodeGroups/BaseNetConnectorNodeGroup.cs index 5c0dacbb04..ea6eb28ba9 100644 --- a/Content.Server/GameObjects/Components/NodeContainer/NodeGroups/BaseNetConnectorNodeGroup.cs +++ b/Content.Server/GameObjects/Components/NodeContainer/NodeGroups/BaseNetConnectorNodeGroup.cs @@ -16,7 +16,7 @@ namespace Content.Server.GameObjects.Components.NodeContainer.NodeGroups .GetAllComponents() .Where(powerComp => (NodeGroupID) powerComp.Voltage == node.NodeGroupID) .ToList(); - _netConnectorComponents.Add(node, newNetConnectorComponents); + _netConnectorComponents[node] = newNetConnectorComponents; foreach (var netConnectorComponent in newNetConnectorComponents) { SetNetConnectorNet(netConnectorComponent); diff --git a/Content.Server/GameObjects/Components/NodeContainer/Nodes/Node.cs b/Content.Server/GameObjects/Components/NodeContainer/Nodes/Node.cs index 07b4847f8f..9edaa5246d 100644 --- a/Content.Server/GameObjects/Components/NodeContainer/Nodes/Node.cs +++ b/Content.Server/GameObjects/Components/NodeContainer/Nodes/Node.cs @@ -73,6 +73,10 @@ namespace Content.Server.GameObjects.Components.NodeContainer.Nodes } } + public virtual void OnSnapGridMove() + { + } + public virtual void OnContainerShutdown() { _deleting = true; diff --git a/Content.Server/GameObjects/EntitySystems/NodeGroupSystem.cs b/Content.Server/GameObjects/EntitySystems/NodeGroupSystem.cs index 1df9de09f3..4577aecce0 100644 --- a/Content.Server/GameObjects/EntitySystems/NodeGroupSystem.cs +++ b/Content.Server/GameObjects/EntitySystems/NodeGroupSystem.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using Content.Server.GameObjects.Components.NodeContainer; using Content.Server.GameObjects.Components.NodeContainer.NodeGroups; using JetBrains.Annotations; using Robust.Shared.GameObjects; @@ -10,6 +11,22 @@ namespace Content.Server.GameObjects.EntitySystems { private readonly HashSet _dirtyNodeGroups = new(); + public override void Initialize() + { + base.Initialize(); + + SubscribeLocalEvent(OnSnapGridPositionChanged); + } + + private void OnSnapGridPositionChanged(EntityUid uid, NodeContainerComponent component, SnapGridPositionChangedEvent args) + { + foreach (var node in component.Nodes.Values) + { + node.OnSnapGridMove(); + AddDirtyNodeGroup(node.NodeGroup); + } + } + public void AddDirtyNodeGroup(INodeGroup nodeGroup) { _dirtyNodeGroups.Add(nodeGroup);