replacing sound (collection) names with SoundSpecifier - part 1
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
using System.Threading.Tasks;
|
||||
using Content.Shared.Audio;
|
||||
using Content.Shared.Construction;
|
||||
using Content.Shared.Sound;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.GameObjects;
|
||||
@@ -14,21 +15,12 @@ namespace Content.Server.Construction.Completions
|
||||
[DataDefinition]
|
||||
public class PlaySound : IGraphAction
|
||||
{
|
||||
[DataField("soundCollection")] public string SoundCollection { get; private set; } = string.Empty;
|
||||
[DataField("sound")] public string Sound { get; private set; } = string.Empty;
|
||||
[DataField("sound")] public SoundSpecifier Sound { get; private set; } = default!;
|
||||
|
||||
public async Task PerformAction(IEntity entity, IEntity? user)
|
||||
{
|
||||
var sound = GetSound();
|
||||
|
||||
if (string.IsNullOrEmpty(sound)) return;
|
||||
|
||||
SoundSystem.Play(Filter.Pvs(entity), sound, entity, AudioHelpers.WithVariation(0.125f));
|
||||
}
|
||||
|
||||
private string GetSound()
|
||||
{
|
||||
return !string.IsNullOrEmpty(SoundCollection) ? AudioHelpers.GetRandomFileFromSoundCollection(SoundCollection) : Sound;
|
||||
if(Sound.TryGetSound(out var sound))
|
||||
SoundSystem.Play(Filter.Pvs(entity), sound, entity, AudioHelpers.WithVariation(0.125f));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user