Files
tbd-station-14/Content.Server/GameObjects/Components/Sound/EmitSoundOnThrowComponent.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

43 lines
1.3 KiB
C#

using Content.Shared.Audio;
using Content.Shared.Interfaces.GameObjects.Components;
using Robust.Shared.Audio;
using Robust.Shared.GameObjects;
using Robust.Shared.Player;
using Robust.Shared.Serialization.Manager.Attributes;
namespace Content.Server.GameObjects.Components.Sound
{
/// <summary>
/// Simple sound emitter that emits sound on use in hand
/// </summary>
[RegisterComponent]
public class EmitSoundOnThrowComponent : Component, ILand
{
/// <inheritdoc />
///
public override string Name => "EmitSoundOnThrow";
[DataField("sound")]
public string? _soundName;
[DataField("variation")]
public float _pitchVariation;
public void PlaySoundEffect()
{
if (!string.IsNullOrWhiteSpace(_soundName))
{
if (_pitchVariation > 0.0)
{
SoundSystem.Play(Filter.Pvs(Owner), _soundName, Owner, AudioHelpers.WithVariation(_pitchVariation).WithVolume(-2f));
}
SoundSystem.Play(Filter.Pvs(Owner), _soundName, Owner, AudioParams.Default.WithVolume(-2f));
}
}
void ILand.Land(LandEventArgs eventArgs)
{
PlaySoundEffect();
}
}
}