SpeechWireAction.cs 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. using Content.Server.Popups;
  2. using Content.Server.Wires;
  3. using Content.Shared.Speech;
  4. using Content.Shared.Wires;
  5. namespace Content.Server.Speech;
  6. public sealed partial class SpeechWireAction : ComponentWireAction<SpeechComponent>
  7. {
  8. private SpeechSystem _speech = default!;
  9. private PopupSystem _popup = default!;
  10. public override Color Color { get; set; } = Color.Green;
  11. public override string Name { get; set; } = "wire-name-speech";
  12. public override object? StatusKey { get; } = SpeechWireActionKey.StatusKey;
  13. public override StatusLightState? GetLightState(Wire wire, SpeechComponent component)
  14. => component.Enabled ? StatusLightState.On : StatusLightState.Off;
  15. public override void Initialize()
  16. {
  17. base.Initialize();
  18. _speech = EntityManager.System<SpeechSystem>();
  19. _popup = EntityManager.System<PopupSystem>();
  20. }
  21. public override bool Cut(EntityUid user, Wire wire, SpeechComponent component)
  22. {
  23. _speech.SetSpeech(wire.Owner, false, component);
  24. return true;
  25. }
  26. public override bool Mend(EntityUid user, Wire wire, SpeechComponent component)
  27. {
  28. _speech.SetSpeech(wire.Owner, true, component);
  29. return true;
  30. }
  31. public override void Pulse(EntityUid user, Wire wire, SpeechComponent component)
  32. {
  33. _popup.PopupEntity(Loc.GetString("wire-speech-pulse", ("name", wire.Owner)), wire.Owner);
  34. }
  35. }