diff --git a/Content.Server/Shuttles/Components/DockingSignalControlComponent.cs b/Content.Server/Shuttles/Components/DockingSignalControlComponent.cs new file mode 100644 index 000000000000..436126508023 --- /dev/null +++ b/Content.Server/Shuttles/Components/DockingSignalControlComponent.cs @@ -0,0 +1,14 @@ +using Content.Shared.DeviceLinking; +using Robust.Shared.Prototypes; + +namespace Content.Server.Shuttles.Components; + +[RegisterComponent] +public sealed partial class DockingSignalControlComponent : Component +{ + /// + /// Output port that is high while docked. + /// + [DataField] + public ProtoId DockStatusSignalPort = "DockStatus"; +} diff --git a/Content.Server/Shuttles/Systems/DockingSignalControlSystem.cs b/Content.Server/Shuttles/Systems/DockingSignalControlSystem.cs new file mode 100644 index 000000000000..34cade7f1c11 --- /dev/null +++ b/Content.Server/Shuttles/Systems/DockingSignalControlSystem.cs @@ -0,0 +1,28 @@ +using Content.Server.DeviceLinking.Systems; +using Content.Server.Shuttles.Components; +using Content.Server.Shuttles.Events; + +namespace Content.Server.Shuttles.Systems; + +public sealed class DockingSignalControlSystem : EntitySystem +{ + [Dependency] private readonly DeviceLinkSystem _deviceLinkSystem = default!; + + public override void Initialize() + { + base.Initialize(); + + SubscribeLocalEvent(OnDocked); + SubscribeLocalEvent(OnUndocked); + } + + private void OnDocked(Entity ent, ref DockEvent args) + { + _deviceLinkSystem.SendSignal(ent, ent.Comp.DockStatusSignalPort, signal: true); + } + + private void OnUndocked(Entity ent, ref UndockEvent args) + { + _deviceLinkSystem.SendSignal(ent, ent.Comp.DockStatusSignalPort, signal: false); + } +} diff --git a/Resources/Locale/en-US/machine-linking/transmitter_ports.ftl b/Resources/Locale/en-US/machine-linking/transmitter_ports.ftl index c685cc8fb78d..1d879fcee9db 100644 --- a/Resources/Locale/en-US/machine-linking/transmitter_ports.ftl +++ b/Resources/Locale/en-US/machine-linking/transmitter_ports.ftl @@ -19,6 +19,9 @@ signal-port-description-right = This port is invoked whenever the lever is moved signal-port-name-doorstatus = Door status signal-port-description-doorstatus = This port is invoked with HIGH when the door opens and LOW when the door finishes closing. +signal-port-name-dockstatus = Dock status +signal-port-description-dockstatus = This port is invoked with HIGH when docked and LOW when undocked. + signal-port-name-middle = Middle signal-port-description-middle = This port is invoked whenever the lever is moved to the neutral position. diff --git a/Resources/Prototypes/DeviceLinking/source_ports.yml b/Resources/Prototypes/DeviceLinking/source_ports.yml index 18b9b831e6b8..1988f29e45c8 100644 --- a/Resources/Prototypes/DeviceLinking/source_ports.yml +++ b/Resources/Prototypes/DeviceLinking/source_ports.yml @@ -45,6 +45,11 @@ description: signal-port-description-doorstatus defaultLinks: [ DoorBolt ] +- type: sourcePort + id: DockStatus + name: signal-port-name-dockstatus + description: signal-port-description-dockstatus + - type: sourcePort id: OrderSender name: signal-port-name-order-sender diff --git a/Resources/Prototypes/Entities/Structures/Doors/Airlocks/shuttle.yml b/Resources/Prototypes/Entities/Structures/Doors/Airlocks/shuttle.yml index 5d6b1088f124..43d1228a408c 100644 --- a/Resources/Prototypes/Entities/Structures/Doors/Airlocks/shuttle.yml +++ b/Resources/Prototypes/Entities/Structures/Doors/Airlocks/shuttle.yml @@ -6,6 +6,11 @@ description: Necessary for connecting two space craft together. components: - type: Docking + - type: DockingSignalControl + - type: DeviceLinkSource + ports: + - DoorStatus + - DockStatus - type: Fixtures fixtures: fix1: @@ -75,7 +80,6 @@ suffix: Glass, Docking description: Necessary for connecting two space craft together. components: - - type: Docking - type: Sprite sprite: Structures/Doors/Airlocks/Glass/shuttle.rsi snapCardinals: false @@ -127,7 +131,6 @@ suffix: Glass, Docking description: Necessary for connecting two space craft together. components: - - type: Docking - type: Sprite sprite: Structures/Doors/Airlocks/Glass/shuttle_syndicate.rsi snapCardinals: false