]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Cuttable speaker wire for vending machines (#23873)
authorTayrtahn <tayrtahn@gmail.com>
Fri, 12 Jan 2024 08:03:02 +0000 (03:03 -0500)
committerGitHub <noreply@github.com>
Fri, 12 Jan 2024 08:03:02 +0000 (01:03 -0700)
Implement SpeechWireAction

Content.Server/Speech/Components/SpeechWireAction.cs [new file with mode: 0644]
Content.Shared/Speech/EntitySystems/SharedSpeechWireAction.cs [new file with mode: 0644]
Content.Shared/Speech/SpeechSystem.cs
Resources/Locale/en-US/speech/speech-wire-action.ftl [new file with mode: 0644]
Resources/Locale/en-US/wires/wire-names.ftl
Resources/Prototypes/Wires/layouts.yml

diff --git a/Content.Server/Speech/Components/SpeechWireAction.cs b/Content.Server/Speech/Components/SpeechWireAction.cs
new file mode 100644 (file)
index 0000000..dd95f20
--- /dev/null
@@ -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<SpeechComponent>
+{
+    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<SpeechSystem>();
+        _popup = EntityManager.System<PopupSystem>();
+    }
+
+    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 (file)
index 0000000..0d23df8
--- /dev/null
@@ -0,0 +1,9 @@
+using Robust.Shared.Serialization;
+
+namespace Content.Shared.Speech;
+
+[Serializable, NetSerializable]
+public enum SpeechWireActionKey : byte
+{
+    StatusKey,
+}
index 4ce408b91a60a3cbe3b2ea116dcc60f8c9019b45..77e3b7ef02717e014e7637a1880cb1c7cbe6f5c9 100644 (file)
@@ -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 (file)
index 0000000..ac9d106
--- /dev/null
@@ -0,0 +1 @@
+wire-speech-pulse = {CAPITALIZE(THE($name))} emits a buzzing sound
index 16a4ede6b1cc1e2f1fb27254f91f6c510496802d..3204426fdb647c5b4c60417ae4ed25ad5454b40d 100644 (file)
@@ -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
index c6145441b2e70c82c77f5a0a6ffbbee80274ba07..d54965d88784537d4153e24313b32f3983974cb1 100644 (file)
@@ -39,6 +39,7 @@
   - !type:AccessWireAction
   - !type:VendingMachineContrabandWireAction
   - !type:VendingMachineEjectItemWireAction
+  - !type:SpeechWireAction
 
 - type: wireLayout
   id: AirAlarm