From 9f00782f26d7a2db8764fd2a46965d2f0f8f0c6c Mon Sep 17 00:00:00 2001 From: ArZarLordOfMango Date: Sat, 25 Jul 2026 12:52:20 +0200 Subject: [PATCH] Issue #3 is now Issue #6 --- Content.Shared/Sound/SharedEmitSoundSystem.cs | 25 ++++++++++++++++++- .../EmitAmbientOnUIOpenComponent.cs | 16 ++++++++++++ .../Components/EmitSoundOnUICloseComponent.cs | 16 ++++++++++++ 3 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 Content.Shared/_CorvaxGoob/Sound/Components/EmitAmbientOnUIOpenComponent.cs create mode 100644 Content.Shared/_CorvaxGoob/Sound/Components/EmitSoundOnUICloseComponent.cs diff --git a/Content.Shared/Sound/SharedEmitSoundSystem.cs b/Content.Shared/Sound/SharedEmitSoundSystem.cs index b354bb415a28..481b2e8e2bfa 100644 --- a/Content.Shared/Sound/SharedEmitSoundSystem.cs +++ b/Content.Shared/Sound/SharedEmitSoundSystem.cs @@ -11,6 +11,7 @@ using Content.Shared.Throwing; using Content.Shared.UserInterface; using Content.Shared.Whitelist; +using Content.Shared._CorvaxGoob.Sound.Components; // CorvaxGoob using JetBrains.Annotations; using Robust.Shared.Audio; using Robust.Shared.Audio.Systems; @@ -53,7 +54,9 @@ public override void Initialize() SubscribeLocalEvent(OnEmitSoundOnDrop); SubscribeLocalEvent(OnEmitSoundOnInteractUsing); SubscribeLocalEvent(HandleEmitSoundOnUIOpen); - + SubscribeLocalEvent(HandleEmitAmbientOnUIOpen); // CorvaxGoob + SubscribeLocalEvent(HandleEmitAmbientOnUIClose); // CorvaxGoob + SubscribeLocalEvent(HandleEmitSoundOnUIClose);// CorvaxGoob SubscribeLocalEvent(OnEmitSoundOnCollide); SubscribeLocalEvent(OnMobState); @@ -197,4 +200,24 @@ private void OnEmitSoundOnCollide(EntityUid uid, EmitSoundOnCollideComponent com public virtual void SetEnabled(Entity entity, bool enabled) { } + + // CorvaxGoob start + private void HandleEmitAmbientOnUIOpen(EntityUid uid, EmitAmbientOnUIOpenComponent component, AfterActivatableUIOpenEvent args) { + if (_whitelistSystem.IsWhitelistFail(component.Blacklist, args.User)) + { + if (TryComp(uid, out var ambient)) + _ambient.SetAmbience(uid, true, ambient); + } + } + + private void HandleEmitAmbientOnUIClose(EntityUid uid, EmitAmbientOnUIOpenComponent component, BoundUIClosedEvent args) { + if (TryComp(uid, out var ambient)) + _ambient.SetAmbience(uid, false, ambient); + } + + private void HandleEmitSoundOnUIClose(EntityUid uid, EmitSoundOnUICloseComponent component, BoundUIClosedEvent args) { + if (_whitelistSystem.IsWhitelistFail(component.Blacklist, args.Actor)) + TryEmitSound(uid, component, args.Actor); + } + // CorvaxGoob end } diff --git a/Content.Shared/_CorvaxGoob/Sound/Components/EmitAmbientOnUIOpenComponent.cs b/Content.Shared/_CorvaxGoob/Sound/Components/EmitAmbientOnUIOpenComponent.cs new file mode 100644 index 000000000000..70e75751ebf7 --- /dev/null +++ b/Content.Shared/_CorvaxGoob/Sound/Components/EmitAmbientOnUIOpenComponent.cs @@ -0,0 +1,16 @@ +using Content.Shared.Whitelist; +using Robust.Shared.Audio; +using Robust.Shared.GameStates; + +namespace Content.Shared._CorvaxGoob.Sound.Components; + +/// +/// Emit ambient while UI is open. +/// +[RegisterComponent, NetworkedComponent, AutoGenerateComponentState] +public sealed partial class EmitAmbientOnUIOpenComponent : Component +{ + [DataField] + [AutoNetworkedField] + public EntityWhitelist Blacklist = new(); +} \ No newline at end of file diff --git a/Content.Shared/_CorvaxGoob/Sound/Components/EmitSoundOnUICloseComponent.cs b/Content.Shared/_CorvaxGoob/Sound/Components/EmitSoundOnUICloseComponent.cs new file mode 100644 index 000000000000..c47ab9d5b968 --- /dev/null +++ b/Content.Shared/_CorvaxGoob/Sound/Components/EmitSoundOnUICloseComponent.cs @@ -0,0 +1,16 @@ +using Content.Shared.Sound.Components; +using Content.Shared.Whitelist; +using Robust.Shared.Audio; +using Robust.Shared.GameStates; + +namespace Content.Shared._CorvaxGoob.Sound.Components; + +/// +/// Emit sound when UI is closed. +/// +[RegisterComponent, NetworkedComponent, AutoGenerateComponentState] +public sealed partial class EmitSoundOnUICloseComponent : BaseEmitSoundComponent +{ + [DataField] + public EntityWhitelist Blacklist = new(); +} \ No newline at end of file