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

@@ -8,11 +8,9 @@ using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Physics;
using Robust.Shared.Physics.Collision;
using Robust.Shared.Prototypes;
using Robust.Shared.Random;
using Robust.Shared.Serialization;
using Robust.Shared.Timing;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.Timing;
namespace Content.Server.GameObjects.Components.Damage
{
@@ -46,13 +44,13 @@ namespace Content.Server.GameObjects.Components.Damage
void IStartCollide.CollideWith(IPhysBody ourBody, IPhysBody otherBody, in Manifold manifold)
{
if (!Owner.TryGetComponent(out IDamageableComponent damageable)) return;
if (!Owner.TryGetComponent(out IDamageableComponent? damageable)) return;
var speed = ourBody.LinearVelocity.Length;
if (speed < MinimumSpeed) return;
if(!string.IsNullOrEmpty(SoundHit))
if (!string.IsNullOrEmpty(SoundHit))
EntitySystem.Get<AudioSystem>().PlayFromEntity(SoundHit, otherBody.Entity, AudioHelpers.WithVariation(0.125f).WithVolume(-0.125f));
if ((_gameTiming.CurTime - _lastHit).TotalSeconds < DamageCooldown)
@@ -62,7 +60,7 @@ namespace Content.Server.GameObjects.Components.Damage
var damage = (int) (BaseDamage * (speed / MinimumSpeed) * Factor);
if (Owner.TryGetComponent(out StunnableComponent stun) && _robustRandom.Prob(StunChance))
if (Owner.TryGetComponent(out StunnableComponent? stun) && _robustRandom.Prob(StunChance))
stun.Stun(StunSeconds);
damageable.ChangeDamage(Damage, damage, false, otherBody.Entity);

View File

@@ -22,7 +22,7 @@ namespace Content.Server.GameObjects.Components.Damage
void ILand.Land(LandEventArgs eventArgs)
{
if (!Owner.TryGetComponent(out IDamageableComponent damageable)) return;
if (!Owner.TryGetComponent(out IDamageableComponent? damageable)) return;
damageable.ChangeDamage(_damageType, _amount, _ignoreResistances, eventArgs.User);
}

View File

@@ -29,7 +29,7 @@ namespace Content.Server.GameObjects.Components.Damage
{
if (tool.HasQuality(ToolQuality.Welding) && toolQuality == ToolQuality.Welding)
{
if (eventArgs.Using.TryGetComponent(out WelderComponent welder))
if (eventArgs.Using.TryGetComponent(out WelderComponent? welder))
{
if (welder.WelderLit) return CallDamage(eventArgs, tool);
}

View File

@@ -2,8 +2,6 @@ using Content.Shared.Damage;
using Content.Shared.GameObjects.Components.Damage;
using Content.Shared.Interfaces.GameObjects.Components;
using Robust.Shared.GameObjects;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.Manager.Attributes;
namespace Content.Server.GameObjects.Components.Damage
@@ -22,7 +20,7 @@ namespace Content.Server.GameObjects.Components.Damage
void IThrowCollide.DoHit(ThrowCollideEventArgs eventArgs)
{
if (!eventArgs.Target.TryGetComponent(out IDamageableComponent damageable)) return;
if (!eventArgs.Target.TryGetComponent(out IDamageableComponent? damageable)) return;
damageable.ChangeDamage(_damageType, _amount, _ignoreResistances, eventArgs.User);
}