diff --git a/Content.Server/Speech/Components/SpeechWireAction.cs b/Content.Server/Speech/Components/SpeechWireAction.cs new file mode 100644 index 0000000000..dd95f2051b --- /dev/null +++ b/Content.Server/Speech/Components/SpeechWireAction.cs @@ -0,0 +1,45 @@ +using Content.Server.Popups; +using Content.Server.Wires; +using Content.Shared.Speech; +using Content.Shared.Wires; + +namespace Content.Server.Speech; + +public sealed partial class SpeechWireAction : ComponentWireAction +{ + private SpeechSystem _speech = default!; + private PopupSystem _popup = default!; + + public override Color Color { get; set; } = Color.Green; + public override string Name { get; set; } = "wire-name-speech"; + + public override object? StatusKey { get; } = SpeechWireActionKey.StatusKey; + + public override StatusLightState? GetLightState(Wire wire, SpeechComponent component) + => component.Enabled ? StatusLightState.On : StatusLightState.Off; + + public override void Initialize() + { + base.Initialize(); + + _speech = EntityManager.System(); + _popup = EntityManager.System(); + } + + public override bool Cut(EntityUid user, Wire wire, SpeechComponent component) + { + _speech.SetSpeech(wire.Owner, false, component); + return true; + } + + public override bool Mend(EntityUid user, Wire wire, SpeechComponent component) + { + _speech.SetSpeech(wire.Owner, true, component); + return true; + } + + public override void Pulse(EntityUid user, Wire wire, SpeechComponent component) + { + _popup.PopupEntity(Loc.GetString("wire-speech-pulse", ("name", wire.Owner)), wire.Owner); + } +} diff --git a/Content.Shared/Speech/EntitySystems/SharedSpeechWireAction.cs b/Content.Shared/Speech/EntitySystems/SharedSpeechWireAction.cs new file mode 100644 index 0000000000..0d23df83c0 --- /dev/null +++ b/Content.Shared/Speech/EntitySystems/SharedSpeechWireAction.cs @@ -0,0 +1,9 @@ +using Robust.Shared.Serialization; + +namespace Content.Shared.Speech; + +[Serializable, NetSerializable] +public enum SpeechWireActionKey : byte +{ + StatusKey, +} diff --git a/Content.Shared/Speech/SpeechSystem.cs b/Content.Shared/Speech/SpeechSystem.cs index 4ce408b91a..77e3b7ef02 100644 --- a/Content.Shared/Speech/SpeechSystem.cs +++ b/Content.Shared/Speech/SpeechSystem.cs @@ -19,7 +19,9 @@ namespace Content.Shared.Speech if (component.Enabled == value) return; - Dirty(component); + component.Enabled = value; + + Dirty(uid, component); } private void OnSpeakAttempt(SpeakAttemptEvent args) diff --git a/Resources/Locale/en-US/speech/speech-wire-action.ftl b/Resources/Locale/en-US/speech/speech-wire-action.ftl new file mode 100644 index 0000000000..ac9d106c85 --- /dev/null +++ b/Resources/Locale/en-US/speech/speech-wire-action.ftl @@ -0,0 +1 @@ +wire-speech-pulse = {CAPITALIZE(THE($name))} emits a buzzing sound diff --git a/Resources/Locale/en-US/wires/wire-names.ftl b/Resources/Locale/en-US/wires/wire-names.ftl index 16a4ede6b1..3204426fdb 100644 --- a/Resources/Locale/en-US/wires/wire-names.ftl +++ b/Resources/Locale/en-US/wires/wire-names.ftl @@ -63,3 +63,4 @@ wire-name-bomb-delay = DLAY wire-name-bomb-proceed = PRCD wire-name-bomb-boom = BOOM wire-name-bomb-bolt = BOLT +wire-name-speech = SPKR diff --git a/Resources/Prototypes/Wires/layouts.yml b/Resources/Prototypes/Wires/layouts.yml index c6145441b2..d54965d887 100644 --- a/Resources/Prototypes/Wires/layouts.yml +++ b/Resources/Prototypes/Wires/layouts.yml @@ -39,6 +39,7 @@ - !type:AccessWireAction - !type:VendingMachineContrabandWireAction - !type:VendingMachineEjectItemWireAction + - !type:SpeechWireAction - type: wireLayout id: AirAlarm