From c7a5587e0710f6d4b8a959bb54fbcd9e9631a96f Mon Sep 17 00:00:00 2001 From: 0x6273 <0x40@keemail.me> Date: Mon, 6 May 2024 05:59:01 +0200 Subject: [PATCH] Dock device link port (#27646) * Add dock device link port * SpawnAndDeleteAllEntitiesInTheSameSpot moment * The fuck is TryStopNukeOpsFromConstantlyFailing?? Do we have a new test that can randomly fail? --- .../DockingSignalControlComponent.cs | 14 ++++++++++ .../Systems/DockingSignalControlSystem.cs | 28 +++++++++++++++++++ .../machine-linking/transmitter_ports.ftl | 3 ++ .../Prototypes/DeviceLinking/source_ports.yml | 5 ++++ .../Structures/Doors/Airlocks/shuttle.yml | 7 +++-- 5 files changed, 55 insertions(+), 2 deletions(-) create mode 100644 Content.Server/Shuttles/Components/DockingSignalControlComponent.cs create mode 100644 Content.Server/Shuttles/Systems/DockingSignalControlSystem.cs diff --git a/Content.Server/Shuttles/Components/DockingSignalControlComponent.cs b/Content.Server/Shuttles/Components/DockingSignalControlComponent.cs new file mode 100644 index 0000000000..4361265080 --- /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 0000000000..34cade7f1c --- /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 c685cc8fb7..1d879fcee9 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 18b9b831e6..1988f29e45 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 5d6b1088f1..43d1228a40 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