DoorBoltWireAction.cs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. using Content.Server.Doors.Systems;
  2. using Content.Server.Wires;
  3. using Content.Shared.Doors;
  4. using Content.Shared.Doors.Components;
  5. using Content.Shared.Wires;
  6. namespace Content.Server.Doors;
  7. public sealed partial class DoorBoltWireAction : ComponentWireAction<DoorBoltComponent>
  8. {
  9. public override Color Color { get; set; } = Color.Red;
  10. public override string Name { get; set; } = "wire-name-door-bolt";
  11. public override StatusLightState? GetLightState(Wire wire, DoorBoltComponent comp)
  12. => comp.BoltsDown ? StatusLightState.On : StatusLightState.Off;
  13. public override object StatusKey { get; } = AirlockWireStatus.BoltIndicator;
  14. public override bool Cut(EntityUid user, Wire wire, DoorBoltComponent airlock)
  15. {
  16. EntityManager.System<DoorSystem>().SetBoltWireCut((wire.Owner, airlock), true);
  17. if (!airlock.BoltsDown && IsPowered(wire.Owner))
  18. EntityManager.System<DoorSystem>().SetBoltsDown((wire.Owner, airlock), true, user);
  19. return true;
  20. }
  21. public override bool Mend(EntityUid user, Wire wire, DoorBoltComponent door)
  22. {
  23. EntityManager.System<DoorSystem>().SetBoltWireCut((wire.Owner, door), false);
  24. return true;
  25. }
  26. public override void Pulse(EntityUid user, Wire wire, DoorBoltComponent door)
  27. {
  28. if (IsPowered(wire.Owner))
  29. EntityManager.System<DoorSystem>().SetBoltsDown((wire.Owner, door), !door.BoltsDown);
  30. else if (!door.BoltsDown)
  31. EntityManager.System<DoorSystem>().SetBoltsDown((wire.Owner, door), true);
  32. }
  33. }