From 0090af6b3b430881114457fedfe201b106ff4f6b Mon Sep 17 00:00:00 2001 From: moneyl <8206401+Moneyl@users.noreply.github.com> Date: Fri, 20 Sep 2019 13:42:45 -0400 Subject: [PATCH] Disable footstep sounds for ghosts (#343) * Disable footstep sounds for ghosts Adds a check before playing footstep sounds to check if the mover is a ghost. Doesn't play footstep sounds if they are a ghost. * Add FootstepSoundComponent Adds FootstepSoundComponent. If a mob has this component, it will make footstep sounds. Otherwise they will not. As of this commit humans have this component and ghosts do not. --- .../Components/Mobs/FootstepSoundComponent.cs | 21 +++++++++++++++++++ .../GameObjects/EntitySystems/MoverSystem.cs | 7 +++++++ Resources/Prototypes/Entities/mobs/human.yml | 1 + 3 files changed, 29 insertions(+) create mode 100644 Content.Server/GameObjects/Components/Mobs/FootstepSoundComponent.cs diff --git a/Content.Server/GameObjects/Components/Mobs/FootstepSoundComponent.cs b/Content.Server/GameObjects/Components/Mobs/FootstepSoundComponent.cs new file mode 100644 index 0000000000..7a6cf43fbb --- /dev/null +++ b/Content.Server/GameObjects/Components/Mobs/FootstepSoundComponent.cs @@ -0,0 +1,21 @@ +using Robust.Shared.GameObjects; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Content.Server.Mobs; +using Robust.Shared.Interfaces.GameObjects; +using Robust.Shared.ViewVariables; + +namespace Content.Server.GameObjects.Components.Mobs +{ + /// + /// Mobs will only make footstep sounds if they have this component. + /// + [RegisterComponent] + public class FootstepSoundComponent : Component + { + public override string Name => "FootstepSound"; + } +} diff --git a/Content.Server/GameObjects/EntitySystems/MoverSystem.cs b/Content.Server/GameObjects/EntitySystems/MoverSystem.cs index 7febdefc70..f20bb0320e 100644 --- a/Content.Server/GameObjects/EntitySystems/MoverSystem.cs +++ b/Content.Server/GameObjects/EntitySystems/MoverSystem.cs @@ -1,5 +1,6 @@ using System; using Content.Server.GameObjects.Components; +using Content.Server.GameObjects.Components.Mobs; using Content.Server.GameObjects.Components.Movement; using Content.Server.Interfaces.GameObjects.Components.Movement; using Content.Shared.Audio; @@ -153,6 +154,12 @@ namespace Content.Server.GameObjects.EntitySystems if (mover.StepSoundDistance > distanceNeeded) { mover.StepSoundDistance = 0; + + if (!mover.Owner.HasComponent()) + { + return; + } + if (mover.Owner.TryGetComponent(out var inventory) && inventory.TryGetSlotItem(EquipmentSlotDefines.Slots.SHOES, out var item) && item.Owner.TryGetComponent(out var modifier)) diff --git a/Resources/Prototypes/Entities/mobs/human.yml b/Resources/Prototypes/Entities/mobs/human.yml index 81404f4f87..fe72758873 100644 --- a/Resources/Prototypes/Entities/mobs/human.yml +++ b/Resources/Prototypes/Entities/mobs/human.yml @@ -67,4 +67,5 @@ - type: Teleportable - type: Examiner - type: CharacterInfo + - type: FootstepSound