ParticleAcceleratorLimiterWireAction.cs 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. using Content.Server.ParticleAccelerator.Components;
  2. using Content.Server.ParticleAccelerator.EntitySystems;
  3. using Content.Server.Popups;
  4. using Content.Server.Wires;
  5. using Content.Shared.Popups;
  6. using Content.Shared.Singularity.Components;
  7. using Content.Shared.Wires;
  8. namespace Content.Server.ParticleAccelerator.Wires;
  9. public sealed partial class ParticleAcceleratorLimiterWireAction : ComponentWireAction<ParticleAcceleratorControlBoxComponent>
  10. {
  11. public override string Name { get; set; } = "wire-name-pa-limiter";
  12. public override Color Color { get; set; } = Color.Teal;
  13. public override object StatusKey { get; } = ParticleAcceleratorWireStatus.Limiter;
  14. public override StatusLightData? GetStatusLightData(Wire wire)
  15. {
  16. var result = base.GetStatusLightData(wire);
  17. if (result.HasValue
  18. && EntityManager.TryGetComponent<ParticleAcceleratorControlBoxComponent>(wire.Owner, out var controller)
  19. && controller.MaxStrength >= ParticleAcceleratorPowerState.Level3)
  20. result = new(Color.Purple, result.Value.State, result.Value.Text);
  21. return result;
  22. }
  23. public override StatusLightState? GetLightState(Wire wire, ParticleAcceleratorControlBoxComponent component)
  24. {
  25. return StatusLightState.On;
  26. }
  27. public override bool Cut(EntityUid user, Wire wire, ParticleAcceleratorControlBoxComponent controller)
  28. {
  29. controller.MaxStrength = ParticleAcceleratorPowerState.Level3;
  30. var paSystem = EntityManager.System<ParticleAcceleratorSystem>();
  31. paSystem.UpdateUI(wire.Owner, controller);
  32. return true;
  33. }
  34. public override bool Mend(EntityUid user, Wire wire, ParticleAcceleratorControlBoxComponent controller)
  35. {
  36. controller.MaxStrength = ParticleAcceleratorPowerState.Level2;
  37. if (controller.SelectedStrength <= controller.MaxStrength || controller.StrengthLocked)
  38. return true;
  39. // Yes, it's a feature that mending this wire WON'T WORK if the strength wire is also cut.
  40. // Since that blocks SetStrength().
  41. var paSystem = EntityManager.System<ParticleAcceleratorSystem>();
  42. paSystem.SetStrength(wire.Owner, controller.MaxStrength, user, controller);
  43. paSystem.UpdateUI(wire.Owner, controller);
  44. return true;
  45. }
  46. public override void Pulse(EntityUid user, Wire wire, ParticleAcceleratorControlBoxComponent controller)
  47. {
  48. EntityManager.System<PopupSystem>()
  49. .PopupEntity(
  50. Loc.GetString("particle-accelerator-control-box-component-wires-update-limiter-on-pulse"),
  51. user,
  52. PopupType.SmallCaution
  53. );
  54. }
  55. public override void Update(Wire wire)
  56. {
  57. }
  58. }