Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dock device link port #27646

Merged
merged 3 commits into from
May 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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";
}
28 changes: 28 additions & 0 deletions Content.Server/Shuttles/Systems/DockingSignalControlSystem.cs
Original file line number Diff line number Diff line change
@@ -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);
}
}
3 changes: 3 additions & 0 deletions Resources/Locale/en-US/machine-linking/transmitter_ports.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
5 changes: 5 additions & 0 deletions Resources/Prototypes/DeviceLinking/source_ports.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Loading