Files
tbd-station-14/Content.Server/Power/NodeGroups/BaseNetConnectorNodeGroup.cs
Vera Aguilera Puerto ed3bf94a3b Electrocution. (#4958)
Co-authored-by: Pieter-Jan Briers <pieterjan.briers@gmail.com>
2021-10-25 16:21:56 +02:00

33 lines
1.1 KiB
C#

using System.Collections.Generic;
using System.Linq;
using Content.Server.NodeContainer.NodeGroups;
using Content.Server.NodeContainer.Nodes;
using Content.Server.Power.Components;
namespace Content.Server.Power.NodeGroups
{
public abstract class BaseNetConnectorNodeGroup<TNetType> : BaseNodeGroup
{
public override void LoadNodes(List<Node> groupNodes)
{
base.LoadNodes(groupNodes);
foreach (var node in groupNodes)
{
var newNetConnectorComponents = node.Owner
.GetAllComponents<IBaseNetConnectorComponent<TNetType>>()
.Where(powerComp => (powerComp.NodeId == null || powerComp.NodeId == node.Name) &&
(NodeGroupID) powerComp.Voltage == node.NodeGroupID)
.ToList();
foreach (var netConnector in newNetConnectorComponents)
{
SetNetConnectorNet(netConnector);
}
}
}
protected abstract void SetNetConnectorNet(IBaseNetConnectorComponent<TNetType> netConnectorComponent);
}
}