From 82576358114f31870f385bbac97409f47c023640 Mon Sep 17 00:00:00 2001 From: Flipp Syder <76629141+vulppine@users.noreply.github.com> Date: Mon, 9 May 2022 18:40:15 -0700 Subject: [PATCH] Electrocution noises (#8061) * Adds spark noises when an entity gets electrocuted by something * oops * double oops * Update Content.Server/Electrocution/Components/ElectrifiedComponent.cs Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> --- .../Electrocution/Components/ElectrifiedComponent.cs | 10 ++++++++++ Content.Server/Electrocution/ElectrocutionSystem.cs | 12 ++++++++++++ 2 files changed, 22 insertions(+) diff --git a/Content.Server/Electrocution/Components/ElectrifiedComponent.cs b/Content.Server/Electrocution/Components/ElectrifiedComponent.cs index d37201f076..0399a0086c 100644 --- a/Content.Server/Electrocution/Components/ElectrifiedComponent.cs +++ b/Content.Server/Electrocution/Components/ElectrifiedComponent.cs @@ -1,3 +1,4 @@ +using Content.Shared.Sound; using Robust.Shared.GameObjects; using Robust.Shared.Serialization.Manager.Attributes; @@ -65,5 +66,14 @@ namespace Content.Server.Electrocution [DataField("siemensCoefficient")] public float SiemensCoefficient { get; } = 1f; + + [DataField("shockNoises")] + public SoundSpecifier ShockNoises { get; } = new SoundCollectionSpecifier("sparks"); + + [DataField("playSoundOnShock")] + public bool PlaySoundOnShock { get; } = true; + + [DataField("shockVolume")] + public float ShockVolume { get; } = 20; } } diff --git a/Content.Server/Electrocution/ElectrocutionSystem.cs b/Content.Server/Electrocution/ElectrocutionSystem.cs index fdb6569a52..4029c49abb 100644 --- a/Content.Server/Electrocution/ElectrocutionSystem.cs +++ b/Content.Server/Electrocution/ElectrocutionSystem.cs @@ -22,6 +22,7 @@ using Content.Shared.StatusEffect; using Content.Shared.Stunnable; using Content.Shared.Tag; using Content.Shared.Weapons.Melee; +using Robust.Shared.Audio; using Robust.Shared.GameObjects; using Robust.Shared.IoC; using Robust.Shared.Localization; @@ -388,6 +389,7 @@ namespace Content.Server.Electrocution { _popupSystem.PopupEntity(Loc.GetString("electrocuted-component-mob-shocked-by-source-popup-others", ("mob", uid), ("source", (sourceUid.Value))), uid, filter); + PlayElectrocutionSound(uid, sourceUid.Value); } else { @@ -440,5 +442,15 @@ namespace Content.Server.Electrocution SetInsulatedSiemensCoefficient(uid, _random.Pick(randomInsulation.List), insulated); } + + private void PlayElectrocutionSound(EntityUid targetUid, EntityUid sourceUid, ElectrifiedComponent? electrified = null) + { + if (!Resolve(sourceUid, ref electrified) || !electrified.PlaySoundOnShock) + { + return; + } + + SoundSystem.Play(Filter.Pvs(targetUid), electrified.ShockNoises.GetSound(), targetUid, AudioParams.Default.WithVolume(electrified.ShockVolume)); + } } }