Remove IoC resolves in BaseNetConnectorNodeGroup and friends (#20333)
This commit is contained in:
@@ -6,29 +6,33 @@ namespace Content.Server.Power.NodeGroups
|
||||
{
|
||||
public abstract class BaseNetConnectorNodeGroup<TNetType> : BaseNodeGroup
|
||||
{
|
||||
protected IEntityManager EntMan = default!;
|
||||
|
||||
public override void Initialize(Node sourceNode, IEntityManager entMan)
|
||||
{
|
||||
base.Initialize(sourceNode, entMan);
|
||||
EntMan = entMan;
|
||||
}
|
||||
|
||||
public override void LoadNodes(List<Node> groupNodes)
|
||||
{
|
||||
base.LoadNodes(groupNodes);
|
||||
var entManager = IoCManager.Resolve<IEntityManager>();
|
||||
|
||||
foreach (var node in groupNodes)
|
||||
{
|
||||
var newNetConnectorComponents = new List<IBaseNetConnectorComponent<TNetType>>();
|
||||
|
||||
foreach (var comp in entManager.GetComponents<IBaseNetConnectorComponent<TNetType>>(node.Owner))
|
||||
// TODO POWER PERFORMANCE
|
||||
// Replace this with TryComps or some other sane way of doing this, the current solution is awful.
|
||||
// This allocates an array, copies ALL of an entities components over, and then iterates over them to
|
||||
// yield any that implement the interface.
|
||||
foreach (var comp in EntMan.GetComponents<IBaseNetConnectorComponent<TNetType>>(node.Owner))
|
||||
{
|
||||
if ((comp.NodeId == null ||
|
||||
comp.NodeId == node.Name) &&
|
||||
(NodeGroupID) comp.Voltage == node.NodeGroupID)
|
||||
{
|
||||
newNetConnectorComponents.Add(comp);
|
||||
SetNetConnectorNet(comp);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var netConnector in newNetConnectorComponents)
|
||||
{
|
||||
SetNetConnectorNet(netConnector);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user