Replace CanBeNull annotations with nullable reference types (#1270)

Co-authored-by: Pieter-Jan Briers <pieterjan.briers+git@gmail.com>
This commit is contained in:
DrSmugleaf
2020-07-08 01:41:20 +02:00
committed by GitHub
parent 5aefae184c
commit e7d756811e
25 changed files with 95 additions and 112 deletions

View File

@@ -1,3 +1,4 @@
#nullable enable
using System;
using Robust.Client.Graphics.ClientEye;
using Robust.Client.Interfaces.GameObjects.Components;
@@ -8,8 +9,6 @@ using Robust.Shared.Maths;
using Robust.Shared.Serialization;
using Robust.Shared.ViewVariables;
#nullable enable
namespace Content.Client.GameObjects.Components
{
[RegisterComponent]

View File

@@ -1,24 +1,17 @@
#nullable enable
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using Content.Shared.GameObjects.Components.Instruments;
using Content.Shared.Physics;
using JetBrains.Annotations;
using NFluidsynth;
using Robust.Shared.GameObjects;
using Robust.Client.Audio.Midi;
using Robust.Client.Player;
using Robust.Shared.Interfaces.Log;
using Robust.Shared.Interfaces.Network;
using Robust.Shared.Interfaces.Timing;
using Robust.Shared.IoC;
using Robust.Shared.Log;
using Robust.Shared.Players;
using Robust.Shared.Serialization;
using Robust.Shared.Timing;
using Robust.Shared.ViewVariables;
using Logger = Robust.Shared.Log.Logger;
using MidiEvent = Robust.Shared.Audio.Midi.MidiEvent;
using Timer = Robust.Shared.Timers.Timer;
@@ -32,24 +25,23 @@ namespace Content.Client.GameObjects.Components.Instruments
/// <summary>
/// Called when a midi song stops playing.
/// </summary>
public event Action OnMidiPlaybackEnded;
public event Action? OnMidiPlaybackEnded;
#pragma warning disable 649
[Dependency] private readonly IMidiManager _midiManager;
[Dependency] private readonly IMidiManager _midiManager = default!;
[Dependency] private readonly IGameTiming _gameTiming;
[Dependency] private readonly IGameTiming _gameTiming = default!;
[Dependency] private readonly IClientNetManager _netManager;
[Dependency] private readonly IClientNetManager _netManager = default!;
#pragma warning restore 649
[CanBeNull]
private IMidiRenderer _renderer;
private IMidiRenderer? _renderer;
private byte _instrumentProgram = 1;
private byte _instrumentBank = 0;
private byte _instrumentBank;
private uint _sequenceDelay = 0;
private uint _sequenceDelay;
private uint _sequenceStartTick;
@@ -209,7 +201,7 @@ namespace Content.Client.GameObjects.Components.Instruments
serializer.DataField(ref _instrumentBank, "bank", (byte) 0);
}
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);
@@ -240,7 +232,7 @@ namespace Content.Client.GameObjects.Components.Instruments
.Min(x => x.Tick) - 1;
}
var sqrtLag = MathF.Sqrt(_netManager.ServerChannel.Ping / 1000f);
var sqrtLag = MathF.Sqrt(_netManager.ServerChannel!.Ping / 1000f);
var delay = (uint) (_renderer!.SequencerTimeScale * (.2 + sqrtLag));
var delta = delay - _sequenceStartTick;
@@ -265,12 +257,12 @@ namespace Content.Client.GameObjects.Components.Instruments
}
break;
case InstrumentStartMidiMessage startMidiMessage:
case InstrumentStartMidiMessage _:
{
SetupRenderer(true);
break;
}
case InstrumentStopMidiMessage stopMidiMessage:
case InstrumentStopMidiMessage _:
{
EndRenderer(true);
break;
@@ -278,7 +270,7 @@ namespace Content.Client.GameObjects.Components.Instruments
}
}
public override void HandleComponentState(ComponentState curState, ComponentState nextState)
public override void HandleComponentState(ComponentState? curState, ComponentState? nextState)
{
base.HandleComponentState(curState, nextState);
if (!(curState is InstrumentState state)) return;
@@ -370,7 +362,7 @@ namespace Content.Client.GameObjects.Components.Instruments
private TimeSpan _lastMeasured = TimeSpan.MinValue;
private int _sentWithinASec = 0;
private int _sentWithinASec;
private static readonly TimeSpan OneSecAgo = TimeSpan.FromSeconds(-1);

View File

@@ -1,5 +1,5 @@
using Content.Shared.GameObjects.Components.Mobs;
using JetBrains.Annotations;
#nullable enable
using Content.Shared.GameObjects.Components.Mobs;
using Robust.Client.Graphics;
using Robust.Client.UserInterface.Controls;
@@ -9,7 +9,7 @@ namespace Content.Client.GameObjects.Components.Mobs
{
public readonly StatusEffect Effect;
public StatusControl(StatusEffect effect, [CanBeNull] Texture texture)
public StatusControl(StatusEffect effect, Texture? texture)
{
Effect = effect;

View File

@@ -1,9 +1,8 @@
#nullable enable
using Content.Shared.GameObjects.Components.Mobs;
using Content.Shared.GameObjects.Components.Movement;
using Robust.Shared.GameObjects;
#nullable enable
namespace Content.Client.GameObjects.Components.Mobs
{
[RegisterComponent]

View File

@@ -1,14 +1,13 @@
#nullable enable
using Content.Shared.GameObjects.Components.Movement;
using Robust.Shared.GameObjects;
using Robust.Shared.Map;
#nullable enable
namespace Content.Client.GameObjects.Components.Movement
{
[RegisterComponent]
[ComponentReference(typeof(IMoverComponent))]
public class PlayerInputMoverComponent : SharedPlayerInputMoverComponent, IMoverComponent
public class PlayerInputMoverComponent : SharedPlayerInputMoverComponent
{
public override GridCoordinates LastPosition { get; set; }
public override float StepSoundDistance { get; set; }

View File

@@ -1,9 +1,8 @@
#nullable enable
using Content.Shared.GameObjects.Components.Movement;
using Content.Shared.GameObjects.Components.Nutrition;
using Robust.Shared.GameObjects;
#nullable enable
namespace Content.Client.GameObjects.Components.Nutrition
{
[RegisterComponent]

View File

@@ -1,9 +1,8 @@
#nullable enable
using Content.Shared.GameObjects.Components.Movement;
using Content.Shared.GameObjects.Components.Nutrition;
using Robust.Shared.GameObjects;
#nullable enable
namespace Content.Client.GameObjects.Components.Nutrition
{
[RegisterComponent]

View File

@@ -1,8 +1,7 @@
#nullable enable
using Content.Shared.GameObjects.Components.Projectiles;
using Robust.Shared.GameObjects;
#nullable enable
namespace Content.Client.GameObjects.Components.Projectiles
{
[RegisterComponent]

View File

@@ -1,4 +1,5 @@
using Content.Shared.GameObjects.Components.Movement;
#nullable enable
using Content.Shared.GameObjects.Components.Movement;
using Content.Shared.GameObjects.EntitySystems;
using Content.Shared.Physics;
using JetBrains.Annotations;
@@ -7,8 +8,6 @@ using Robust.Client.Player;
using Robust.Shared.GameObjects.Components;
using Robust.Shared.IoC;
#nullable enable
namespace Content.Client.GameObjects.EntitySystems
{
[UsedImplicitly]