signal router (#20802)
* add signal router sprite * DisposalSignalRouter logic * add disposal signal router * add disposal signal router * how did it work without this * death --------- Co-authored-by: deltanedas <@deltanedas:kde.org>
This commit is contained in:
@@ -0,0 +1,36 @@
|
|||||||
|
using Content.Server.Disposal.Tube.Systems;
|
||||||
|
using Content.Shared.DeviceLinking;
|
||||||
|
using Robust.Shared.Prototypes;
|
||||||
|
|
||||||
|
namespace Content.Server.Disposal.Tube.Components;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Requires <see cref="DisposalJunctionComponent"/> to function.
|
||||||
|
/// </summary>
|
||||||
|
[RegisterComponent, Access(typeof(DisposalSignalRouterSystem))]
|
||||||
|
public sealed partial class DisposalSignalRouterComponent : Component
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Whether to route items to the side or not.
|
||||||
|
/// </summary>
|
||||||
|
[DataField]
|
||||||
|
public bool Routing;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Port that sets the router to send items to the side.
|
||||||
|
/// </summary>
|
||||||
|
[DataField]
|
||||||
|
public ProtoId<SinkPortPrototype> OnPort = "On";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Port that sets the router to send items ahead.
|
||||||
|
/// </summary>
|
||||||
|
[DataField]
|
||||||
|
public ProtoId<SinkPortPrototype> OffPort = "Off";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Port that toggles the router between sending items to the side and ahead.
|
||||||
|
/// </summary>
|
||||||
|
[DataField]
|
||||||
|
public ProtoId<SinkPortPrototype> TogglePort = "Toggle";
|
||||||
|
}
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
using Content.Server.DeviceLinking.Events;
|
||||||
|
using Content.Server.DeviceLinking.Systems;
|
||||||
|
using Content.Server.Disposal.Tube;
|
||||||
|
using Content.Server.Disposal.Tube.Components;
|
||||||
|
|
||||||
|
namespace Content.Server.Disposal.Tube.Systems;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Handles signals and the routing get next direction event.
|
||||||
|
/// </summary>
|
||||||
|
public sealed class DisposalSignalRouterSystem : EntitySystem
|
||||||
|
{
|
||||||
|
[Dependency] private readonly DeviceLinkSystem _deviceLink = default!;
|
||||||
|
|
||||||
|
public override void Initialize()
|
||||||
|
{
|
||||||
|
base.Initialize();
|
||||||
|
|
||||||
|
SubscribeLocalEvent<DisposalSignalRouterComponent, ComponentInit>(OnInit);
|
||||||
|
SubscribeLocalEvent<DisposalSignalRouterComponent, SignalReceivedEvent>(OnSignalReceived);
|
||||||
|
SubscribeLocalEvent<DisposalSignalRouterComponent, GetDisposalsNextDirectionEvent>(OnGetNextDirection, after: new[] { typeof(DisposalTubeSystem) });
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnInit(EntityUid uid, DisposalSignalRouterComponent comp, ComponentInit args)
|
||||||
|
{
|
||||||
|
_deviceLink.EnsureSinkPorts(uid, comp.OnPort, comp.OffPort, comp.TogglePort);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnSignalReceived(EntityUid uid, DisposalSignalRouterComponent comp, ref SignalReceivedEvent args)
|
||||||
|
{
|
||||||
|
// TogglePort flips it
|
||||||
|
// OnPort sets it to true
|
||||||
|
// OffPort sets it to false
|
||||||
|
comp.Routing = args.Port == comp.TogglePort
|
||||||
|
? !comp.Routing
|
||||||
|
: args.Port == comp.OnPort;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnGetNextDirection(EntityUid uid, DisposalSignalRouterComponent comp, ref GetDisposalsNextDirectionEvent args)
|
||||||
|
{
|
||||||
|
if (!comp.Routing)
|
||||||
|
{
|
||||||
|
args.Next = Transform(uid).LocalRotation.GetDir();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// use the junction side direction when a tag matches
|
||||||
|
var ev = new GetDisposalsConnectableDirectionsEvent();
|
||||||
|
RaiseLocalEvent(uid, ref ev);
|
||||||
|
args.Next = ev.Connectable[1];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -426,3 +426,63 @@
|
|||||||
- type: Construction
|
- type: Construction
|
||||||
graph: DisposalPipe
|
graph: DisposalPipe
|
||||||
node: bend
|
node: bend
|
||||||
|
|
||||||
|
- type: entity
|
||||||
|
parent: DisposalJunction
|
||||||
|
id: DisposalSignalRouter
|
||||||
|
name: disposal signal router
|
||||||
|
description: A signal-controlled three-way router.
|
||||||
|
components:
|
||||||
|
- type: Sprite
|
||||||
|
drawdepth: ThickPipe
|
||||||
|
layers:
|
||||||
|
- map: [ "pipe" ]
|
||||||
|
state: signal-router-free
|
||||||
|
- type: DisposalTube
|
||||||
|
containerId: DisposalSignalRouter
|
||||||
|
- type: DisposalSignalRouter
|
||||||
|
- type: DeviceLinkSink
|
||||||
|
ports:
|
||||||
|
- On
|
||||||
|
- Off
|
||||||
|
- Toggle
|
||||||
|
- type: DeviceNetwork
|
||||||
|
deviceNetId: Wireless
|
||||||
|
receiveFrequencyId: BasicDevice
|
||||||
|
- type: WirelessNetworkConnection
|
||||||
|
range: 200
|
||||||
|
- type: ContainerContainer
|
||||||
|
containers:
|
||||||
|
DisposalSignalRouter: !type:Container
|
||||||
|
- type: GenericVisualizer
|
||||||
|
visuals:
|
||||||
|
enum.DisposalTubeVisuals.VisualState:
|
||||||
|
pipe:
|
||||||
|
Free: { state: signal-router-free }
|
||||||
|
Anchored: { state: signal-router }
|
||||||
|
- type: Flippable
|
||||||
|
mirrorEntity: DisposalSignalRouterFlipped
|
||||||
|
- type: Construction
|
||||||
|
graph: DisposalPipe
|
||||||
|
node: signal_router
|
||||||
|
|
||||||
|
- type: entity
|
||||||
|
parent: DisposalSignalRouter
|
||||||
|
id: DisposalSignalRouterFlipped
|
||||||
|
suffix: flipped
|
||||||
|
components:
|
||||||
|
- type: Sprite
|
||||||
|
layers:
|
||||||
|
- map: [ "pipe" ]
|
||||||
|
state: signal-router-flipped-free
|
||||||
|
- type: DisposalJunction
|
||||||
|
degrees:
|
||||||
|
- 0
|
||||||
|
- 90
|
||||||
|
- 180
|
||||||
|
- type: GenericVisualizer
|
||||||
|
visuals:
|
||||||
|
enum.DisposalTubeVisuals.VisualState:
|
||||||
|
pipe:
|
||||||
|
Free: { state: signal-router-flipped-free }
|
||||||
|
Anchored: { state: signal-router-flipped }
|
||||||
|
|||||||
@@ -51,6 +51,23 @@
|
|||||||
- material: Steel
|
- material: Steel
|
||||||
amount: 2
|
amount: 2
|
||||||
doAfter: 1
|
doAfter: 1
|
||||||
|
# DisposalSignalRouter
|
||||||
|
- to: signal_router
|
||||||
|
steps:
|
||||||
|
- material: Steel
|
||||||
|
amount: 2
|
||||||
|
doAfter: 1
|
||||||
|
- material: Cable
|
||||||
|
amount: 1
|
||||||
|
doAfter: 1
|
||||||
|
- to: signal_router_flipped
|
||||||
|
steps:
|
||||||
|
- material: Steel
|
||||||
|
amount: 2
|
||||||
|
doAfter: 1
|
||||||
|
- material: Cable
|
||||||
|
amount: 1
|
||||||
|
doAfter: 1
|
||||||
- node: broken
|
- node: broken
|
||||||
entity: DisposalPipeBroken
|
entity: DisposalPipeBroken
|
||||||
edges:
|
edges:
|
||||||
@@ -188,3 +205,32 @@
|
|||||||
steps:
|
steps:
|
||||||
- tool: Welding
|
- tool: Welding
|
||||||
doAfter: 1
|
doAfter: 1
|
||||||
|
# DisposalRouter
|
||||||
|
- node: signal_router
|
||||||
|
entity: DisposalSignalRouter
|
||||||
|
edges:
|
||||||
|
- to: start
|
||||||
|
completed:
|
||||||
|
- !type:SpawnPrototype
|
||||||
|
prototype: SheetSteel1
|
||||||
|
amount: 2
|
||||||
|
- !type:SpawnPrototype
|
||||||
|
prototype: CableApcStack1
|
||||||
|
- !type:DeleteEntity
|
||||||
|
steps:
|
||||||
|
- tool: Welding
|
||||||
|
doAfter: 1
|
||||||
|
- node: signal_router_flipped
|
||||||
|
entity: DisposalSignalRouterFlipped
|
||||||
|
edges:
|
||||||
|
- to: start
|
||||||
|
completed:
|
||||||
|
- !type:SpawnPrototype
|
||||||
|
prototype: SheetSteel1
|
||||||
|
amount: 2
|
||||||
|
- !type:SpawnPrototype
|
||||||
|
prototype: CableApcStack1
|
||||||
|
- !type:DeleteEntity
|
||||||
|
steps:
|
||||||
|
- tool: Welding
|
||||||
|
doAfter: 1
|
||||||
|
|||||||
@@ -242,6 +242,37 @@
|
|||||||
state: conpipe-j2s
|
state: conpipe-j2s
|
||||||
mirror: DisposalRouter
|
mirror: DisposalRouter
|
||||||
|
|
||||||
|
- type: construction
|
||||||
|
name: disposal signal router
|
||||||
|
description: A signal-controlled three-way router.
|
||||||
|
id: DisposalSignalRouter
|
||||||
|
graph: DisposalPipe
|
||||||
|
startNode: start
|
||||||
|
targetNode: signal_router
|
||||||
|
category: construction-category-utilities
|
||||||
|
placementMode: SnapgridCenter
|
||||||
|
canBuildInImpassable: false
|
||||||
|
icon:
|
||||||
|
sprite: Structures/Piping/disposal.rsi
|
||||||
|
state: signal-router-free
|
||||||
|
mirror: DisposalSignalRouterFlipped
|
||||||
|
|
||||||
|
- type: construction
|
||||||
|
hide: true
|
||||||
|
name: disposal signal router
|
||||||
|
description: A signal-controlled three-way router.
|
||||||
|
id: DisposalSignalRouterFlipped
|
||||||
|
graph: DisposalPipe
|
||||||
|
startNode: start
|
||||||
|
targetNode: signal_router_flipped
|
||||||
|
category: construction-category-utilities
|
||||||
|
placementMode: SnapgridCenter
|
||||||
|
canBuildInImpassable: false
|
||||||
|
icon:
|
||||||
|
sprite: Structures/Piping/disposal.rsi
|
||||||
|
state: signal-router-flipped-free
|
||||||
|
mirror: DisposalSignalRouter
|
||||||
|
|
||||||
- type: construction
|
- type: construction
|
||||||
name: disposal junction
|
name: disposal junction
|
||||||
description: A three-way junction. The arrow indicates where items exit.
|
description: A three-way junction. The arrow indicates where items exit.
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
"y": 32
|
"y": 32
|
||||||
},
|
},
|
||||||
"license": "CC-BY-SA-3.0",
|
"license": "CC-BY-SA-3.0",
|
||||||
"copyright": "https://github.com/discordia-space/CEV-Eris/blob/bbe32606902c90f5290b57d905a3f31b84dc6d7d/icons/obj/pipes/disposal.dmi and modified by DrSmugleaf",
|
"copyright": "https://github.com/discordia-space/CEV-Eris/blob/bbe32606902c90f5290b57d905a3f31b84dc6d7d/icons/obj/pipes/disposal.dmi and modified by DrSmugleaf. Signal router sprites based on normal router modified by deltanedas (github).",
|
||||||
"states": [
|
"states": [
|
||||||
{
|
{
|
||||||
"name": "condisposal",
|
"name": "condisposal",
|
||||||
@@ -827,6 +827,78 @@
|
|||||||
1.0
|
1.0
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "signal-router",
|
||||||
|
"directions": 4,
|
||||||
|
"delays": [
|
||||||
|
[
|
||||||
|
1.0
|
||||||
|
],
|
||||||
|
[
|
||||||
|
1.0
|
||||||
|
],
|
||||||
|
[
|
||||||
|
1.0
|
||||||
|
],
|
||||||
|
[
|
||||||
|
1.0
|
||||||
|
]
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "signal-router-free",
|
||||||
|
"directions": 4,
|
||||||
|
"delays": [
|
||||||
|
[
|
||||||
|
1.0
|
||||||
|
],
|
||||||
|
[
|
||||||
|
1.0
|
||||||
|
],
|
||||||
|
[
|
||||||
|
1.0
|
||||||
|
],
|
||||||
|
[
|
||||||
|
1.0
|
||||||
|
]
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "signal-router-flipped",
|
||||||
|
"directions": 4,
|
||||||
|
"delays": [
|
||||||
|
[
|
||||||
|
1.0
|
||||||
|
],
|
||||||
|
[
|
||||||
|
1.0
|
||||||
|
],
|
||||||
|
[
|
||||||
|
1.0
|
||||||
|
],
|
||||||
|
[
|
||||||
|
1.0
|
||||||
|
]
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "signal-router-flipped-free",
|
||||||
|
"directions": 4,
|
||||||
|
"delays": [
|
||||||
|
[
|
||||||
|
1.0
|
||||||
|
],
|
||||||
|
[
|
||||||
|
1.0
|
||||||
|
],
|
||||||
|
[
|
||||||
|
1.0
|
||||||
|
],
|
||||||
|
[
|
||||||
|
1.0
|
||||||
|
]
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 4.9 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 5.5 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 4.9 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 5.5 KiB |
Reference in New Issue
Block a user