Factorio - add a power toggle link port for the robotic arm. (#4117)

* Adds a toggle power sink port to the robotic arm

* Created babys first componenet, the toggle power
link port is not a componenet (PowerTogglePort)
Wow!

* Update PowerTogglePortComponent.cs

Deltanedas special #1

Signed-off-by: AlgisAlphonse <94876543+AlgisAlphonse@users.noreply.github.com>

* Update PowerTogglePortComponent.cs

susnedas

Signed-off-by: AlgisAlphonse <94876543+AlgisAlphonse@users.noreply.github.com>

* Update PowerTogglePortComponent.cs

sus

Signed-off-by: AlgisAlphonse <94876543+AlgisAlphonse@users.noreply.github.com>

---------

Signed-off-by: AlgisAlphonse <94876543+AlgisAlphonse@users.noreply.github.com>
This commit is contained in:
AlgisAlphonse 2025-08-26 22:05:17 +02:00 committed by GitHub
parent cc8e79ac54
commit 495361de72
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 53 additions and 0 deletions

View File

@ -0,0 +1,15 @@
using Content.Shared.DeviceLinking;
using Robust.Shared.Prototypes;
using Robust.Shared.GameStates;
using Robust.Shared.Serialization;
using Content.Shared._DV.DeviceLinking.Systems;
namespace Content.Shared._DV.DeviceLinking.Components;
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
[Access(typeof(PowerTogglePortSystem))]
public sealed partial class PowerTogglePortComponent : Component
{
[DataField, AutoNetworkedField]
public ProtoId<SinkPortPrototype> PowerTogglePort = "PowerToggle";
}

View File

@ -0,0 +1,29 @@
using Content.Shared.DeviceLinking.Events;
using Content.Shared.Power.EntitySystems;
using Content.Shared.Power.Components;
using Content.Shared.DeviceLinking;
using Content.Shared._DV.DeviceLinking.Components;
using Robust.Shared.Prototypes;
namespace Content.Shared._DV.DeviceLinking.Systems;
public sealed class PowerTogglePortSystem : EntitySystem
{
[Dependency] private readonly SharedDeviceLinkSystem _device = default!;
[Dependency] private readonly SharedPowerReceiverSystem _power = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<PowerTogglePortComponent, SignalReceivedEvent>(OnSignalReceived);
}
private void OnSignalReceived(Entity<PowerTogglePortComponent> entity, ref SignalReceivedEvent args)
{
if (args.Port == entity.Comp.PowerTogglePort)
_power.TogglePower(entity);
}
}

View File

@ -0,0 +1,3 @@
signal-port-name-power-toggle = Toggle Power
signal-port-description-power-toggle = A signal port, that toggles power state when it recieves a signal.

View File

@ -0,0 +1,4 @@
- type: sinkPort
id: PowerToggle
name: signal-port-name-power-toggle
description: signal-port-description-power-toggle

View File

@ -99,9 +99,11 @@
- type: DeviceLinkSink
ports:
- RoboticArmInput
- PowerToggle #DeltaV
# - On
# - Off
# TODO: ports to disable it
- type: PowerTogglePort #DeltaV
- type: DeviceLinkSource
ports:
- RoboticArmOutput