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
{
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)