Files
tbd-station-14/Content.Server/GameObjects/Components/Destructible/Thresholds/Behaviors/PlaySoundBehavior.cs
Acruid 9459400002 SoundSystem Improvements (#3697)
* Refactor all audio to use the new SoundSystem.

* Update submodule

Co-authored-by: Pieter-Jan Briers <pieterjan.briers+git@gmail.com>
2021-03-21 17:12:03 +01:00

32 lines
933 B
C#

using System;
using Content.Server.GameObjects.EntitySystems;
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.GameObjects.Components.Destructible.Thresholds.Behaviors
{
[Serializable]
[DataDefinition]
public class PlaySoundBehavior : IThresholdBehavior
{
/// <summary>
/// Sound played upon destruction.
/// </summary>
[DataField("sound")] public string Sound { get; set; } = string.Empty;
public void Execute(IEntity owner, DestructibleSystem system)
{
if (string.IsNullOrEmpty(Sound))
{
return;
}
var pos = owner.Transform.Coordinates;
SoundSystem.Play(Filter.Pvs(pos), Sound, pos, AudioHelpers.WithVariation(0.125f));
}
}
}