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 0000000000..0566c70e35 Binary files /dev/null and b/Resources/Textures/Structures/Wallmounts/intercom.rsi/broadcasting.png differ 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 e50e20bbed..b6731da141 100644 Binary files a/Resources/Textures/Structures/Wallmounts/intercom.rsi/unshaded.png and b/Resources/Textures/Structures/Wallmounts/intercom.rsi/unshaded.png differ