2021-03-21 09:12:03 -07:00
|
|
|
using Content.Shared.Audio;
|
2021-02-11 01:13:03 -08:00
|
|
|
using Robust.Server.GameObjects;
|
2019-07-31 15:02:36 +02:00
|
|
|
using Robust.Shared.Audio;
|
|
|
|
|
using Robust.Shared.GameObjects;
|
2019-06-03 23:16:47 +05:00
|
|
|
using Robust.Shared.IoC;
|
2021-03-21 09:12:03 -07:00
|
|
|
using Robust.Shared.Player;
|
2019-07-31 15:02:36 +02:00
|
|
|
using Robust.Shared.Prototypes;
|
2019-08-17 21:09:09 +02:00
|
|
|
using Robust.Shared.Random;
|
2021-03-05 01:08:38 +01:00
|
|
|
using Robust.Shared.Serialization.Manager.Attributes;
|
2019-06-03 23:16:47 +05:00
|
|
|
|
|
|
|
|
namespace Content.Server.GameObjects.Components.Sound
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Changes footstep sound
|
|
|
|
|
/// </summary>
|
2019-07-31 15:02:36 +02:00
|
|
|
[RegisterComponent]
|
2019-06-03 23:16:47 +05:00
|
|
|
public class FootstepModifierComponent : Component
|
|
|
|
|
{
|
2020-08-24 14:10:28 +02:00
|
|
|
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
|
|
|
|
[Dependency] private readonly IRobustRandom _footstepRandom = default!;
|
2019-06-03 23:16:47 +05:00
|
|
|
|
2020-08-24 14:10:28 +02:00
|
|
|
/// <inheritdoc />
|
2019-06-03 23:16:47 +05:00
|
|
|
public override string Name => "FootstepModifier";
|
|
|
|
|
|
2021-03-05 01:08:38 +01:00
|
|
|
[DataField("footstepSoundCollection")]
|
2021-03-16 15:50:20 +01:00
|
|
|
public string? _soundCollectionName;
|
2019-06-03 23:16:47 +05:00
|
|
|
|
|
|
|
|
public void PlayFootstep()
|
|
|
|
|
{
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(_soundCollectionName))
|
|
|
|
|
{
|
|
|
|
|
var soundCollection = _prototypeManager.Index<SoundCollectionPrototype>(_soundCollectionName);
|
|
|
|
|
var file = _footstepRandom.Pick(soundCollection.PickFiles);
|
2021-05-12 14:50:02 +02:00
|
|
|
SoundSystem.Play(Filter.Pvs(Owner), file, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2f));
|
2019-06-03 23:16:47 +05:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|