replacing sound (collection) names with SoundSpecifier - part 1

This commit is contained in:
Galactic Chimp
2021-07-10 17:35:33 +02:00
parent 4500b66f28
commit ce3c59e0e6
131 changed files with 934 additions and 587 deletions

View File

@@ -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));
}
}
}