1
0

ParticleAcceleratorToggleWireAction.cs 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. using Content.Server.ParticleAccelerator.Components;
  2. using Content.Server.ParticleAccelerator.EntitySystems;
  3. using Content.Server.Wires;
  4. using Content.Shared.Singularity.Components;
  5. using Content.Shared.Wires;
  6. using Robust.Shared.Player;
  7. namespace Content.Server.ParticleAccelerator.Wires;
  8. public sealed partial class ParticleAcceleratorPowerWireAction : ComponentWireAction<ParticleAcceleratorControlBoxComponent>
  9. {
  10. public override string Name { get; set; } = "wire-name-pa-power";
  11. public override Color Color { get; set; } = Color.Yellow;
  12. public override object StatusKey { get; } = ParticleAcceleratorWireStatus.Power;
  13. public override StatusLightState? GetLightState(Wire wire, ParticleAcceleratorControlBoxComponent component)
  14. {
  15. if (!component.CanBeEnabled)
  16. return StatusLightState.Off;
  17. return component.Enabled ? StatusLightState.On : StatusLightState.BlinkingSlow;
  18. }
  19. public override bool Cut(EntityUid user, Wire wire, ParticleAcceleratorControlBoxComponent controller)
  20. {
  21. var paSystem = EntityManager.System<ParticleAcceleratorSystem>();
  22. controller.CanBeEnabled = false;
  23. paSystem.SwitchOff(wire.Owner, user, controller);
  24. return true;
  25. }
  26. public override bool Mend(EntityUid user, Wire wire, ParticleAcceleratorControlBoxComponent controller)
  27. {
  28. controller.CanBeEnabled = true;
  29. return true;
  30. }
  31. public override void Pulse(EntityUid user, Wire wire, ParticleAcceleratorControlBoxComponent controller)
  32. {
  33. var paSystem = EntityManager.System<ParticleAcceleratorSystem>();
  34. if (controller.Enabled)
  35. paSystem.SwitchOff(wire.Owner, user, controller);
  36. else if (controller.Assembled)
  37. paSystem.SwitchOn(wire.Owner, user, controller);
  38. }
  39. }