diff --git a/Content.Server/Singularity/EntitySystems/GravityWellSystem.cs b/Content.Server/Singularity/EntitySystems/GravityWellSystem.cs index 55caba994b..eaa3c0a936 100644 --- a/Content.Server/Singularity/EntitySystems/GravityWellSystem.cs +++ b/Content.Server/Singularity/EntitySystems/GravityWellSystem.cs @@ -24,6 +24,7 @@ public sealed class GravityWellSystem : SharedGravityWellSystem [Dependency] private readonly IViewVariablesManager _vvManager = default!; [Dependency] private readonly EntityLookupSystem _lookup = default!; [Dependency] private readonly SharedPhysicsSystem _physics = default!; + [Dependency] private readonly SharedTransformSystem _transform = default!; #endregion Dependencies /// @@ -181,9 +182,12 @@ public sealed class GravityWellSystem : SharedGravityWellSystem var epicenter = mapPos.Position; var minRange2 = MathF.Max(minRange * minRange, MinGravPulseRange); // Cache square value for speed. Also apply a sane minimum value to the minimum value so that div/0s don't happen. + var bodyQuery = GetEntityQuery(); + var xformQuery = GetEntityQuery(); + foreach(var entity in _lookup.GetEntitiesInRange(mapPos.MapId, epicenter, maxRange, flags: LookupFlags.Dynamic | LookupFlags.Sundries)) { - if (!TryComp(entity, out var physics) + if (!bodyQuery.TryGetComponent(entity, out var physics) || physics.BodyType == BodyType.Static) { continue; @@ -192,7 +196,7 @@ public sealed class GravityWellSystem : SharedGravityWellSystem if(!CanGravPulseAffect(entity)) continue; - var displacement = epicenter - Transform(entity).WorldPosition; + var displacement = epicenter - _transform.GetWorldPosition(entity, xformQuery); var distance2 = displacement.LengthSquared; if (distance2 < minRange2) continue; diff --git a/Content.Shared/Sound/Components/EmitSoundOnCollideComponent.cs b/Content.Shared/Sound/Components/EmitSoundOnCollideComponent.cs index 95db14427d..d582fc0fa3 100644 --- a/Content.Shared/Sound/Components/EmitSoundOnCollideComponent.cs +++ b/Content.Shared/Sound/Components/EmitSoundOnCollideComponent.cs @@ -12,7 +12,7 @@ public sealed class EmitSoundOnCollideComponent : BaseEmitSoundComponent /// Minimum velocity required for the sound to play. /// [ViewVariables(VVAccess.ReadWrite), DataField("minVelocity")] - public float MinimumVelocity = 1f; + public float MinimumVelocity = 3f; /// /// To avoid sound spam add a cooldown to it. diff --git a/Content.Shared/Sound/SharedEmitSoundSystem.cs b/Content.Shared/Sound/SharedEmitSoundSystem.cs index a2fa038101..085b43cb7e 100644 --- a/Content.Shared/Sound/SharedEmitSoundSystem.cs +++ b/Content.Shared/Sound/SharedEmitSoundSystem.cs @@ -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)); } } diff --git a/Resources/Prototypes/Entities/Objects/base_item.yml b/Resources/Prototypes/Entities/Objects/base_item.yml index b8f71ee236..0a1fe41198 100644 --- a/Resources/Prototypes/Entities/Objects/base_item.yml +++ b/Resources/Prototypes/Entities/Objects/base_item.yml @@ -11,8 +11,6 @@ - type: EmitSoundOnCollide sound: path: /Audio/Effects/wall_bonk.ogg - params: - volume: 2 - type: EmitSoundOnLand sound: path: /Audio/Effects/drop.ogg