Cuttable speaker wire for vending machines (#23873)

Implement SpeechWireAction
This commit is contained in:
Tayrtahn
2024-01-12 03:03:02 -05:00
committed by GitHub
parent b9f694ea59
commit b8de514237
6 changed files with 60 additions and 1 deletions

View File

@@ -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);
}
}

View File

@@ -0,0 +1,9 @@
using Robust.Shared.Serialization;
namespace Content.Shared.Speech;
[Serializable, NetSerializable]
public enum SpeechWireActionKey : byte
{
StatusKey,
}

View File

@@ -19,7 +19,9 @@ namespace Content.Shared.Speech
if (component.Enabled == value) if (component.Enabled == value)
return; return;
Dirty(component); component.Enabled = value;
Dirty(uid, component);
} }
private void OnSpeakAttempt(SpeakAttemptEvent args) private void OnSpeakAttempt(SpeakAttemptEvent args)

View File

@@ -0,0 +1 @@
wire-speech-pulse = {CAPITALIZE(THE($name))} emits a buzzing sound

View File

@@ -63,3 +63,4 @@ wire-name-bomb-delay = DLAY
wire-name-bomb-proceed = PRCD wire-name-bomb-proceed = PRCD
wire-name-bomb-boom = BOOM wire-name-bomb-boom = BOOM
wire-name-bomb-bolt = BOLT wire-name-bomb-bolt = BOLT
wire-name-speech = SPKR

View File

@@ -39,6 +39,7 @@
- !type:AccessWireAction - !type:AccessWireAction
- !type:VendingMachineContrabandWireAction - !type:VendingMachineContrabandWireAction
- !type:VendingMachineEjectItemWireAction - !type:VendingMachineEjectItemWireAction
- !type:SpeechWireAction
- type: wireLayout - type: wireLayout
id: AirAlarm id: AirAlarm