Nerf emitsoundoncollide (#16602)

This commit is contained in:
metalgearsloth
2023-05-20 02:04:26 +10:00
committed by GitHub
parent 373435c006
commit d6adf9880d
4 changed files with 17 additions and 6 deletions

View File

@@ -6,6 +6,7 @@ using Content.Shared.Popups;
using Content.Shared.Sound.Components;
using Content.Shared.Throwing;
using JetBrains.Annotations;
using Robust.Shared.Audio;
using Robust.Shared.Map;
using Robust.Shared.Network;
using Robust.Shared.Physics.Components;
@@ -133,7 +134,15 @@ public abstract class SharedEmitSoundSystem : EntitySystem
return;
}
const float MaxVolumeVelocity = 10f;
const float MinVolume = -10f;
const float MaxVolume = 2f;
var fraction = MathF.Min(1f, (physics.LinearVelocity.Length - component.MinimumVelocity) / MaxVolumeVelocity);
var volume = MinVolume + (MaxVolume - MinVolume) * fraction;
component.NextSound = _timing.CurTime + EmitSoundOnCollideComponent.CollideCooldown;
TryEmitSound(uid, component, predict: false);
if (_netMan.IsServer)
_audioSystem.PlayPvs(component.Sound, uid, AudioParams.Default.WithVolume(volume));
}
}