Cuttable speaker wire for vending machines (#23873)
Implement SpeechWireAction
This commit is contained in:
45
Content.Server/Speech/Components/SpeechWireAction.cs
Normal file
45
Content.Server/Speech/Components/SpeechWireAction.cs
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
using Robust.Shared.Serialization;
|
||||||
|
|
||||||
|
namespace Content.Shared.Speech;
|
||||||
|
|
||||||
|
[Serializable, NetSerializable]
|
||||||
|
public enum SpeechWireActionKey : byte
|
||||||
|
{
|
||||||
|
StatusKey,
|
||||||
|
}
|
||||||
@@ -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)
|
||||||
|
|||||||
1
Resources/Locale/en-US/speech/speech-wire-action.ftl
Normal file
1
Resources/Locale/en-US/speech/speech-wire-action.ftl
Normal file
@@ -0,0 +1 @@
|
|||||||
|
wire-speech-pulse = {CAPITALIZE(THE($name))} emits a buzzing sound
|
||||||
@@ -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
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user