replacing sound (collection) names with SoundSpecifier - part 1
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using Content.Shared.Audio;
|
||||
using Content.Shared.Sound;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Player;
|
||||
@@ -14,17 +15,15 @@ namespace Content.Server.Destructible.Thresholds.Behaviors
|
||||
/// <summary>
|
||||
/// Sound played upon destruction.
|
||||
/// </summary>
|
||||
[DataField("sound")] public string Sound { get; set; } = string.Empty;
|
||||
[DataField("sound")] public SoundSpecifier Sound { get; set; } = default!;
|
||||
|
||||
public void Execute(IEntity owner, DestructibleSystem system)
|
||||
{
|
||||
if (string.IsNullOrEmpty(Sound))
|
||||
if (Sound.TryGetSound(out var sound))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var pos = owner.Transform.Coordinates;
|
||||
SoundSystem.Play(Filter.Pvs(pos), Sound, pos, AudioHelpers.WithVariation(0.125f));
|
||||
var pos = owner.Transform.Coordinates;
|
||||
SoundSystem.Play(Filter.Pvs(pos), sound, pos, AudioHelpers.WithVariation(0.125f));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
using System;
|
||||
using Content.Shared.Audio;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Player;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
|
||||
namespace Content.Server.Destructible.Thresholds.Behaviors
|
||||
{
|
||||
[Serializable]
|
||||
[DataDefinition]
|
||||
public class PlaySoundCollectionBehavior : IThresholdBehavior
|
||||
{
|
||||
/// <summary>
|
||||
/// Sound collection from which to pick a random sound to play.
|
||||
/// </summary>
|
||||
[DataField("soundCollection")]
|
||||
private string SoundCollection { get; set; } = string.Empty;
|
||||
|
||||
public void Execute(IEntity owner, DestructibleSystem system)
|
||||
{
|
||||
if (string.IsNullOrEmpty(SoundCollection))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var sound = AudioHelpers.GetRandomFileFromSoundCollection(SoundCollection);
|
||||
var pos = owner.Transform.Coordinates;
|
||||
|
||||
SoundSystem.Play(Filter.Pvs(pos), sound, pos, AudioHelpers.WithVariation(0.125f));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user