Intercom Tweaks and Fixes (#13032)
Closes https://github.com/space-wizards/space-station-14/issues/13023
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
using Content.Server.Chat.Systems;
|
using Content.Server.Chat.Systems;
|
||||||
using Content.Server.Interaction;
|
using Content.Server.Interaction;
|
||||||
using Content.Server.Popups;
|
using Content.Server.Popups;
|
||||||
|
using Content.Server.Power.Components;
|
||||||
using Content.Server.Power.EntitySystems;
|
using Content.Server.Power.EntitySystems;
|
||||||
using Content.Server.Radio.Components;
|
using Content.Server.Radio.Components;
|
||||||
using Content.Server.Speech;
|
using Content.Server.Speech;
|
||||||
@@ -9,6 +10,7 @@ using Content.Shared.Examine;
|
|||||||
using Content.Shared.Interaction;
|
using Content.Shared.Interaction;
|
||||||
using Content.Shared.Radio;
|
using Content.Shared.Radio;
|
||||||
using Content.Shared.Verbs;
|
using Content.Shared.Verbs;
|
||||||
|
using Robust.Server.GameObjects;
|
||||||
using Robust.Shared.Player;
|
using Robust.Shared.Player;
|
||||||
using Robust.Shared.Prototypes;
|
using Robust.Shared.Prototypes;
|
||||||
|
|
||||||
@@ -24,6 +26,7 @@ public sealed class RadioDeviceSystem : EntitySystem
|
|||||||
[Dependency] private readonly ChatSystem _chat = default!;
|
[Dependency] private readonly ChatSystem _chat = default!;
|
||||||
[Dependency] private readonly RadioSystem _radio = default!;
|
[Dependency] private readonly RadioSystem _radio = default!;
|
||||||
[Dependency] private readonly InteractionSystem _interaction = 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.
|
// Used to prevent a shitter from using a bunch of radios to spam chat.
|
||||||
private HashSet<(string, EntityUid)> _recentlySent = new();
|
private HashSet<(string, EntityUid)> _recentlySent = new();
|
||||||
@@ -37,6 +40,7 @@ public sealed class RadioDeviceSystem : EntitySystem
|
|||||||
SubscribeLocalEvent<RadioMicrophoneComponent, ListenEvent>(OnListen);
|
SubscribeLocalEvent<RadioMicrophoneComponent, ListenEvent>(OnListen);
|
||||||
SubscribeLocalEvent<RadioMicrophoneComponent, ListenAttemptEvent>(OnAttemptListen);
|
SubscribeLocalEvent<RadioMicrophoneComponent, ListenAttemptEvent>(OnAttemptListen);
|
||||||
SubscribeLocalEvent<RadioMicrophoneComponent, GetVerbsEvent<Verb>>(OnGetVerbs);
|
SubscribeLocalEvent<RadioMicrophoneComponent, GetVerbsEvent<Verb>>(OnGetVerbs);
|
||||||
|
SubscribeLocalEvent<RadioMicrophoneComponent, PowerChangedEvent>(OnPowerChanged);
|
||||||
|
|
||||||
SubscribeLocalEvent<RadioSpeakerComponent, ComponentInit>(OnSpeakerInit);
|
SubscribeLocalEvent<RadioSpeakerComponent, ComponentInit>(OnSpeakerInit);
|
||||||
SubscribeLocalEvent<RadioSpeakerComponent, ActivateInWorldEvent>(OnActivateSpeaker);
|
SubscribeLocalEvent<RadioSpeakerComponent, ActivateInWorldEvent>(OnActivateSpeaker);
|
||||||
@@ -89,7 +93,7 @@ public sealed class RadioDeviceSystem : EntitySystem
|
|||||||
if (component.PowerRequired && !this.IsPowered(uid, EntityManager))
|
if (component.PowerRequired && !this.IsPowered(uid, EntityManager))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
component.Enabled = !component.Enabled;
|
SetMicrophoneEnabled(uid, !component.Enabled, component);
|
||||||
|
|
||||||
if (!quiet)
|
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)
|
public void ToggleRadioSpeaker(EntityUid uid, EntityUid user, bool quiet = false, RadioSpeakerComponent? component = null)
|
||||||
{
|
{
|
||||||
if (!Resolve(uid, ref component))
|
if (!Resolve(uid, ref component))
|
||||||
|
|||||||
15
Content.Shared/Radio/RadioVisuals.cs
Normal file
15
Content.Shared/Radio/RadioVisuals.cs
Normal file
@@ -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
|
||||||
|
}
|
||||||
@@ -17,14 +17,18 @@
|
|||||||
- type: InteractionOutline
|
- type: InteractionOutline
|
||||||
- type: Appearance
|
- type: Appearance
|
||||||
- type: Sprite
|
- type: Sprite
|
||||||
|
noRot: false
|
||||||
sprite: Structures/Wallmounts/intercom.rsi
|
sprite: Structures/Wallmounts/intercom.rsi
|
||||||
layers:
|
layers:
|
||||||
- state: base
|
- state: base
|
||||||
- state: unshaded
|
- state: unshaded
|
||||||
map: ["enum.PowerDeviceVisualLayers.Powered"]
|
map: ["enum.PowerDeviceVisualLayers.Powered"]
|
||||||
|
- state: broadcasting
|
||||||
|
map: ["enum.RadioDeviceVisualLayers.Broadcasting"]
|
||||||
shader: unshaded
|
shader: unshaded
|
||||||
|
visible: false
|
||||||
- type: Transform
|
- type: Transform
|
||||||
noRot: true
|
noRot: false
|
||||||
anchored: true
|
anchored: true
|
||||||
- type: Wires
|
- type: Wires
|
||||||
BoardName: "Intercom"
|
BoardName: "Intercom"
|
||||||
@@ -52,6 +56,10 @@
|
|||||||
enum.PowerDeviceVisualLayers.Powered:
|
enum.PowerDeviceVisualLayers.Powered:
|
||||||
True: { visible: true }
|
True: { visible: true }
|
||||||
False: { visible: false }
|
False: { visible: false }
|
||||||
|
enum.RadioDeviceVisuals.Broadcasting:
|
||||||
|
enum.RadioDeviceVisualLayers.Broadcasting:
|
||||||
|
True: { visible: true }
|
||||||
|
False: { visible: false }
|
||||||
placement:
|
placement:
|
||||||
mode: SnapgridCenter
|
mode: SnapgridCenter
|
||||||
snap:
|
snap:
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 171 B |
@@ -11,6 +11,10 @@
|
|||||||
"name": "base",
|
"name": "base",
|
||||||
"directions": 4
|
"directions": 4
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "broadcasting",
|
||||||
|
"directions": 4
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "build",
|
"name": "build",
|
||||||
"directions": 4
|
"directions": 4
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 382 B After Width: | Height: | Size: 369 B |
Reference in New Issue
Block a user