Enable nullability in Content.Server (#3685)
This commit is contained in:
@@ -14,10 +14,8 @@ using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Localization;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.Timing;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
using Robust.Shared.Timing;
|
||||
using Robust.Shared.ViewVariables;
|
||||
|
||||
namespace Content.Server.GameObjects.Components.Fluids
|
||||
@@ -33,7 +31,7 @@ namespace Content.Server.GameObjects.Components.Fluids
|
||||
[DataField("transferAmount")]
|
||||
private ReagentUnit _transferAmount = ReagentUnit.New(10);
|
||||
[DataField("spraySound")]
|
||||
private string _spraySound;
|
||||
private string? _spraySound;
|
||||
[DataField("sprayVelocity")]
|
||||
private float _sprayVelocity = 1.5f;
|
||||
[DataField("sprayAliveTime")]
|
||||
@@ -73,7 +71,7 @@ namespace Content.Server.GameObjects.Components.Fluids
|
||||
set => _sprayVelocity = value;
|
||||
}
|
||||
|
||||
public string SpraySound => _spraySound;
|
||||
public string? SpraySound => _spraySound;
|
||||
|
||||
public ReagentUnit CurrentVolume => Owner.GetComponentOrNull<SolutionContainerComponent>()?.CurrentVolume ?? ReagentUnit.Zero;
|
||||
|
||||
@@ -115,7 +113,7 @@ namespace Content.Server.GameObjects.Components.Fluids
|
||||
if (eventArgs.ClickLocation.GetGridId(_serverEntityManager) != playerPos.GetGridId(_serverEntityManager))
|
||||
return true;
|
||||
|
||||
if (!Owner.TryGetComponent(out SolutionContainerComponent contents))
|
||||
if (!Owner.TryGetComponent(out SolutionContainerComponent? contents))
|
||||
return true;
|
||||
|
||||
var direction = (eventArgs.ClickLocation.Position - playerPos.Position).Normalized;
|
||||
@@ -147,7 +145,7 @@ namespace Content.Server.GameObjects.Components.Fluids
|
||||
var vapor = _serverEntityManager.SpawnEntity(_vaporPrototype, playerPos.Offset(distance < 1 ? quarter : threeQuarters));
|
||||
vapor.Transform.LocalRotation = rotation;
|
||||
|
||||
if (vapor.TryGetComponent(out AppearanceComponent appearance)) // Vapor sprite should face down.
|
||||
if (vapor.TryGetComponent(out AppearanceComponent? appearance)) // Vapor sprite should face down.
|
||||
{
|
||||
appearance.SetData(VaporVisuals.Rotation, -Angle.South + rotation);
|
||||
appearance.SetData(VaporVisuals.Color, contents.Color.WithAlpha(1f));
|
||||
@@ -162,12 +160,15 @@ namespace Content.Server.GameObjects.Components.Fluids
|
||||
}
|
||||
|
||||
//Play sound
|
||||
EntitySystem.Get<AudioSystem>().PlayFromEntity(_spraySound, Owner, AudioHelpers.WithVariation(0.125f));
|
||||
if (!string.IsNullOrEmpty(_spraySound))
|
||||
{
|
||||
EntitySystem.Get<AudioSystem>().PlayFromEntity(_spraySound, Owner, AudioHelpers.WithVariation(0.125f));
|
||||
}
|
||||
|
||||
_lastUseTime = curTime;
|
||||
_cooldownEnd = _lastUseTime + TimeSpan.FromSeconds(_cooldownTime);
|
||||
|
||||
if (Owner.TryGetComponent(out ItemCooldownComponent cooldown))
|
||||
if (Owner.TryGetComponent(out ItemCooldownComponent? cooldown))
|
||||
{
|
||||
cooldown.CooldownStart = _lastUseTime;
|
||||
cooldown.CooldownEnd = _cooldownEnd;
|
||||
@@ -199,13 +200,13 @@ namespace Content.Server.GameObjects.Components.Fluids
|
||||
|
||||
_safety = state;
|
||||
|
||||
if(Owner.TryGetComponent(out AppearanceComponent appearance))
|
||||
if(Owner.TryGetComponent(out AppearanceComponent? appearance))
|
||||
appearance.SetData(SprayVisuals.Safety, _safety);
|
||||
}
|
||||
|
||||
void IDropped.Dropped(DroppedEventArgs eventArgs)
|
||||
{
|
||||
if(_hasSafety && Owner.TryGetComponent(out AppearanceComponent appearance))
|
||||
if(_hasSafety && Owner.TryGetComponent(out AppearanceComponent? appearance))
|
||||
appearance.SetData(SprayVisuals.Safety, _safety);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user