removed TryGetSound + made some SoundSpecifier datafields required

This commit is contained in:
Galactic Chimp
2021-07-31 19:52:33 +02:00
parent 8ff703c338
commit 57016d14b4
114 changed files with 519 additions and 785 deletions

View File

@@ -69,11 +69,11 @@ namespace Content.Shared.Light.Component
protected string IconStateLit { get; set; } = string.Empty;
[ViewVariables]
[DataField("litSound")]
[DataField("litSound", required: true)]
protected SoundSpecifier LitSound { get; set; } = default!;
[ViewVariables]
[DataField("loopedSound")]
[DataField("loopedSound", required: true)]
public string LoopedSound { get; set; } = string.Empty;
[ViewVariables]

View File

@@ -32,7 +32,7 @@ namespace Content.Shared.Maps
[DataField("can_crowbar")] public bool CanCrowbar { get; private set; }
[DataField("footstep_sounds")] public SoundSpecifier FootstepSounds { get; } = default!;
[DataField("footstep_sounds", required: true)] public SoundSpecifier FootstepSounds { get; } = default!;
[DataField("friction")] public float Friction { get; set; }

View File

@@ -3,7 +3,6 @@ using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.Serialization.TypeSerializers.Implementations;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
using Robust.Shared.Utility;
using System.Diagnostics.CodeAnalysis;
namespace Content.Shared.Sound
{
@@ -11,8 +10,6 @@ namespace Content.Shared.Sound
public abstract class SoundSpecifier
{
public abstract string GetSound();
public abstract bool TryGetSound([NotNullWhen(true)] out string? sound);
}
public sealed class SoundPathSpecifier : SoundSpecifier
@@ -40,12 +37,6 @@ namespace Content.Shared.Sound
{
return Path == null ? string.Empty : Path.ToString();
}
public override bool TryGetSound([NotNullWhen(true)] out string? sound)
{
sound = GetSound();
return !string.IsNullOrWhiteSpace(sound);
}
}
public sealed class SoundCollectionSpecifier : SoundSpecifier
@@ -68,11 +59,5 @@ namespace Content.Shared.Sound
{
return Collection == null ? string.Empty : AudioHelpers.GetRandomFileFromSoundCollection(Collection);
}
public override bool TryGetSound([NotNullWhen(true)] out string? sound)
{
sound = GetSound();
return !string.IsNullOrWhiteSpace(sound);
}
}
}

View File

@@ -61,9 +61,9 @@ namespace Content.Shared.Standing
}
// Currently shit is only downed by server but when it's predicted we can probably only play this on server / client
if (playSound && component.DownSoundCollection.TryGetSound(out var sound))
if (playSound)
{
SoundSystem.Play(Filter.Pvs(entity), sound, entity, AudioHelpers.WithVariation(0.25f));
SoundSystem.Play(Filter.Pvs(entity), component.DownSoundCollection.GetSound(), entity, AudioHelpers.WithVariation(0.25f));
}
}