replacing sound (collection) names with SoundSpecifier - part 1
This commit is contained in:
@@ -4,6 +4,7 @@ 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;
|
||||
using Robust.Shared.GameObjects;
|
||||
@@ -44,10 +45,7 @@ namespace Content.Server.Tools.Components
|
||||
public float SpeedModifier { get; set; } = 1;
|
||||
|
||||
[DataField("useSound")]
|
||||
public string? UseSound { get; set; }
|
||||
|
||||
[DataField("useSoundCollection")]
|
||||
public string? UseSoundCollection { get; set; }
|
||||
public SoundSpecifier UseSound { get; set; } = default!;
|
||||
|
||||
public void AddQuality(ToolQuality quality)
|
||||
{
|
||||
@@ -96,30 +94,10 @@ namespace Content.Server.Tools.Components
|
||||
return true;
|
||||
}
|
||||
|
||||
protected void PlaySoundCollection(string? name, float volume = -5f)
|
||||
public void PlayUseSound(float volume = -5f)
|
||||
{
|
||||
if (string.IsNullOrEmpty(name))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var file = AudioHelpers.GetRandomFileFromSoundCollection(name);
|
||||
SoundSystem.Play(Filter.Pvs(Owner), file, Owner, AudioHelpers.WithVariation(0.15f).WithVolume(volume));
|
||||
}
|
||||
|
||||
public void PlayUseSound(float volume=-5f)
|
||||
{
|
||||
if (string.IsNullOrEmpty(UseSoundCollection))
|
||||
{
|
||||
if (!string.IsNullOrEmpty(UseSound))
|
||||
{
|
||||
SoundSystem.Play(Filter.Pvs(Owner), UseSound, Owner, AudioHelpers.WithVariation(0.15f).WithVolume(volume));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
PlaySoundCollection(UseSoundCollection, volume);
|
||||
}
|
||||
if(UseSound.TryGetSound(out var useSound))
|
||||
SoundSystem.Play(Filter.Pvs(Owner), useSound, Owner, AudioHelpers.WithVariation(0.15f).WithVolume(volume));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user