Replace CanBeNull annotations with nullable reference types (#1270)
Co-authored-by: Pieter-Jan Briers <pieterjan.briers+git@gmail.com>
This commit is contained in:
@@ -1,11 +1,10 @@
|
||||
#nullable enable
|
||||
using System.Collections.Generic;
|
||||
using Content.Server.Interfaces;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.ViewVariables;
|
||||
|
||||
#nullable enable
|
||||
|
||||
namespace Content.Server.GameObjects.Components.Access
|
||||
{
|
||||
/// <summary>
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#nullable enable
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@@ -10,8 +11,6 @@ using Robust.Shared.Interfaces.GameObjects;
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.ViewVariables;
|
||||
|
||||
#nullable enable
|
||||
|
||||
namespace Content.Server.GameObjects.Components.Access
|
||||
{
|
||||
/// <summary>
|
||||
@@ -68,7 +67,6 @@ namespace Content.Server.GameObjects.Components.Access
|
||||
return _accessLists.Count == 0 || _accessLists.Any(a => a.IsSubsetOf(accessTags));
|
||||
}
|
||||
|
||||
[CanBeNull]
|
||||
public static ICollection<string> FindAccessTags(IEntity entity)
|
||||
{
|
||||
if (entity.TryGetComponent(out IAccess accessComponent))
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#nullable enable
|
||||
using Content.Shared.Jobs;
|
||||
using Robust.Server.Interfaces.GameObjects;
|
||||
using Robust.Shared.GameObjects;
|
||||
@@ -5,8 +6,6 @@ using Robust.Shared.IoC;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
#nullable enable
|
||||
|
||||
namespace Content.Server.GameObjects.Components.Access
|
||||
{
|
||||
[RegisterComponent]
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
using Content.Server.Cargo;
|
||||
#nullable enable
|
||||
using Content.Server.Cargo;
|
||||
using Content.Server.GameObjects.Components.Power.ApcNetComponents;
|
||||
using Content.Server.GameObjects.EntitySystems;
|
||||
using Content.Server.Interfaces.GameObjects.Components.Interaction;
|
||||
using Content.Shared.GameObjects.Components.Cargo;
|
||||
using Content.Shared.Prototypes.Cargo;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Server.GameObjects.Components.UserInterface;
|
||||
using Robust.Server.Interfaces.GameObjects;
|
||||
using Robust.Shared.GameObjects;
|
||||
@@ -20,39 +20,43 @@ namespace Content.Server.GameObjects.Components.Cargo
|
||||
public class CargoConsoleComponent : SharedCargoConsoleComponent, IActivate
|
||||
{
|
||||
#pragma warning disable 649
|
||||
[Dependency] private readonly ICargoOrderDataManager _cargoOrderDataManager;
|
||||
[Dependency] private readonly ICargoOrderDataManager _cargoOrderDataManager = default!;
|
||||
#pragma warning restore 649
|
||||
|
||||
[ViewVariables]
|
||||
public int Points = 1000;
|
||||
|
||||
private BoundUserInterface _userInterface;
|
||||
private BoundUserInterface _userInterface = default!;
|
||||
|
||||
[ViewVariables]
|
||||
public GalacticMarketComponent Market { get; private set; }
|
||||
[ViewVariables]
|
||||
public CargoOrderDatabaseComponent Orders { get; private set; }
|
||||
|
||||
private CargoBankAccount _bankAccount;
|
||||
public GalacticMarketComponent Market { get; private set; } = default!;
|
||||
|
||||
[ViewVariables]
|
||||
[CanBeNull]
|
||||
public CargoBankAccount BankAccount
|
||||
public CargoOrderDatabaseComponent Orders { get; private set; } = default!;
|
||||
|
||||
private CargoBankAccount? _bankAccount;
|
||||
|
||||
[ViewVariables]
|
||||
public CargoBankAccount? BankAccount
|
||||
{
|
||||
get => _bankAccount;
|
||||
private set
|
||||
{
|
||||
if (_bankAccount == value)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (_bankAccount != null)
|
||||
{
|
||||
_bankAccount.OnBalanceChange -= UpdateUIState;
|
||||
}
|
||||
|
||||
_bankAccount = value;
|
||||
|
||||
if (value != null)
|
||||
{
|
||||
_bankAccount.OnBalanceChange += UpdateUIState;
|
||||
value.OnBalanceChange += UpdateUIState;
|
||||
}
|
||||
|
||||
UpdateUIState();
|
||||
@@ -61,9 +65,9 @@ namespace Content.Server.GameObjects.Components.Cargo
|
||||
|
||||
private bool _requestOnly = false;
|
||||
|
||||
private PowerReceiverComponent _powerReceiver;
|
||||
private PowerReceiverComponent _powerReceiver = default!;
|
||||
private bool Powered => _powerReceiver.Powered;
|
||||
private CargoConsoleSystem _cargoConsoleSystem;
|
||||
private CargoConsoleSystem _cargoConsoleSystem = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
@@ -98,8 +102,11 @@ namespace Content.Server.GameObjects.Components.Cargo
|
||||
{
|
||||
case CargoConsoleAddOrderMessage msg:
|
||||
{
|
||||
if (msg.Amount <= 0)
|
||||
if (msg.Amount <= 0 || _bankAccount == null)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
_cargoOrderDataManager.AddOrder(Orders.Database.Id, msg.Requester, msg.Reason, msg.ProductId, msg.Amount, _bankAccount.Id);
|
||||
break;
|
||||
}
|
||||
@@ -111,8 +118,12 @@ namespace Content.Server.GameObjects.Components.Cargo
|
||||
case CargoConsoleApproveOrderMessage msg:
|
||||
{
|
||||
if (_requestOnly ||
|
||||
!Orders.Database.TryGetOrder(msg.OrderNumber, out var order))
|
||||
!Orders.Database.TryGetOrder(msg.OrderNumber, out var order) ||
|
||||
_bankAccount == null)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
_prototypeManager.TryIndex(order.ProductId, out CargoProductPrototype product);
|
||||
if (product == null)
|
||||
break;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Content.Server.GameObjects.Components.Strap;
|
||||
#nullable enable
|
||||
using Content.Server.GameObjects.Components.Strap;
|
||||
using Content.Server.GameObjects.EntitySystems;
|
||||
using Content.Server.Interfaces;
|
||||
using Content.Server.Interfaces.GameObjects.Components.Interaction;
|
||||
@@ -8,7 +9,6 @@ using Content.Shared.GameObjects;
|
||||
using Content.Shared.GameObjects.Components.Mobs;
|
||||
using Content.Shared.GameObjects.Components.Strap;
|
||||
using Content.Shared.GameObjects.EntitySystems;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Server.GameObjects.EntitySystems;
|
||||
using Robust.Shared.GameObjects;
|
||||
@@ -25,15 +25,15 @@ namespace Content.Server.GameObjects.Components.Mobs
|
||||
public class BuckleComponent : SharedBuckleComponent, IInteractHand, IDragDrop
|
||||
{
|
||||
#pragma warning disable 649
|
||||
[Dependency] private readonly IEntitySystemManager _entitySystem;
|
||||
[Dependency] private readonly IServerNotifyManager _notifyManager;
|
||||
[Dependency] private readonly IEntitySystemManager _entitySystem = default!;
|
||||
[Dependency] private readonly IServerNotifyManager _notifyManager = default!;
|
||||
#pragma warning restore 649
|
||||
|
||||
[CanBeNull] private StrapComponent _buckledTo;
|
||||
private StrapComponent? _buckledTo;
|
||||
private int _size;
|
||||
|
||||
[ViewVariables, CanBeNull]
|
||||
public StrapComponent BuckledTo
|
||||
[ViewVariables]
|
||||
public StrapComponent? BuckledTo
|
||||
{
|
||||
get => _buckledTo;
|
||||
private set
|
||||
|
||||
@@ -1,11 +1,7 @@
|
||||
using Content.Shared.GameObjects.Components.Movement;
|
||||
#nullable enable
|
||||
using Content.Shared.GameObjects.Components.Movement;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.GameObjects.Components;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Physics;
|
||||
using Robust.Shared.ViewVariables;
|
||||
|
||||
#nullable enable
|
||||
|
||||
namespace Content.Server.GameObjects.Components.Movement
|
||||
{
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#nullable enable
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
@@ -22,8 +23,6 @@ using Robust.Shared.Localization;
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.ViewVariables;
|
||||
|
||||
#nullable enable
|
||||
|
||||
namespace Content.Server.GameObjects.Components.PDA
|
||||
{
|
||||
[RegisterComponent]
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
#nullable enable
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Content.Server.GameObjects.Components.Interactable;
|
||||
@@ -32,12 +33,12 @@ namespace Content.Server.GameObjects.Components
|
||||
public class WiresComponent : SharedWiresComponent, IInteractUsing, IExamine, IMapInit
|
||||
{
|
||||
#pragma warning disable 649
|
||||
[Dependency] private readonly IRobustRandom _random;
|
||||
[Dependency] private readonly IServerNotifyManager _notifyManager;
|
||||
[Dependency] private readonly IRobustRandom _random = default!;
|
||||
[Dependency] private readonly IServerNotifyManager _notifyManager = default!;
|
||||
#pragma warning restore 649
|
||||
private AudioSystem _audioSystem;
|
||||
private AppearanceComponent _appearance;
|
||||
private BoundUserInterface _userInterface;
|
||||
private AudioSystem _audioSystem = default!;
|
||||
private AppearanceComponent _appearance = default!;
|
||||
private BoundUserInterface _userInterface = default!;
|
||||
|
||||
private bool _isPanelOpen;
|
||||
|
||||
@@ -93,7 +94,7 @@ namespace Content.Server.GameObjects.Components
|
||||
}
|
||||
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public string SerialNumber
|
||||
public string? SerialNumber
|
||||
{
|
||||
get => _serialNumber;
|
||||
set
|
||||
@@ -127,16 +128,16 @@ namespace Content.Server.GameObjects.Components
|
||||
private readonly List<WireLetter> _availableLetters =
|
||||
new List<WireLetter>((WireLetter[]) Enum.GetValues(typeof(WireLetter)));
|
||||
|
||||
private string _boardName;
|
||||
private string _boardName = default!;
|
||||
|
||||
private string _serialNumber;
|
||||
private string? _serialNumber;
|
||||
|
||||
// Used to generate wire appearance randomization client side.
|
||||
// We honestly don't care what it is or such but do care that it doesn't change between UI re-opens.
|
||||
[ViewVariables]
|
||||
private int _wireSeed;
|
||||
[ViewVariables]
|
||||
private string _layoutId;
|
||||
private string? _layoutId;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
@@ -186,7 +187,7 @@ namespace Content.Server.GameObjects.Components
|
||||
base.Startup();
|
||||
|
||||
|
||||
WireLayout layout = null;
|
||||
WireLayout? layout = null;
|
||||
var hackingSystem = EntitySystem.Get<WireHackingSystem>();
|
||||
if (_layoutId != null)
|
||||
{
|
||||
@@ -299,9 +300,9 @@ namespace Content.Server.GameObjects.Components
|
||||
{
|
||||
[NotNull] private readonly WiresComponent _wires;
|
||||
[NotNull] private readonly IWires _owner;
|
||||
[CanBeNull] private readonly WireLayout _layout;
|
||||
private readonly WireLayout? _layout;
|
||||
|
||||
public WiresBuilder(WiresComponent wires, IWires owner, WireLayout layout)
|
||||
public WiresBuilder(WiresComponent wires, IWires owner, WireLayout? layout)
|
||||
{
|
||||
_wires = wires;
|
||||
_owner = owner;
|
||||
@@ -365,12 +366,12 @@ namespace Content.Server.GameObjects.Components
|
||||
{
|
||||
case WiresActionMessage msg:
|
||||
var wire = WiresList.Find(x => x.Id == msg.Id);
|
||||
if (wire == null)
|
||||
var player = serverMsg.Session.AttachedEntity;
|
||||
if (wire == null || player == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var player = serverMsg.Session.AttachedEntity;
|
||||
if (!player.TryGetComponent(out IHandsComponent handsComponent))
|
||||
{
|
||||
_notifyManager.PopupMessage(Owner.Transform.GridPosition, player,
|
||||
@@ -386,7 +387,7 @@ namespace Content.Server.GameObjects.Components
|
||||
}
|
||||
|
||||
var activeHandEntity = handsComponent.GetActiveHand?.Owner;
|
||||
ToolComponent tool = null;
|
||||
ToolComponent? tool = null;
|
||||
activeHandEntity?.TryGetComponent(out tool);
|
||||
|
||||
switch (msg.Action)
|
||||
|
||||
Reference in New Issue
Block a user