replacing sound (collection) names with SoundSpecifier - part 1
This commit is contained in:
@@ -5,6 +5,7 @@ using Content.Shared.Audio;
|
||||
using Content.Shared.Interaction;
|
||||
using Content.Shared.Research.Components;
|
||||
using Content.Shared.Research.Prototypes;
|
||||
using Content.Shared.Sound;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Server.Player;
|
||||
using Robust.Shared.Audio;
|
||||
@@ -13,6 +14,7 @@ using Robust.Shared.IoC;
|
||||
using Robust.Shared.Player;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Random;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
using Robust.Shared.ViewVariables;
|
||||
|
||||
namespace Content.Server.Research.Components
|
||||
@@ -24,7 +26,8 @@ namespace Content.Server.Research.Components
|
||||
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
||||
[Dependency] private readonly IRobustRandom _random = default!;
|
||||
|
||||
private const string SoundCollectionName = "keyboard";
|
||||
[DataField("sound")]
|
||||
private SoundSpecifier _soundCollectionName = new SoundCollectionSpecifier("keyboard");
|
||||
|
||||
[ViewVariables] private bool Powered => !Owner.TryGetComponent(out ApcPowerReceiverComponent? receiver) || receiver.Powered;
|
||||
|
||||
@@ -123,9 +126,8 @@ namespace Content.Server.Research.Components
|
||||
|
||||
private void PlayKeyboardSound()
|
||||
{
|
||||
var soundCollection = _prototypeManager.Index<SoundCollectionPrototype>(SoundCollectionName);
|
||||
var file = _random.Pick(soundCollection.PickFiles);
|
||||
SoundSystem.Play(Filter.Pvs(Owner), file,Owner,AudioParams.Default);
|
||||
if (_soundCollectionName.TryGetSound(out var sound))
|
||||
SoundSystem.Play(Filter.Pvs(Owner), sound, Owner, AudioParams.Default);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user