replacing sound (collection) names with SoundSpecifier - part 1
This commit is contained in:
@@ -1,10 +1,7 @@
|
||||
using Content.Shared.Audio;
|
||||
using Content.Shared.Sound;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Player;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Random;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
|
||||
namespace Content.Server.Movement.Components
|
||||
@@ -15,23 +12,16 @@ namespace Content.Server.Movement.Components
|
||||
[RegisterComponent]
|
||||
public class FootstepModifierComponent : Component
|
||||
{
|
||||
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
||||
[Dependency] private readonly IRobustRandom _footstepRandom = default!;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string Name => "FootstepModifier";
|
||||
|
||||
[DataField("footstepSoundCollection")]
|
||||
public string? _soundCollectionName;
|
||||
public SoundSpecifier _soundCollection = default!;
|
||||
|
||||
public void PlayFootstep()
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(_soundCollectionName))
|
||||
{
|
||||
var soundCollection = _prototypeManager.Index<SoundCollectionPrototype>(_soundCollectionName);
|
||||
var file = _footstepRandom.Pick(soundCollection.PickFiles);
|
||||
SoundSystem.Play(Filter.Pvs(Owner), file, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2f));
|
||||
}
|
||||
if (_soundCollection.TryGetSound(out var footstepSound))
|
||||
SoundSystem.Play(Filter.Pvs(Owner), footstepSound, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2f));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user