From de35226e05fac828f03861f54a21e5a5b33089ae Mon Sep 17 00:00:00 2001 From: Nemanja <98561806+EmoGarbage404@users.noreply.github.com> Date: Wed, 14 Dec 2022 23:13:02 -0500 Subject: [PATCH] Intercom Tweaks and Fixes (#13032) Closes https://github.com/space-wizards/space-station-14/issues/13023 --- .../Radio/EntitySystems/RadioDeviceSystem.cs | 22 +++++++++++++++++- Content.Shared/Radio/RadioVisuals.cs | 15 ++++++++++++ .../Structures/Wallmounts/intercom.yml | 10 +++++++- .../Wallmounts/intercom.rsi/broadcasting.png | Bin 0 -> 171 bytes .../Wallmounts/intercom.rsi/meta.json | 4 ++++ .../Wallmounts/intercom.rsi/unshaded.png | Bin 382 -> 369 bytes 6 files changed, 49 insertions(+), 2 deletions(-) create mode 100644 Content.Shared/Radio/RadioVisuals.cs create mode 100644 Resources/Textures/Structures/Wallmounts/intercom.rsi/broadcasting.png diff --git a/Content.Server/Radio/EntitySystems/RadioDeviceSystem.cs b/Content.Server/Radio/EntitySystems/RadioDeviceSystem.cs index 8ff99ac5d9..9b40e5b67f 100644 --- a/Content.Server/Radio/EntitySystems/RadioDeviceSystem.cs +++ b/Content.Server/Radio/EntitySystems/RadioDeviceSystem.cs @@ -1,6 +1,7 @@ using Content.Server.Chat.Systems; using Content.Server.Interaction; using Content.Server.Popups; +using Content.Server.Power.Components; using Content.Server.Power.EntitySystems; using Content.Server.Radio.Components; using Content.Server.Speech; @@ -9,6 +10,7 @@ using Content.Shared.Examine; using Content.Shared.Interaction; using Content.Shared.Radio; using Content.Shared.Verbs; +using Robust.Server.GameObjects; using Robust.Shared.Player; using Robust.Shared.Prototypes; @@ -24,6 +26,7 @@ public sealed class RadioDeviceSystem : EntitySystem [Dependency] private readonly ChatSystem _chat = default!; [Dependency] private readonly RadioSystem _radio = default!; [Dependency] private readonly InteractionSystem _interaction = default!; + [Dependency] private readonly AppearanceSystem _appearance = default!; // Used to prevent a shitter from using a bunch of radios to spam chat. private HashSet<(string, EntityUid)> _recentlySent = new(); @@ -37,6 +40,7 @@ public sealed class RadioDeviceSystem : EntitySystem SubscribeLocalEvent(OnListen); SubscribeLocalEvent(OnAttemptListen); SubscribeLocalEvent>(OnGetVerbs); + SubscribeLocalEvent(OnPowerChanged); SubscribeLocalEvent(OnSpeakerInit); SubscribeLocalEvent(OnActivateSpeaker); @@ -89,7 +93,7 @@ public sealed class RadioDeviceSystem : EntitySystem if (component.PowerRequired && !this.IsPowered(uid, EntityManager)) return; - component.Enabled = !component.Enabled; + SetMicrophoneEnabled(uid, !component.Enabled, component); if (!quiet) { @@ -137,6 +141,22 @@ public sealed class RadioDeviceSystem : EntitySystem } } + private void OnPowerChanged(EntityUid uid, RadioMicrophoneComponent component, ref PowerChangedEvent args) + { + if (args.Powered) + return; + SetMicrophoneEnabled(uid, false, component); + } + + public void SetMicrophoneEnabled(EntityUid uid, bool enabled, RadioMicrophoneComponent? component = null) + { + if (!Resolve(uid, ref component, false)) + return; + + component.Enabled = enabled; + _appearance.SetData(uid, RadioDeviceVisuals.Broadcasting, component.Enabled); + } + public void ToggleRadioSpeaker(EntityUid uid, EntityUid user, bool quiet = false, RadioSpeakerComponent? component = null) { if (!Resolve(uid, ref component)) diff --git a/Content.Shared/Radio/RadioVisuals.cs b/Content.Shared/Radio/RadioVisuals.cs new file mode 100644 index 0000000000..fc2993dec9 --- /dev/null +++ b/Content.Shared/Radio/RadioVisuals.cs @@ -0,0 +1,15 @@ +using Robust.Shared.Serialization; + +namespace Content.Shared.Radio; + +[Serializable, NetSerializable] +public enum RadioDeviceVisuals : byte +{ + Broadcasting +} + +[Serializable, NetSerializable] +public enum RadioDeviceVisualLayers : byte +{ + Broadcasting +} diff --git a/Resources/Prototypes/Entities/Structures/Wallmounts/intercom.yml b/Resources/Prototypes/Entities/Structures/Wallmounts/intercom.yml index 7920a9559c..f8d1a8cfcc 100644 --- a/Resources/Prototypes/Entities/Structures/Wallmounts/intercom.yml +++ b/Resources/Prototypes/Entities/Structures/Wallmounts/intercom.yml @@ -17,14 +17,18 @@ - type: InteractionOutline - type: Appearance - type: Sprite + noRot: false sprite: Structures/Wallmounts/intercom.rsi layers: - state: base - state: unshaded map: ["enum.PowerDeviceVisualLayers.Powered"] + - state: broadcasting + map: ["enum.RadioDeviceVisualLayers.Broadcasting"] shader: unshaded + visible: false - type: Transform - noRot: true + noRot: false anchored: true - type: Wires BoardName: "Intercom" @@ -52,6 +56,10 @@ enum.PowerDeviceVisualLayers.Powered: True: { visible: true } False: { visible: false } + enum.RadioDeviceVisuals.Broadcasting: + enum.RadioDeviceVisualLayers.Broadcasting: + True: { visible: true } + False: { visible: false } placement: mode: SnapgridCenter snap: diff --git a/Resources/Textures/Structures/Wallmounts/intercom.rsi/broadcasting.png b/Resources/Textures/Structures/Wallmounts/intercom.rsi/broadcasting.png new file mode 100644 index 0000000000000000000000000000000000000000..0566c70e35cfdc479d4164a4ce0413aace7b9098 GIT binary patch literal 171 zcmeAS@N?(olHy`uVBq!ia0vp^4j|0I1|(Ny7TyC=jKx9jP7LeL$-D$|QaxQ9Ln`LH zy|t0IK|zEiASo%^^{|7vI9LDx literal 0 HcmV?d00001 diff --git a/Resources/Textures/Structures/Wallmounts/intercom.rsi/meta.json b/Resources/Textures/Structures/Wallmounts/intercom.rsi/meta.json index 44babf5bfb..5df8b265bf 100644 --- a/Resources/Textures/Structures/Wallmounts/intercom.rsi/meta.json +++ b/Resources/Textures/Structures/Wallmounts/intercom.rsi/meta.json @@ -11,6 +11,10 @@ "name": "base", "directions": 4 }, + { + "name": "broadcasting", + "directions": 4 + }, { "name": "build", "directions": 4 diff --git a/Resources/Textures/Structures/Wallmounts/intercom.rsi/unshaded.png b/Resources/Textures/Structures/Wallmounts/intercom.rsi/unshaded.png index e50e20bbed5ce8e0c32c1f63f9d728c1944b08ed..b6731da141b67ef8ef410f8a03229c674ac77a81 100644 GIT binary patch delta 329 zcmV-P0k;1B0`UTnF@GybL_t(|obB4NZG%7*#_`YWU>bXdD19b~lmW;x9>6V2q(!30 z0x1y@W$L8L499a3frwlrU@$!M|4AnS64K*|cL#ST0RRA?zqBYV388IiQQF)wT}|`w zGBeo^k4cDz-uV6b_3L~i=_QKJuHUp(mjG}*m1IZ7e#+~p*ncX?Pr!g5s~&m}S>Aqm zHZ2Lk4p}}p34^}`=dj)Hl+^WE@4DUZW{GDOt1bZm0000004#y`1(1s;MPC(<5y$eS zMS0QmvuoYmAgi2(O+qm1EJVy5&zSz*2W+N{Vnl~5@Aa0tS{eFFT9o$j^r*M{JB?bZ z-PM>S_W|8qYeJ)!s)tcv(gb+WB*1zk;HLV3hxba7^jz2N@#^#)1zdBrb8HIUf5ZR) b0A_UpO|SWh>V4>000000NkvXXu0mjf?eLy5 delta 342 zcmV-c0jd7+0{#M!F@HEoL_t(|obB2%j)FiG2H;=rAdQ~EZ0`w7_5kc(qd35nGkl7JsqS!1$6>eK-+a3wr8J z^P*dMwpU_|qRH8s^IdlBT&CUFXY%N<1opE&(DUA|fIpBBJ2A=sk?y6Vz;g z>=0```j2hb$Xi)ijoN