Nerf emitsoundoncollide (#16602)
This commit is contained in:
@@ -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
|
||||
|
||||
/// <summary>
|
||||
@@ -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<PhysicsComponent>();
|
||||
var xformQuery = GetEntityQuery<TransformComponent>();
|
||||
|
||||
foreach(var entity in _lookup.GetEntitiesInRange(mapPos.MapId, epicenter, maxRange, flags: LookupFlags.Dynamic | LookupFlags.Sundries))
|
||||
{
|
||||
if (!TryComp<PhysicsComponent>(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;
|
||||
|
||||
@@ -12,7 +12,7 @@ public sealed class EmitSoundOnCollideComponent : BaseEmitSoundComponent
|
||||
/// Minimum velocity required for the sound to play.
|
||||
/// </summary>
|
||||
[ViewVariables(VVAccess.ReadWrite), DataField("minVelocity")]
|
||||
public float MinimumVelocity = 1f;
|
||||
public float MinimumVelocity = 3f;
|
||||
|
||||
/// <summary>
|
||||
/// To avoid sound spam add a cooldown to it.
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,8 +11,6 @@
|
||||
- type: EmitSoundOnCollide
|
||||
sound:
|
||||
path: /Audio/Effects/wall_bonk.ogg
|
||||
params:
|
||||
volume: 2
|
||||
- type: EmitSoundOnLand
|
||||
sound:
|
||||
path: /Audio/Effects/drop.ogg
|
||||
|
||||
Reference in New Issue
Block a user