]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Dock device link port (#27646)
author0x6273 <0x40@keemail.me>
Mon, 6 May 2024 03:59:01 +0000 (05:59 +0200)
committerGitHub <noreply@github.com>
Mon, 6 May 2024 03:59:01 +0000 (13:59 +1000)
* Add dock device link port

* SpawnAndDeleteAllEntitiesInTheSameSpot moment

* The fuck is TryStopNukeOpsFromConstantlyFailing??

Do we have a new test that can randomly fail?

Content.Server/Shuttles/Components/DockingSignalControlComponent.cs [new file with mode: 0644]
Content.Server/Shuttles/Systems/DockingSignalControlSystem.cs [new file with mode: 0644]
Resources/Locale/en-US/machine-linking/transmitter_ports.ftl
Resources/Prototypes/DeviceLinking/source_ports.yml
Resources/Prototypes/Entities/Structures/Doors/Airlocks/shuttle.yml

diff --git a/Content.Server/Shuttles/Components/DockingSignalControlComponent.cs b/Content.Server/Shuttles/Components/DockingSignalControlComponent.cs
new file mode 100644 (file)
index 0000000..4361265
--- /dev/null
@@ -0,0 +1,14 @@
+using Content.Shared.DeviceLinking;
+using Robust.Shared.Prototypes;
+
+namespace Content.Server.Shuttles.Components;
+
+[RegisterComponent]
+public sealed partial class DockingSignalControlComponent : Component
+{
+    /// <summary>
+    /// Output port that is high while docked.
+    /// </summary>
+    [DataField]
+    public ProtoId<SourcePortPrototype> DockStatusSignalPort = "DockStatus";
+}
diff --git a/Content.Server/Shuttles/Systems/DockingSignalControlSystem.cs b/Content.Server/Shuttles/Systems/DockingSignalControlSystem.cs
new file mode 100644 (file)
index 0000000..34cade7
--- /dev/null
@@ -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<DockingSignalControlComponent, DockEvent>(OnDocked);
+        SubscribeLocalEvent<DockingSignalControlComponent, UndockEvent>(OnUndocked);
+    }
+
+    private void OnDocked(Entity<DockingSignalControlComponent> ent, ref DockEvent args)
+    {
+        _deviceLinkSystem.SendSignal(ent, ent.Comp.DockStatusSignalPort, signal: true);
+    }
+
+    private void OnUndocked(Entity<DockingSignalControlComponent> ent, ref UndockEvent args)
+    {
+        _deviceLinkSystem.SendSignal(ent, ent.Comp.DockStatusSignalPort, signal: false);
+    }
+}
index c685cc8fb78de17a3ea8fb0613cf9e6671c2cb54..1d879fcee9db31496d07c5a12080d73234284914 100644 (file)
@@ -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.
 
index 18b9b831e6b83468834e072aba0e5da106e82732..1988f29e45c8e9ba1e11453ac8019ec10fe582fc 100644 (file)
   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
index 5d6b1088f12465793f59120fcb58b0185b133bde..43d1228a408c5e816ce66dbaaa11fefbb8828a23 100644 (file)
@@ -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
   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