More power nullability (#3070)

This commit is contained in:
collinlunn
2021-02-02 05:20:24 -06:00
committed by GitHub
parent d0d2434fba
commit a5492bc943
20 changed files with 73 additions and 56 deletions

View File

@@ -1,3 +1,5 @@
#nullable enable
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using Content.Server.GameObjects.Components.NodeContainer;
using Content.Server.GameObjects.Components.NodeContainer.NodeGroups;
@@ -15,7 +17,7 @@ namespace Content.Server.GameObjects.Components.Power
[ViewVariables]
public TNetType Net { get => _net; set => SetNet(value); }
private TNetType _net;
private TNetType _net = default!; //set in OnAdd()
protected abstract TNetType NullNet { get; }
@@ -68,7 +70,7 @@ namespace Content.Server.GameObjects.Components.Power
protected abstract void RemoveSelfFromNet(TNetType net);
private bool TryFindNet(out TNetType foundNet)
private bool TryFindNet([NotNullWhen(true)] out TNetType? foundNet)
{
if (Owner.TryGetComponent<NodeContainerComponent>(out var container))
{