Fix tool sounds.

Fixes #4465
This commit is contained in:
Vera Aguilera Puerto
2021-08-13 11:04:23 +02:00
parent 6a1ca13111
commit e66982161f
5 changed files with 14 additions and 9 deletions

View File

@@ -3,7 +3,6 @@ using System.Threading.Tasks;
using Content.Server.DoAfter;
using Content.Shared.ActionBlocker;
using Content.Shared.Audio;
using Content.Shared.Interaction.Events;
using Content.Shared.Sound;
using Content.Shared.Tool;
using Robust.Shared.Audio;
@@ -44,8 +43,9 @@ namespace Content.Server.Tools.Components
[DataField("speed")]
public float SpeedModifier { get; set; } = 1;
[DataField("useSound", required: true)]
public SoundSpecifier UseSound { get; set; } = default!;
// Some tools don't play a sound on use.
[DataField("useSound")]
public SoundSpecifier? UseSound { get; set; }
public void AddQuality(ToolQuality quality)
{
@@ -96,6 +96,9 @@ namespace Content.Server.Tools.Components
public void PlayUseSound(float volume = -5f)
{
if (UseSound == null)
return;
SoundSystem.Play(Filter.Pvs(Owner), UseSound.GetSound(), Owner, AudioHelpers.WithVariation(0.15f).WithVolume(volume));
}
}