From 6617310ffac3f3f8859db4ba906c044fca923f45 Mon Sep 17 00:00:00 2001
From: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
Date: Wed, 11 May 2022 09:22:02 +1000
Subject: [PATCH] Don't play landing sounds in space (#8085)
---
Content.Server/Sound/EmitSoundSystem.cs | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/Content.Server/Sound/EmitSoundSystem.cs b/Content.Server/Sound/EmitSoundSystem.cs
index 8562a99bf8..816fd70880 100644
--- a/Content.Server/Sound/EmitSoundSystem.cs
+++ b/Content.Server/Sound/EmitSoundSystem.cs
@@ -5,9 +5,11 @@ using Content.Server.Throwing;
using Content.Server.UserInterface;
using Content.Shared.Interaction;
using Content.Shared.Interaction.Events;
+using Content.Shared.Maps;
using Content.Shared.Throwing;
using JetBrains.Annotations;
using Robust.Shared.Audio;
+using Robust.Shared.Map;
using Robust.Shared.Player;
using Robust.Shared.Random;
@@ -19,7 +21,9 @@ namespace Content.Server.Sound
[UsedImplicitly]
public sealed class EmitSoundSystem : EntitySystem
{
+ [Dependency] private readonly IMapManager _mapManager = default!;
[Dependency] private readonly IRobustRandom _random = default!;
+ [Dependency] private readonly ITileDefinitionManager _tileDefMan = default!;
///
public override void Initialize()
@@ -40,6 +44,13 @@ namespace Content.Server.Sound
private void HandleEmitSoundOnLand(EntityUid eUI, BaseEmitSoundComponent component, LandEvent arg)
{
+ if (!TryComp(eUI, out var xform) ||
+ !_mapManager.TryGetGrid(xform.GridID, out var grid)) return;
+
+ var tile = grid.GetTileRef(xform.Coordinates);
+
+ if (tile.IsSpace(_tileDefMan)) return;
+
TryEmitSound(component);
}