Skip to content

Commit f2f2857

Browse files
mnva0funkystationbot
andauthored
Makes body scanner computers function as health analyzers for their linked operating table (funky-station#1438)
Co-authored-by: funkystationbot <funky@funkystation.org>
1 parent fbb22ea commit f2f2857

4 files changed

Lines changed: 113 additions & 1 deletion

File tree

Content.Server/Medical/Components/HealthAnalyzerComponent.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
// SPDX-FileCopyrightText: 2024 Tadeo <td12233a@gmail.com>
1616
// SPDX-FileCopyrightText: 2024 deltanedas <39013340+deltanedas@users.noreply.github.com>
1717
// SPDX-FileCopyrightText: 2025 Tay <td12233a@gmail.com>
18+
// SPDX-FileCopyrightText: 2025 mnva <218184747+mnva0@users.noreply.github.com>
1819
// SPDX-FileCopyrightText: 2025 pa.pecherskij <pa.pecherskij@interfax.ru>
1920
// SPDX-FileCopyrightText: 2025 taydeo <td12233a@gmail.com>
2021
//
@@ -32,7 +33,7 @@ namespace Content.Server.Medical.Components;
3233
/// Requires <c>ItemToggleComponent</c>.
3334
/// </remarks>
3435
[RegisterComponent, AutoGenerateComponentPause]
35-
[Access(typeof(HealthAnalyzerSystem), typeof(CryoPodSystem))]
36+
[Access(typeof(HealthAnalyzerSystem), typeof(CryoPodSystem), typeof(BodyScannerSystem))] // Funky: useful body scanners
3637
public sealed partial class HealthAnalyzerComponent : Component
3738
{
3839
/// <summary>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// SPDX-FileCopyrightText: 2025 mnva <218184747+mnva0@users.noreply.github.com>
2+
//
3+
// SPDX-License-Identifier: AGPL-3.0-or-later
4+
5+
using Content.Shared.DeviceLinking;
6+
using Robust.Shared.Prototypes;
7+
8+
namespace Content.Server.Medical;
9+
10+
[RegisterComponent]
11+
public sealed partial class BodyScannerComponent : Component
12+
{
13+
[DataField]
14+
public ProtoId<SinkPortPrototype> OperatingTablePort = "OperatingTableReceiver";
15+
16+
[DataField, AutoNetworkedField]
17+
public EntityUid? OperatingTable;
18+
}
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
// SPDX-FileCopyrightText: 2025 mnva <218184747+mnva0@users.noreply.github.com>
2+
//
3+
// SPDX-License-Identifier: AGPL-3.0-or-later
4+
5+
6+
using Content.Shared._Shitmed.Medical.Surgery;
7+
using Content.Shared.Buckle.Components;
8+
using Content.Shared.DeviceLinking.Events;
9+
using Content.Shared.UserInterface;
10+
using Content.Server.Medical.Components;
11+
using System.Linq;
12+
13+
namespace Content.Server.Medical;
14+
15+
public sealed partial class BodyScannerSystem : EntitySystem
16+
{
17+
public override void Initialize()
18+
{
19+
base.Initialize();
20+
21+
SubscribeLocalEvent<BodyScannerComponent, NewLinkEvent>(OnNewLink);
22+
SubscribeLocalEvent<BodyScannerComponent, PortDisconnectedEvent>(OnPortDisconnected);
23+
SubscribeLocalEvent<BodyScannerComponent, AfterActivatableUIOpenEvent>(OnActivateUI);
24+
}
25+
26+
private void SetPatient(Entity<BodyScannerComponent> ent, EntityUid patient)
27+
{
28+
if (TryComp<HealthAnalyzerComponent>(ent, out var healthAnalyzer))
29+
healthAnalyzer.ScannedEntity = patient;
30+
}
31+
32+
private void UnsetPatient(Entity<BodyScannerComponent> ent)
33+
{
34+
if (TryComp<HealthAnalyzerComponent>(ent, out var healthAnalyzer))
35+
healthAnalyzer.ScannedEntity = null;
36+
}
37+
38+
private void OnNewLink(Entity<BodyScannerComponent> ent, ref NewLinkEvent args)
39+
{
40+
if (args.SinkPort == ent.Comp.OperatingTablePort &&
41+
HasComp<OperatingTableComponent>(args.Source))
42+
{
43+
ent.Comp.OperatingTable = args.Source;
44+
}
45+
}
46+
47+
private void OnPortDisconnected(Entity<BodyScannerComponent> ent, ref PortDisconnectedEvent args)
48+
{
49+
if (args.Port != ent.Comp.OperatingTablePort)
50+
return;
51+
52+
ent.Comp.OperatingTable = null;
53+
UnsetPatient(ent);
54+
}
55+
56+
private void OnActivateUI(Entity<BodyScannerComponent> ent, ref AfterActivatableUIOpenEvent args)
57+
{
58+
if (!TryComp<StrapComponent>(ent.Comp.OperatingTable, out var strap))
59+
return;
60+
61+
var buckled = strap.BuckledEntities;
62+
if (buckled.Count == 0)
63+
UnsetPatient(ent);
64+
65+
var patient = buckled.FirstOrDefault();
66+
SetPatient(ent, patient);
67+
68+
69+
}
70+
}

Resources/Prototypes/Entities/Structures/Machines/Computers/computers.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,12 @@
9090
# SPDX-FileCopyrightText: 2024 lzk <124214523+lzk228@users.noreply.github.com>
9191
# SPDX-FileCopyrightText: 2024 metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
9292
# SPDX-FileCopyrightText: 2025 Kip <tfraser520@gmail.com>
93+
# SPDX-FileCopyrightText: 2025 Lyndomen <49795619+Lyndomen@users.noreply.github.com>
9394
# SPDX-FileCopyrightText: 2025 Mish <bluscout78@yahoo.com>
9495
# SPDX-FileCopyrightText: 2025 Tay <td12233a@gmail.com>
96+
# SPDX-FileCopyrightText: 2025 corresp0nd <46357632+corresp0nd@users.noreply.github.com>
9597
# SPDX-FileCopyrightText: 2025 jackel234 <52829582+jackel234@users.noreply.github.com>
98+
# SPDX-FileCopyrightText: 2025 mnva <218184747+mnva0@users.noreply.github.com>
9699
# SPDX-FileCopyrightText: 2025 pa.pecherskij <pa.pecherskij@interfax.ru>
97100
# SPDX-FileCopyrightText: 2025 pathetic meowmeow <uhhadd@gmail.com>
98101
# SPDX-FileCopyrightText: 2025 slarticodefast <161409025+slarticodefast@users.noreply.github.com>
@@ -789,6 +792,26 @@
789792
powerLoad: 500
790793
- type: Computer
791794
board: BodyScannerComputerCircuitboard
795+
# Funky: Functional body scanners
796+
- type: HealthAnalyzer
797+
scanDelay: 0
798+
- type: UserInterface
799+
interfaces:
800+
enum.HealthAnalyzerUiKey.Key:
801+
type: HealthAnalyzerBoundUserInterface
802+
- type: ActivatableUI
803+
key: enum.HealthAnalyzerUiKey.Key
804+
requiresComplex: false
805+
- type: ActivatableUIRequiresPower
806+
- type: DeviceList
807+
- type: DeviceNetwork
808+
deviceNetId: Wired
809+
receiveFrequencyId: BasicDevice
810+
- type: DeviceLinkSink
811+
ports:
812+
- OperatingTableReceiver
813+
- type: BodyScanner
814+
# End
792815
- type: PointLight
793816
radius: 1.5
794817
energy: 1.6

0 commit comments

Comments
 (0)