Enable nullability in Content.Client (#3257)

* Enable nullability in Content.Client

* Remove #nullable enable

* Merge fixes

* Remove Debug.Assert

* Merge fixes

* Fix build

* Fix build
This commit is contained in:
DrSmugleaf
2021-03-10 14:48:29 +01:00
committed by GitHub
parent 4f9bd4e802
commit 902aa128c2
270 changed files with 1774 additions and 1550 deletions

View File

@@ -25,7 +25,7 @@ namespace Content.Client.GameObjects.Components.Weapons
}
var playerManager = IoCManager.Resolve<IPlayerManager>();
if (playerManager?.LocalPlayer != null && playerManager.LocalPlayer.ControlledEntity != Owner)
if (playerManager.LocalPlayer != null && playerManager.LocalPlayer.ControlledEntity != Owner)
{
return;
}

View File

@@ -11,10 +11,10 @@ namespace Content.Client.GameObjects.Components.Weapons.Melee
{
public override string Name => "MeleeWeaponArcAnimation";
private MeleeWeaponAnimationPrototype _meleeWeaponAnimation;
private MeleeWeaponAnimationPrototype? _meleeWeaponAnimation;
private float _timer;
private SpriteComponent _sprite;
private SpriteComponent? _sprite;
private Angle _baseAngle;
public override void Initialize()
@@ -27,7 +27,7 @@ namespace Content.Client.GameObjects.Components.Weapons.Melee
public void SetData(MeleeWeaponAnimationPrototype prototype, Angle baseAngle, IEntity attacker, bool followAttacker = true)
{
_meleeWeaponAnimation = prototype;
_sprite.AddLayer(new RSI.StateId(prototype.State));
_sprite?.AddLayer(new RSI.StateId(prototype.State));
_baseAngle = baseAngle;
if(followAttacker)
Owner.Transform.AttachParent(attacker);
@@ -44,7 +44,11 @@ namespace Content.Client.GameObjects.Components.Weapons.Melee
var (r, g, b, a) =
Vector4.Clamp(_meleeWeaponAnimation.Color + _meleeWeaponAnimation.ColorDelta * _timer, Vector4.Zero, Vector4.One);
_sprite.Color = new Color(r, g, b, a);
if (_sprite != null)
{
_sprite.Color = new Color(r, g, b, a);
}
switch (_meleeWeaponAnimation.ArcType)
{
@@ -56,7 +60,11 @@ namespace Content.Client.GameObjects.Components.Weapons.Melee
case WeaponArcType.Poke:
Owner.Transform.WorldRotation = _baseAngle;
_sprite.Offset -= (0, _meleeWeaponAnimation.Speed * frameTime);
if (_sprite != null)
{
_sprite.Offset -= (0, _meleeWeaponAnimation.Speed * frameTime);
}
break;
}

View File

@@ -17,7 +17,7 @@ namespace Content.Client.GameObjects.Components.Weapons.Ranged.Barrels
public override string Name => "BatteryBarrel";
public override uint? NetID => ContentNetIDs.BATTERY_BARREL;
private StatusControl _statusControl;
private StatusControl? _statusControl;
/// <summary>
/// Count of bullets in the magazine.
@@ -28,7 +28,7 @@ namespace Content.Client.GameObjects.Components.Weapons.Ranged.Barrels
[ViewVariables]
public (int count, int max)? MagazineCount { get; private set; }
public override void HandleComponentState(ComponentState curState, ComponentState nextState)
public override void HandleComponentState(ComponentState? curState, ComponentState? nextState)
{
base.HandleComponentState(curState, nextState);

View File

@@ -18,7 +18,7 @@ namespace Content.Client.GameObjects.Components.Weapons.Ranged.Barrels
public override string Name => "BoltActionBarrel";
public override uint? NetID => ContentNetIDs.BOLTACTION_BARREL;
private StatusControl _statusControl;
private StatusControl? _statusControl;
/// <summary>
/// chambered is true when a bullet is chambered
@@ -36,7 +36,7 @@ namespace Content.Client.GameObjects.Components.Weapons.Ranged.Barrels
[ViewVariables]
public (int count, int max)? MagazineCount { get; private set; }
public override void HandleComponentState(ComponentState curState, ComponentState nextState)
public override void HandleComponentState(ComponentState? curState, ComponentState? nextState)
{
base.HandleComponentState(curState, nextState);

View File

@@ -36,11 +36,11 @@ namespace Content.Client.GameObjects.Components.Weapons.Ranged.Barrels
KeyFrames =
{
new AnimationTrackProperty.KeyFrame(Color.Red, 0.1f),
new AnimationTrackProperty.KeyFrame(null, 0.3f),
new AnimationTrackProperty.KeyFrame(null!, 0.3f),
new AnimationTrackProperty.KeyFrame(Color.Red, 0.2f),
new AnimationTrackProperty.KeyFrame(null, 0.3f),
new AnimationTrackProperty.KeyFrame(null!, 0.3f),
new AnimationTrackProperty.KeyFrame(Color.Red, 0.2f),
new AnimationTrackProperty.KeyFrame(null, 0.3f),
new AnimationTrackProperty.KeyFrame(null!, 0.3f),
}
}
}
@@ -59,11 +59,11 @@ namespace Content.Client.GameObjects.Components.Weapons.Ranged.Barrels
KeyFrames =
{
new AnimationTrackProperty.KeyFrame(Color.Red, 0.0f),
new AnimationTrackProperty.KeyFrame(null, 0.15f),
new AnimationTrackProperty.KeyFrame(null!, 0.15f),
new AnimationTrackProperty.KeyFrame(Color.Red, 0.15f),
new AnimationTrackProperty.KeyFrame(null, 0.15f),
new AnimationTrackProperty.KeyFrame(null!, 0.15f),
new AnimationTrackProperty.KeyFrame(Color.Red, 0.15f),
new AnimationTrackProperty.KeyFrame(null, 0.15f),
new AnimationTrackProperty.KeyFrame(null!, 0.15f),
}
}
}
@@ -72,7 +72,7 @@ namespace Content.Client.GameObjects.Components.Weapons.Ranged.Barrels
public override string Name => "MagazineBarrel";
public override uint? NetID => ContentNetIDs.MAGAZINE_BARREL;
private StatusControl _statusControl;
private StatusControl? _statusControl;
/// <summary>
/// True if a bullet is chambered.
@@ -91,7 +91,7 @@ namespace Content.Client.GameObjects.Components.Weapons.Ranged.Barrels
[ViewVariables(VVAccess.ReadWrite)] [DataField("lmg_alarm_animation")] private bool _isLmgAlarmAnimation = default;
public override void HandleComponentState(ComponentState curState, ComponentState nextState)
public override void HandleComponentState(ComponentState? curState, ComponentState? nextState)
{
base.HandleComponentState(curState, nextState);
@@ -103,7 +103,7 @@ namespace Content.Client.GameObjects.Components.Weapons.Ranged.Barrels
_statusControl?.Update();
}
public override void HandleNetworkMessage(ComponentMessage message, INetChannel channel, ICommonSession session = null)
public override void HandleNetworkMessage(ComponentMessage message, INetChannel channel, ICommonSession? session = null)
{
base.HandleNetworkMessage(message, channel, session);

View File

@@ -18,7 +18,7 @@ namespace Content.Client.GameObjects.Components.Weapons.Ranged.Barrels
public override string Name => "PumpBarrel";
public override uint? NetID => ContentNetIDs.PUMP_BARREL;
private StatusControl _statusControl;
private StatusControl? _statusControl;
/// <summary>
/// chambered is true when a bullet is chambered
@@ -36,7 +36,7 @@ namespace Content.Client.GameObjects.Components.Weapons.Ranged.Barrels
[ViewVariables]
public (int count, int max)? MagazineCount { get; private set; }
public override void HandleComponentState(ComponentState curState, ComponentState nextState)
public override void HandleComponentState(ComponentState? curState, ComponentState? nextState)
{
base.HandleComponentState(curState, nextState);

View File

@@ -16,7 +16,7 @@ namespace Content.Client.GameObjects.Components.Weapons.Ranged.Barrels
public override string Name => "RevolverBarrel";
public override uint? NetID => ContentNetIDs.REVOLVER_BARREL;
private StatusControl _statusControl;
private StatusControl? _statusControl;
/// <summary>
/// A array that lists the bullet states
@@ -25,12 +25,12 @@ namespace Content.Client.GameObjects.Components.Weapons.Ranged.Barrels
/// null means no bullet
/// </summary>
[ViewVariables]
public bool?[] Bullets { get; private set; }
public bool?[] Bullets { get; private set; } = new bool?[0];
[ViewVariables]
public int CurrentSlot { get; private set; }
public override void HandleComponentState(ComponentState curState, ComponentState nextState)
public override void HandleComponentState(ComponentState? curState, ComponentState? nextState)
{
base.HandleComponentState(curState, nextState);

View File

@@ -4,8 +4,6 @@ using JetBrains.Annotations;
using Robust.Client.GameObjects;
using Robust.Shared.GameObjects;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.Utility;
using YamlDotNet.RepresentationModel;
namespace Content.Client.GameObjects.Components.Weapons.Ranged.Barrels.Visualizers
{
@@ -14,7 +12,7 @@ namespace Content.Client.GameObjects.Components.Weapons.Ranged.Barrels.Visualize
{
private bool _magLoaded;
[DataField("magState")]
private string _magState;
private string? _magState;
[DataField("steps")]
private int _magSteps;
[DataField("zeroVisible")]

View File

@@ -20,7 +20,7 @@ namespace Content.Client.GameObjects.Components.Weapons.Ranged
{
public FireRateSelector FireRateSelector { get; private set; } = FireRateSelector.Safety;
public override void HandleComponentState(ComponentState curState, ComponentState nextState)
public override void HandleComponentState(ComponentState? curState, ComponentState? nextState)
{
base.HandleComponentState(curState, nextState);
if (curState is not RangedWeaponComponentState rangedState)