Fly-by sound tweaks (#10658)

This commit is contained in:
metalgearsloth
2022-08-18 12:32:39 +10:00
committed by GitHub
parent 64a25dc8f6
commit b627b2b34d
2 changed files with 13 additions and 5 deletions

View File

@@ -13,6 +13,7 @@ public sealed class FlyBySoundSystem : SharedFlyBySoundSystem
{ {
[Dependency] private readonly IPlayerManager _player = default!; [Dependency] private readonly IPlayerManager _player = default!;
[Dependency] private readonly IRobustRandom _random = default!; [Dependency] private readonly IRobustRandom _random = default!;
[Dependency] private readonly SharedAudioSystem _audio = default!;
public override void Initialize() public override void Initialize()
{ {
@@ -28,11 +29,18 @@ public sealed class FlyBySoundSystem : SharedFlyBySoundSystem
if (attachedEnt == null || if (attachedEnt == null ||
args.OtherFixture.Body.Owner != attachedEnt || args.OtherFixture.Body.Owner != attachedEnt ||
TryComp<ProjectileComponent>(args.OurFixture.Body.Owner, out var projectile) && TryComp<ProjectileComponent>(args.OurFixture.Body.Owner, out var projectile) &&
projectile.Shooter == attachedEnt) return; projectile.Shooter == attachedEnt)
{
return;
}
if (args.OurFixture.ID != FlyByFixture || if (args.OurFixture.ID != FlyByFixture ||
!_random.Prob(component.Prob)) return; !_random.Prob(component.Prob))
{
return;
}
SoundSystem.Play(component.Sound.GetSound(), Filter.Local(), uid, component.Sound.Params); // Play attached to our entity because the projectile may immediately delete or the likes.
_audio.Play(component.Sound, Filter.Local(), attachedEnt.Value);
} }
} }

View File

@@ -13,12 +13,12 @@ public sealed class FlyBySoundComponent : Component
/// Probability that the sound plays /// Probability that the sound plays
/// </summary> /// </summary>
[ViewVariables(VVAccess.ReadWrite), DataField("prob")] [ViewVariables(VVAccess.ReadWrite), DataField("prob")]
public float Prob = 0.75f; public float Prob = 0.10f;
[ViewVariables(VVAccess.ReadWrite), DataField("sound")] [ViewVariables(VVAccess.ReadWrite), DataField("sound")]
public SoundSpecifier Sound = new SoundCollectionSpecifier("BulletMiss") public SoundSpecifier Sound = new SoundCollectionSpecifier("BulletMiss")
{ {
Params = AudioParams.Default.WithVolume(5f), Params = AudioParams.Default,
}; };
[ViewVariables, DataField("range")] public float Range = 1.5f; [ViewVariables, DataField("range")] public float Range = 1.5f;