diff --git a/Content.Server/GameObjects/Components/NodeContainer/NodeGroups/INodeGroup.cs b/Content.Server/GameObjects/Components/NodeContainer/NodeGroups/INodeGroup.cs index 615b6eb4e4..a3cbf37dd5 100644 --- a/Content.Server/GameObjects/Components/NodeContainer/NodeGroups/INodeGroup.cs +++ b/Content.Server/GameObjects/Components/NodeContainer/NodeGroups/INodeGroup.cs @@ -1,6 +1,8 @@ #nullable enable using System.Collections.Generic; using Content.Server.GameObjects.Components.NodeContainer.Nodes; +using Content.Server.GameObjects.EntitySystems; +using Robust.Shared.GameObjects; using Robust.Shared.IoC; using Robust.Shared.Map; using Robust.Shared.ViewVariables; @@ -61,7 +63,7 @@ namespace Content.Server.GameObjects.Components.NodeContainer.NodeGroups { _nodes.Remove(node); OnRemoveNode(node); - IoCManager.Resolve().AddDirtyNodeGroup(this); + EntitySystem.Get().AddDirtyNodeGroup(this); } public void CombineGroup(INodeGroup newGroup) @@ -103,7 +105,7 @@ namespace Content.Server.GameObjects.Components.NodeContainer.NodeGroups } protected virtual void OnAddNode(Node node) { } - + protected virtual void OnRemoveNode(Node node) { } protected virtual void OnGivingNodesForCombine(INodeGroup newGroup) { } diff --git a/Content.Server/GameObjects/Components/NodeContainer/NodeGroups/INodeGroupManager.cs b/Content.Server/GameObjects/Components/NodeContainer/NodeGroups/INodeGroupManager.cs deleted file mode 100644 index 186c2d5cc9..0000000000 --- a/Content.Server/GameObjects/Components/NodeContainer/NodeGroups/INodeGroupManager.cs +++ /dev/null @@ -1,38 +0,0 @@ -#nullable enable -using System.Collections.Generic; - -namespace Content.Server.GameObjects.Components.NodeContainer.NodeGroups -{ - /// - /// Maintains a set of s that need to be remade with . - /// Defers remaking to reduce recalculations when a group is altered multiple times in a frame. - /// - public interface INodeGroupManager - { - /// - /// Queue up an to be remade. - /// - void AddDirtyNodeGroup(INodeGroup nodeGroup); - - void Update(float frameTime); - } - - public class NodeGroupManager : INodeGroupManager - { - private readonly HashSet _dirtyNodeGroups = new(); - - public void AddDirtyNodeGroup(INodeGroup nodeGroup) - { - _dirtyNodeGroups.Add(nodeGroup); - } - - public void Update(float frameTime) - { - foreach (var group in _dirtyNodeGroups) - { - group.RemakeGroup(); - } - _dirtyNodeGroups.Clear(); - } - } -} diff --git a/Content.Server/GameObjects/EntitySystems/NodeGroupSystem.cs b/Content.Server/GameObjects/EntitySystems/NodeGroupSystem.cs index 5c51fd0b2e..1df9de09f3 100644 --- a/Content.Server/GameObjects/EntitySystems/NodeGroupSystem.cs +++ b/Content.Server/GameObjects/EntitySystems/NodeGroupSystem.cs @@ -1,19 +1,30 @@ -using Content.Server.GameObjects.Components.NodeContainer.NodeGroups; +using System.Collections.Generic; +using Content.Server.GameObjects.Components.NodeContainer.NodeGroups; using JetBrains.Annotations; using Robust.Shared.GameObjects; -using Robust.Shared.IoC; namespace Content.Server.GameObjects.EntitySystems { [UsedImplicitly] public class NodeGroupSystem : EntitySystem { - [Dependency] private readonly INodeGroupManager _groupManager = default!; + private readonly HashSet _dirtyNodeGroups = new(); + + public void AddDirtyNodeGroup(INodeGroup nodeGroup) + { + _dirtyNodeGroups.Add(nodeGroup); + } public override void Update(float frameTime) { base.Update(frameTime); - _groupManager.Update(frameTime); + + foreach (var group in _dirtyNodeGroups) + { + group.RemakeGroup(); + } + + _dirtyNodeGroups.Clear(); } } } diff --git a/Content.Server/ServerContentIoC.cs b/Content.Server/ServerContentIoC.cs index 67a39ef973..d5bda609ae 100644 --- a/Content.Server/ServerContentIoC.cs +++ b/Content.Server/ServerContentIoC.cs @@ -49,7 +49,6 @@ namespace Content.Server IoCManager.Register(); IoCManager.Register(); IoCManager.Register(); - IoCManager.Register(); IoCManager.Register(); IoCManager.Register(); IoCManager.Register();