Give BaseItem a landing sound (#14504)

This commit is contained in:
metalgearsloth
2023-03-11 19:26:01 +11:00
committed by GitHub
parent 33f388e66e
commit 1533e1b2b1
7 changed files with 38 additions and 22 deletions

View File

@@ -98,12 +98,12 @@ namespace Content.Shared.Sound
if (predict)
{
_audioSystem.PlayPredicted(component.Sound, component.Owner, user, component.Sound.Params.AddVolume(-2f));
_audioSystem.PlayPredicted(component.Sound, component.Owner, user);
}
else if (_netMan.IsServer)
{
// don't predict sounds that client couldn't have played already
_audioSystem.PlayPvs(component.Sound, component.Owner, component.Sound.Params.AddVolume(-2f));
_audioSystem.PlayPvs(component.Sound, component.Owner);
}
}
}

View File

@@ -82,7 +82,7 @@ public sealed class ThrowingSystem : EntitySystem
if (time < FlyTime)
{
_thrownSystem.LandComponent(comp, physics);
_thrownSystem.LandComponent(uid, comp, physics);
}
else
{
@@ -93,7 +93,7 @@ public sealed class ThrowingSystem : EntitySystem
if (physics.Deleted)
return;
_thrownSystem.LandComponent(comp, physics);
_thrownSystem.LandComponent(uid, comp, physics);
});
}
@@ -104,7 +104,7 @@ public sealed class ThrowingSystem : EntitySystem
_gravity.IsWeightless(user.Value, userPhysics))
{
var msg = new ThrowPushbackAttemptEvent();
RaiseLocalEvent(physics.Owner, msg);
RaiseLocalEvent(uid, msg);
if (!msg.Cancelled)
_physics.ApplyLinearImpulse(user.Value, -impulseVector * pushbackRatio, body: userPhysics);

View File

@@ -8,6 +8,7 @@ using Robust.Shared.GameStates;
using Robust.Shared.Physics;
using Robust.Shared.Physics.Dynamics;
using System.Linq;
using Content.Shared.Sound.Components;
using Robust.Shared.Physics.Components;
using Robust.Shared.Physics.Events;
using Robust.Shared.Physics.Systems;
@@ -117,16 +118,17 @@ namespace Content.Shared.Throwing
EntityManager.RemoveComponent<ThrownItemComponent>(uid);
}
public void LandComponent(ThrownItemComponent thrownItem, PhysicsComponent physics)
public void LandComponent(EntityUid uid, ThrownItemComponent thrownItem, PhysicsComponent physics)
{
_physics.SetBodyStatus(physics, BodyStatus.OnGround);
if (thrownItem.Deleted || Deleted(thrownItem.Owner) || _containerSystem.IsEntityInContainer(thrownItem.Owner)) return;
if (thrownItem.Deleted || Deleted(uid) || _containerSystem.IsEntityInContainer(uid))
return;
var landing = thrownItem.Owner;
var landing = uid;
// Unfortunately we can't check for hands containers as they have specific names.
if (thrownItem.Owner.TryGetContainerMan(out var containerManager) &&
if (uid.TryGetContainerMan(out var containerManager) &&
EntityManager.HasComponent<SharedHandsComponent>(containerManager.Owner))
{
EntityManager.RemoveComponent(landing, thrownItem);