Enable nullability in Content.Server (#3685)
This commit is contained in:
@@ -29,7 +29,7 @@ namespace Content.Server.GameObjects.Components.Interactable
|
||||
|
||||
[ViewVariables]
|
||||
private float _stateExpiryTime = default;
|
||||
private AppearanceComponent _appearance = default;
|
||||
private AppearanceComponent? _appearance = default;
|
||||
|
||||
bool IUse.UseEntity(UseEntityEventArgs eventArgs)
|
||||
{
|
||||
@@ -64,7 +64,7 @@ namespace Content.Server.GameObjects.Components.Interactable
|
||||
|
||||
CurrentState = ExpendableLightState.Lit;
|
||||
_stateExpiryTime = GlowDuration;
|
||||
|
||||
|
||||
UpdateSpriteAndSounds(Activated);
|
||||
UpdateVisualizer();
|
||||
|
||||
@@ -79,25 +79,22 @@ namespace Content.Server.GameObjects.Components.Interactable
|
||||
switch (CurrentState)
|
||||
{
|
||||
case ExpendableLightState.Lit:
|
||||
_appearance.SetData(ExpendableLightVisuals.State, TurnOnBehaviourID);
|
||||
_appearance?.SetData(ExpendableLightVisuals.State, TurnOnBehaviourID);
|
||||
break;
|
||||
|
||||
case ExpendableLightState.Fading:
|
||||
_appearance.SetData(ExpendableLightVisuals.State, FadeOutBehaviourID);
|
||||
_appearance?.SetData(ExpendableLightVisuals.State, FadeOutBehaviourID);
|
||||
break;
|
||||
|
||||
case ExpendableLightState.Dead:
|
||||
_appearance.SetData(ExpendableLightVisuals.State, string.Empty);
|
||||
break;
|
||||
|
||||
default:
|
||||
_appearance?.SetData(ExpendableLightVisuals.State, string.Empty);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateSpriteAndSounds(bool on)
|
||||
{
|
||||
if (Owner.TryGetComponent(out SpriteComponent sprite))
|
||||
if (Owner.TryGetComponent(out SpriteComponent? sprite))
|
||||
{
|
||||
switch (CurrentState)
|
||||
{
|
||||
@@ -145,7 +142,7 @@ namespace Content.Server.GameObjects.Components.Interactable
|
||||
}
|
||||
}
|
||||
|
||||
if (Owner.TryGetComponent(out ClothingComponent clothing))
|
||||
if (Owner.TryGetComponent(out ClothingComponent? clothing))
|
||||
{
|
||||
clothing.ClothingEquippedPrefix = on ? "Activated" : string.Empty;
|
||||
}
|
||||
|
||||
@@ -44,9 +44,9 @@ namespace Content.Server.GameObjects.Components.Interactable
|
||||
[DataField("tools")] private List<ToolEntry> _tools = new();
|
||||
private int _currentTool = 0;
|
||||
|
||||
private AudioSystem _audioSystem;
|
||||
private ToolComponent _tool;
|
||||
private SpriteComponent _sprite;
|
||||
private AudioSystem _audioSystem = default!;
|
||||
private ToolComponent? _tool;
|
||||
private SpriteComponent? _sprite;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
@@ -99,7 +99,7 @@ namespace Content.Server.GameObjects.Components.Interactable
|
||||
|
||||
public override ComponentState GetComponentState(ICommonSession player)
|
||||
{
|
||||
return new MultiToolComponentState(_tool.Qualities);
|
||||
return new MultiToolComponentState(_tool?.Qualities ?? ToolQuality.None);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,10 +42,10 @@ namespace Content.Server.GameObjects.Components.Interactable
|
||||
public float SpeedModifier { get; set; } = 1;
|
||||
|
||||
[DataField("useSound")]
|
||||
public string UseSound { get; set; }
|
||||
public string? UseSound { get; set; }
|
||||
|
||||
[DataField("useSoundCollection")]
|
||||
public string UseSoundCollection { get; set; }
|
||||
public string? UseSoundCollection { get; set; }
|
||||
|
||||
public void AddQuality(ToolQuality quality)
|
||||
{
|
||||
@@ -64,7 +64,7 @@ namespace Content.Server.GameObjects.Components.Interactable
|
||||
return _qualities.HasFlag(quality);
|
||||
}
|
||||
|
||||
public virtual async Task<bool> UseTool(IEntity user, IEntity target, float doAfterDelay, ToolQuality toolQualityNeeded, Func<bool> doAfterCheck = null)
|
||||
public virtual async Task<bool> UseTool(IEntity user, IEntity? target, float doAfterDelay, ToolQuality toolQualityNeeded, Func<bool>? doAfterCheck = null)
|
||||
{
|
||||
if (!HasQuality(toolQualityNeeded) || !ActionBlockerSystem.CanInteract(user))
|
||||
return false;
|
||||
@@ -94,8 +94,13 @@ namespace Content.Server.GameObjects.Components.Interactable
|
||||
return true;
|
||||
}
|
||||
|
||||
protected void PlaySoundCollection(string name, float volume=-5f)
|
||||
protected void PlaySoundCollection(string? name, float volume = -5f)
|
||||
{
|
||||
if (string.IsNullOrEmpty(name))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var file = AudioHelpers.GetRandomFileFromSoundCollection(name);
|
||||
EntitySystem.Get<AudioSystem>()
|
||||
.PlayFromEntity(file, Owner, AudioHelpers.WithVariation(0.15f).WithVolume(volume));
|
||||
|
||||
@@ -100,7 +100,7 @@ namespace Content.Server.GameObjects.Components.Interactable
|
||||
return new WelderComponentState(FuelCapacity, Fuel, WelderLit);
|
||||
}
|
||||
|
||||
public override async Task<bool> UseTool(IEntity user, IEntity target, float doAfterDelay, ToolQuality toolQualityNeeded, Func<bool>? doAfterCheck = null)
|
||||
public override async Task<bool> UseTool(IEntity user, IEntity? target, float doAfterDelay, ToolQuality toolQualityNeeded, Func<bool>? doAfterCheck = null)
|
||||
{
|
||||
bool ExtraCheck()
|
||||
{
|
||||
@@ -108,7 +108,7 @@ namespace Content.Server.GameObjects.Components.Interactable
|
||||
|
||||
if (!CanWeld(DefaultFuelCost))
|
||||
{
|
||||
target.PopupMessage(user, "Can't weld!");
|
||||
target?.PopupMessage(user, "Can't weld!");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user