Node and NodeGroup nullability (#3047)
Co-authored-by: py01 <pyronetics01@gmail.com>
This commit is contained in:
@@ -1,6 +1,5 @@
|
|||||||
using System;
|
#nullable enable
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Content.Server.GameObjects.Components.Power;
|
using Content.Server.GameObjects.Components.Power;
|
||||||
using Content.Server.GameObjects.Components.Power.ApcNetComponents;
|
using Content.Server.GameObjects.Components.Power.ApcNetComponents;
|
||||||
@@ -58,7 +57,7 @@ namespace Content.Server.GameObjects.Components.NodeContainer.NodeGroups
|
|||||||
|
|
||||||
public void AddApc(ApcComponent apc)
|
public void AddApc(ApcComponent apc)
|
||||||
{
|
{
|
||||||
if (!apc.Owner.TryGetComponent(out BatteryComponent battery))
|
if (!apc.Owner.TryGetComponent<BatteryComponent>(out var battery))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using System.Collections.Generic;
|
#nullable enable
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Content.Server.GameObjects.Components.NodeContainer.Nodes;
|
using Content.Server.GameObjects.Components.NodeContainer.Nodes;
|
||||||
using Content.Server.GameObjects.Components.Power;
|
using Content.Server.GameObjects.Components.Power;
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using System.Collections.Generic;
|
#nullable enable
|
||||||
|
using System.Collections.Generic;
|
||||||
using Content.Server.GameObjects.Components.NodeContainer.Nodes;
|
using Content.Server.GameObjects.Components.NodeContainer.Nodes;
|
||||||
using Robust.Shared.IoC;
|
using Robust.Shared.IoC;
|
||||||
using Robust.Shared.Map;
|
using Robust.Shared.Map;
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using System.Collections.Generic;
|
#nullable enable
|
||||||
|
using System.Collections.Generic;
|
||||||
using Content.Server.Atmos;
|
using Content.Server.Atmos;
|
||||||
using Content.Server.GameObjects.Components.NodeContainer.Nodes;
|
using Content.Server.GameObjects.Components.NodeContainer.Nodes;
|
||||||
using Content.Server.GameObjects.EntitySystems;
|
using Content.Server.GameObjects.EntitySystems;
|
||||||
@@ -27,9 +28,9 @@ namespace Content.Server.GameObjects.Components.NodeContainer.NodeGroups
|
|||||||
[ViewVariables]
|
[ViewVariables]
|
||||||
private readonly List<PipeNode> _pipes = new();
|
private readonly List<PipeNode> _pipes = new();
|
||||||
|
|
||||||
[ViewVariables] private AtmosphereSystem _atmosphereSystem;
|
[ViewVariables] private AtmosphereSystem? _atmosphereSystem;
|
||||||
|
|
||||||
[ViewVariables] private IGridAtmosphereComponent GridAtmos => _atmosphereSystem.GetGridAtmosphere(GridId);
|
[ViewVariables] private IGridAtmosphereComponent? GridAtmos => _atmosphereSystem?.GetGridAtmosphere(GridId);
|
||||||
|
|
||||||
public override void Initialize(Node sourceNode)
|
public override void Initialize(Node sourceNode)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using System;
|
#nullable enable
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using Content.Server.GameObjects.Components.Power.PowerNetComponents;
|
using Content.Server.GameObjects.Components.Power.PowerNetComponents;
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
#nullable enable
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Robust.Shared.GameObjects.Components.Transform;
|
using Robust.Shared.GameObjects.Components.Transform;
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
#nullable enable
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@@ -29,7 +30,7 @@ namespace Content.Server.GameObjects.Components.NodeContainer.Nodes
|
|||||||
private INodeGroup _nodeGroup = BaseNodeGroup.NullGroup;
|
private INodeGroup _nodeGroup = BaseNodeGroup.NullGroup;
|
||||||
|
|
||||||
[ViewVariables]
|
[ViewVariables]
|
||||||
public IEntity Owner { get; private set; }
|
public IEntity Owner { get; private set; } = default!;
|
||||||
|
|
||||||
[ViewVariables]
|
[ViewVariables]
|
||||||
private bool _needsGroup = true;
|
private bool _needsGroup = true;
|
||||||
@@ -46,8 +47,6 @@ namespace Content.Server.GameObjects.Components.NodeContainer.Nodes
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private bool _deleting = false;
|
private bool _deleting = false;
|
||||||
|
|
||||||
private INodeGroupFactory _nodeGroupFactory;
|
|
||||||
|
|
||||||
public virtual void ExposeData(ObjectSerializer serializer)
|
public virtual void ExposeData(ObjectSerializer serializer)
|
||||||
{
|
{
|
||||||
serializer.DataField(this, x => x.NodeGroupID, "nodeGroupID", NodeGroupID.Default);
|
serializer.DataField(this, x => x.NodeGroupID, "nodeGroupID", NodeGroupID.Default);
|
||||||
@@ -56,7 +55,6 @@ namespace Content.Server.GameObjects.Components.NodeContainer.Nodes
|
|||||||
public virtual void Initialize(IEntity owner)
|
public virtual void Initialize(IEntity owner)
|
||||||
{
|
{
|
||||||
Owner = owner;
|
Owner = owner;
|
||||||
_nodeGroupFactory = IoCManager.Resolve<INodeGroupFactory>();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnContainerStartup()
|
public void OnContainerStartup()
|
||||||
@@ -163,7 +161,7 @@ namespace Content.Server.GameObjects.Components.NodeContainer.Nodes
|
|||||||
|
|
||||||
private INodeGroup MakeNewGroup()
|
private INodeGroup MakeNewGroup()
|
||||||
{
|
{
|
||||||
return _nodeGroupFactory.MakeNodeGroup(this);
|
return IoCManager.Resolve<INodeGroupFactory>().MakeNodeGroup(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user