Enable nullability in Content.Server (#3685)

This commit is contained in:
DrSmugleaf
2021-03-16 15:50:20 +01:00
committed by GitHub
parent 90fec0ed24
commit a5ade526b7
306 changed files with 1616 additions and 1441 deletions

View File

@@ -12,8 +12,8 @@ using Robust.Server.GameObjects;
using Robust.Shared.Containers;
using Robust.Shared.GameObjects;
using Robust.Shared.Localization;
using Robust.Shared.Players;
using Robust.Shared.Physics;
using Robust.Shared.Players;
using Robust.Shared.Serialization.Manager.Attributes;
namespace Content.Server.GameObjects.Components.Items.Storage
@@ -28,14 +28,11 @@ namespace Content.Server.GameObjects.Components.Items.Storage
public override uint? NetID => ContentNetIDs.ITEM;
[DataField("HeldPrefix")]
private string _equippedPrefix;
private string? _equippedPrefix;
public string EquippedPrefix
public string? EquippedPrefix
{
get
{
return _equippedPrefix;
}
get => _equippedPrefix;
set
{
_equippedPrefix = value;
@@ -81,7 +78,7 @@ namespace Content.Server.GameObjects.Components.Items.Storage
return false;
}
if (Owner.TryGetComponent(out IPhysBody physics) &&
if (Owner.TryGetComponent(out IPhysBody? physics) &&
physics.BodyType == BodyType.Static)
{
return false;
@@ -92,9 +89,10 @@ namespace Content.Server.GameObjects.Components.Items.Storage
bool IInteractHand.InteractHand(InteractHandEventArgs eventArgs)
{
if (!CanPickup(eventArgs.User)) return false;
if (!CanPickup(eventArgs.User) ||
!eventArgs.User.TryGetComponent(out IHandsComponent? hands) ||
hands.ActiveHand == null) return false;
var hands = eventArgs.User.GetComponent<IHandsComponent>();
hands.PutInHand(this, hands.ActiveHand, false);
return true;
}
@@ -117,7 +115,7 @@ namespace Content.Server.GameObjects.Components.Items.Storage
protected override void Activate(IEntity user, ItemComponent component)
{
if (user.TryGetComponent(out HandsComponent hands) && !hands.IsHolding(component.Owner))
if (user.TryGetComponent(out HandsComponent? hands) && !hands.IsHolding(component.Owner))
{
hands.PutInHand(component);
}

View File

@@ -8,9 +8,6 @@ using Robust.Server.GameObjects;
using Robust.Shared.Audio;
using Robust.Shared.GameObjects;
using Robust.Shared.Localization;
using Robust.Shared.Log;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.ViewVariables;
@@ -34,7 +31,7 @@ namespace Content.Server.GameObjects.Components.Items.Storage
{
_locked = value;
if (Owner.TryGetComponent(out AppearanceComponent appearance))
if (Owner.TryGetComponent(out AppearanceComponent? appearance))
{
appearance.SetData(StorageVisuals.Locked, _locked);
}
@@ -45,7 +42,7 @@ namespace Content.Server.GameObjects.Components.Items.Storage
{
base.Startup();
if (Owner.TryGetComponent(out AppearanceComponent appearance))
if (Owner.TryGetComponent(out AppearanceComponent? appearance))
{
appearance.SetData(StorageVisuals.CanLock, true);
}
@@ -114,7 +111,7 @@ namespace Content.Server.GameObjects.Components.Items.Storage
private bool CheckAccess(IEntity user)
{
if (Owner.TryGetComponent(out AccessReader reader))
if (Owner.TryGetComponent(out AccessReader? reader))
{
if (!reader.IsAllowed(user))
{