Remove INodeGroupManager, moves logic into NodeGroupSystem.
It was an absolutely redundant IoC service.
This commit is contained in:
@@ -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<INodeGroupManager>().AddDirtyNodeGroup(this);
|
||||
EntitySystem.Get<NodeGroupSystem>().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) { }
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
#nullable enable
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Content.Server.GameObjects.Components.NodeContainer.NodeGroups
|
||||
{
|
||||
/// <summary>
|
||||
/// Maintains a set of <see cref="INodeGroup"/>s that need to be remade with <see cref="INodeGroup.RemakeGroup"/>.
|
||||
/// Defers remaking to reduce recalculations when a group is altered multiple times in a frame.
|
||||
/// </summary>
|
||||
public interface INodeGroupManager
|
||||
{
|
||||
/// <summary>
|
||||
/// Queue up an <see cref="INodeGroup"/> to be remade.
|
||||
/// </summary>
|
||||
void AddDirtyNodeGroup(INodeGroup nodeGroup);
|
||||
|
||||
void Update(float frameTime);
|
||||
}
|
||||
|
||||
public class NodeGroupManager : INodeGroupManager
|
||||
{
|
||||
private readonly HashSet<INodeGroup> _dirtyNodeGroups = new();
|
||||
|
||||
public void AddDirtyNodeGroup(INodeGroup nodeGroup)
|
||||
{
|
||||
_dirtyNodeGroups.Add(nodeGroup);
|
||||
}
|
||||
|
||||
public void Update(float frameTime)
|
||||
{
|
||||
foreach (var group in _dirtyNodeGroups)
|
||||
{
|
||||
group.RemakeGroup();
|
||||
}
|
||||
_dirtyNodeGroups.Clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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<INodeGroup> _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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,7 +49,6 @@ namespace Content.Server
|
||||
IoCManager.Register<ActionManager, ActionManager>();
|
||||
IoCManager.Register<IPDAUplinkManager,PDAUplinkManager>();
|
||||
IoCManager.Register<INodeGroupFactory, NodeGroupFactory>();
|
||||
IoCManager.Register<INodeGroupManager, NodeGroupManager>();
|
||||
IoCManager.Register<IPowerNetManager, PowerNetManager>();
|
||||
IoCManager.Register<BlackboardManager, BlackboardManager>();
|
||||
IoCManager.Register<ConsiderationsManager, ConsiderationsManager>();
|
||||
|
||||
Reference in New Issue
Block a user