Fix pipe net null error (#9508)

This commit is contained in:
Leon Friedrich
2022-07-07 15:36:07 +12:00
committed by GitHub
parent 731e9cbd9f
commit d9c247b310
6 changed files with 32 additions and 28 deletions

View File

@@ -26,7 +26,7 @@ namespace Content.Server.Power.NodeGroups
[UsedImplicitly]
public sealed class ApcNet : BaseNetConnectorNodeGroup<IApcNet>, IApcNet
{
private readonly PowerNetSystem _powerNetSystem = EntitySystem.Get<PowerNetSystem>();
private PowerNetSystem? _powerNetSystem;
[ViewVariables] public readonly List<ApcComponent> Apcs = new();
[ViewVariables] public readonly List<ApcPowerProviderComponent> Providers = new();
@@ -42,10 +42,11 @@ namespace Content.Server.Power.NodeGroups
[ViewVariables]
public PowerState.Network NetworkNode { get; } = new();
public override void Initialize(Node sourceNode, IEntityManager? entMan = null)
public override void Initialize(Node sourceNode, IEntityManager entMan)
{
base.Initialize(sourceNode, entMan);
_powerNetSystem = entMan.EntitySysManager.GetEntitySystem<PowerNetSystem>();
_powerNetSystem.InitApcNet(this);
}
@@ -53,7 +54,7 @@ namespace Content.Server.Power.NodeGroups
{
base.AfterRemake(newGroups);
_powerNetSystem.DestroyApcNet(this);
_powerNetSystem?.DestroyApcNet(this);
}
public void AddApc(ApcComponent apc)
@@ -104,7 +105,7 @@ namespace Content.Server.Power.NodeGroups
public void QueueNetworkReconnect()
{
_powerNetSystem.QueueReconnectApcNet(this);
_powerNetSystem?.QueueReconnectApcNet(this);
}
protected override void SetNetConnectorNet(IBaseNetConnectorComponent<IApcNet> netConnectorComponent)
@@ -114,6 +115,9 @@ namespace Content.Server.Power.NodeGroups
public override string? GetDebugData()
{
if (_powerNetSystem == null)
return null;
// This is just recycling the multi-tool examine.
var ps = _powerNetSystem.GetNetworkStatistics(NetworkNode);