Portable Generator Rework (#19302)

This commit is contained in:
Pieter-Jan Briers
2023-08-25 20:40:42 +02:00
committed by GitHub
parent 50828363fe
commit bf16698efa
73 changed files with 1933 additions and 473 deletions

View File

@@ -3,9 +3,7 @@ using Content.Server.NodeContainer.NodeGroups;
using Content.Server.NodeContainer.Nodes;
using Content.Server.Power.Components;
using Content.Server.Power.EntitySystems;
using Content.Server.Power.Pow3r;
using JetBrains.Annotations;
using Robust.Shared.Map;
namespace Content.Server.Power.NodeGroups
{
@@ -24,13 +22,12 @@ namespace Content.Server.Power.NodeGroups
[NodeGroup(NodeGroupID.Apc)]
[UsedImplicitly]
public sealed partial class ApcNet : BaseNetConnectorNodeGroup<IApcNet>, IApcNet
public sealed partial class ApcNet : BasePowerNet<IApcNet>, IApcNet
{
private PowerNetSystem? _powerNetSystem;
[ViewVariables] public readonly List<ApcComponent> Apcs = new();
[ViewVariables] public readonly List<ApcPowerProviderComponent> Providers = new();
[ViewVariables] public readonly List<PowerConsumerComponent> Consumers = new();
//Debug property
[ViewVariables] private int TotalReceivers => Providers.Sum(provider => provider.LinkedReceivers.Count);
@@ -39,9 +36,6 @@ namespace Content.Server.Power.NodeGroups
private IEnumerable<ApcPowerReceiverComponent> AllReceivers =>
Providers.SelectMany(provider => provider.LinkedReceivers);
[ViewVariables]
public PowerState.Network NetworkNode { get; } = new();
public override void Initialize(Node sourceNode, IEntityManager entMan)
{
base.Initialize(sourceNode, entMan);
@@ -89,21 +83,7 @@ namespace Content.Server.Power.NodeGroups
QueueNetworkReconnect();
}
public void AddConsumer(PowerConsumerComponent consumer)
{
consumer.NetworkLoad.LinkedNetwork = default;
Consumers.Add(consumer);
QueueNetworkReconnect();
}
public void RemoveConsumer(PowerConsumerComponent consumer)
{
consumer.NetworkLoad.LinkedNetwork = default;
Consumers.Remove(consumer);
QueueNetworkReconnect();
}
public void QueueNetworkReconnect()
public override void QueueNetworkReconnect()
{
_powerNetSystem?.QueueReconnectApcNet(this);
}