PlaySoundBehavior.cs 792 B

1234567891011121314151617181920212223
  1. using Content.Shared.Audio;
  2. using Robust.Shared.Audio;
  3. using Robust.Shared.Audio.Systems;
  4. using Robust.Shared.Player;
  5. namespace Content.Server.Destructible.Thresholds.Behaviors
  6. {
  7. [Serializable]
  8. [DataDefinition]
  9. public sealed partial class PlaySoundBehavior : IThresholdBehavior
  10. {
  11. /// <summary>
  12. /// Sound played upon destruction.
  13. /// </summary>
  14. [DataField("sound", required: true)] public SoundSpecifier Sound { get; set; } = default!;
  15. public void Execute(EntityUid owner, DestructibleSystem system, EntityUid? cause = null)
  16. {
  17. var pos = system.EntityManager.GetComponent<TransformComponent>(owner).Coordinates;
  18. system.EntityManager.System<SharedAudioSystem>().PlayPvs(Sound, pos);
  19. }
  20. }
  21. }