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

@@ -3,6 +3,7 @@ using System;
using System.Threading.Tasks;
using Content.Shared.Interaction;
using Content.Shared.Interaction.Helpers;
using Content.Shared.Sound;
using Robust.Shared.Audio;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
@@ -47,7 +48,7 @@ namespace Content.Server.Nutrition.Components
/// </summary>
[ViewVariables]
[DataField("breakSound")]
private string? _breakSound = "/Audio/Items/snap.ogg";
private SoundSpecifier _breakSound = new SoundPathSpecifier("/Audio/Items/snap.ogg");
public void AddType(UtensilType type)
{
@@ -71,9 +72,9 @@ namespace Content.Server.Nutrition.Components
internal void TryBreak(IEntity user)
{
if (_breakSound != null && IoCManager.Resolve<IRobustRandom>().Prob(_breakChance))
if (_breakSound.TryGetSound(out var breakSound) && IoCManager.Resolve<IRobustRandom>().Prob(_breakChance))
{
SoundSystem.Play(Filter.Pvs(user), _breakSound, user, AudioParams.Default.WithVolume(-2f));
SoundSystem.Play(Filter.Pvs(user), breakSound, user, AudioParams.Default.WithVolume(-2f));
Owner.Delete();
}
}