Fix: Grenades don't make trigger sound (#25321)

* Fix: Grenades don't make trigger sound

* transform instead of trycomp transform

---------

Co-authored-by: Plykiya <plykiya@protonmail.com>
(cherry picked from commit 7d94cc719c4c7c6cbffbe4b7aad72f36ed689621)
This commit is contained in:
Plykiya
2024-02-17 08:54:58 -08:00
committed by Debug
parent 33b647a4da
commit afcae40a0a
2 changed files with 12 additions and 4 deletions

View File

@@ -29,6 +29,8 @@ using Robust.Shared.Physics.Events;
using Robust.Shared.Physics.Systems;
using Robust.Shared.Prototypes;
using Robust.Shared.Random;
using Robust.Shared.Player;
using Content.Shared.Coordinates;
namespace Content.Server.Explosion.EntitySystems
{
@@ -103,9 +105,15 @@ namespace Content.Server.Explosion.EntitySystems
private void OnSoundTrigger(EntityUid uid, SoundOnTriggerComponent component, TriggerEvent args)
{
_audio.PlayPvs(component.Sound, uid);
if (component.RemoveOnTrigger)
RemCompDeferred<SoundOnTriggerComponent>(uid);
if (component.RemoveOnTrigger) // if the component gets removed when it's triggered
{
var xform = Transform(uid);
_audio.PlayPvs(component.Sound, xform.Coordinates); // play the sound at its last known coordinates
}
else // if the component doesn't get removed when triggered
{
_audio.PlayPvs(component.Sound, uid); // have the sound follow the entity itself
}
}
private void OnAnchorTrigger(EntityUid uid, AnchorOnTriggerComponent component, TriggerEvent args)