From a95c8baf28f34ff34d65b6145b47d0cc88662b67 Mon Sep 17 00:00:00 2001 From: Saphire Lattice Date: Sun, 27 Oct 2024 00:22:08 +0700 Subject: [PATCH] Add health analyzer unrevivability warning (#32636) * Add health analyzer unrevivability warning * Remove errornous comment --- .../UI/HealthAnalyzerWindow.xaml | 3 +-- .../UI/HealthAnalyzerWindow.xaml.cs | 25 +++++++++++++------ Content.Server/Medical/CryoPodSystem.cs | 1 + .../Medical/HealthAnalyzerSystem.cs | 8 +++++- .../HealthAnalyzerScannedUserMessage.cs | 4 ++- .../components/health-analyzer-component.ftl | 3 ++- 6 files changed, 32 insertions(+), 12 deletions(-) diff --git a/Content.Client/HealthAnalyzer/UI/HealthAnalyzerWindow.xaml b/Content.Client/HealthAnalyzer/UI/HealthAnalyzerWindow.xaml index 19d00a0bbf..aae8785b1f 100644 --- a/Content.Client/HealthAnalyzer/UI/HealthAnalyzerWindow.xaml +++ b/Content.Client/HealthAnalyzer/UI/HealthAnalyzerWindow.xaml @@ -47,8 +47,7 @@ - + diff --git a/Content.Client/HealthAnalyzer/UI/HealthAnalyzerWindow.xaml.cs b/Content.Client/HealthAnalyzer/UI/HealthAnalyzerWindow.xaml.cs index d61267d002..fd3615d59f 100644 --- a/Content.Client/HealthAnalyzer/UI/HealthAnalyzerWindow.xaml.cs +++ b/Content.Client/HealthAnalyzer/UI/HealthAnalyzerWindow.xaml.cs @@ -110,18 +110,29 @@ namespace Content.Client.HealthAnalyzer.UI // Alerts - AlertsDivider.Visible = msg.Bleeding == true; - AlertsContainer.Visible = msg.Bleeding == true; + var showAlerts = msg.Unrevivable == true || msg.Bleeding == true; + + AlertsDivider.Visible = showAlerts; + AlertsContainer.Visible = showAlerts; + + if (showAlerts) + AlertsContainer.DisposeAllChildren(); + + if (msg.Unrevivable == true) + AlertsContainer.AddChild(new RichTextLabel + { + Text = Loc.GetString("health-analyzer-window-entity-unrevivable-text"), + Margin = new Thickness(0, 4), + MaxWidth = 300 + }); if (msg.Bleeding == true) - { - AlertsContainer.DisposeAllChildren(); - AlertsContainer.AddChild(new Label + AlertsContainer.AddChild(new RichTextLabel { Text = Loc.GetString("health-analyzer-window-entity-bleeding-text"), - FontColorOverride = Color.Red, + Margin = new Thickness(0, 4), + MaxWidth = 300 }); - } // Damage Groups diff --git a/Content.Server/Medical/CryoPodSystem.cs b/Content.Server/Medical/CryoPodSystem.cs index fc9ab081d2..15fe2a69cf 100644 --- a/Content.Server/Medical/CryoPodSystem.cs +++ b/Content.Server/Medical/CryoPodSystem.cs @@ -201,6 +201,7 @@ public sealed partial class CryoPodSystem : SharedCryoPodSystem ? bloodSolution.FillFraction : 0, null, + null, null )); } diff --git a/Content.Server/Medical/HealthAnalyzerSystem.cs b/Content.Server/Medical/HealthAnalyzerSystem.cs index 60a492a755..90646725bb 100644 --- a/Content.Server/Medical/HealthAnalyzerSystem.cs +++ b/Content.Server/Medical/HealthAnalyzerSystem.cs @@ -2,6 +2,7 @@ using Content.Server.Body.Components; using Content.Server.Medical.Components; using Content.Server.PowerCell; using Content.Server.Temperature.Components; +using Content.Server.Traits.Assorted; using Content.Shared.Chemistry.EntitySystems; using Content.Shared.Damage; using Content.Shared.DoAfter; @@ -196,6 +197,7 @@ public sealed class HealthAnalyzerSystem : EntitySystem var bloodAmount = float.NaN; var bleeding = false; + var unrevivable = false; if (TryComp(target, out var bloodstream) && _solutionContainerSystem.ResolveSolution(target, bloodstream.BloodSolutionName, @@ -205,12 +207,16 @@ public sealed class HealthAnalyzerSystem : EntitySystem bleeding = bloodstream.BleedAmount > 0; } + if (HasComp(target)) + unrevivable = true; + _uiSystem.ServerSendUiMessage(healthAnalyzer, HealthAnalyzerUiKey.Key, new HealthAnalyzerScannedUserMessage( GetNetEntity(target), bodyTemperature, bloodAmount, scanMode, - bleeding + bleeding, + unrevivable )); } } diff --git a/Content.Shared/MedicalScanner/HealthAnalyzerScannedUserMessage.cs b/Content.Shared/MedicalScanner/HealthAnalyzerScannedUserMessage.cs index 78f26ed5c0..08af1a36a7 100644 --- a/Content.Shared/MedicalScanner/HealthAnalyzerScannedUserMessage.cs +++ b/Content.Shared/MedicalScanner/HealthAnalyzerScannedUserMessage.cs @@ -13,14 +13,16 @@ public sealed class HealthAnalyzerScannedUserMessage : BoundUserInterfaceMessage public float BloodLevel; public bool? ScanMode; public bool? Bleeding; + public bool? Unrevivable; - public HealthAnalyzerScannedUserMessage(NetEntity? targetEntity, float temperature, float bloodLevel, bool? scanMode, bool? bleeding) + public HealthAnalyzerScannedUserMessage(NetEntity? targetEntity, float temperature, float bloodLevel, bool? scanMode, bool? bleeding, bool? unrevivable) { TargetEntity = targetEntity; Temperature = temperature; BloodLevel = bloodLevel; ScanMode = scanMode; Bleeding = bleeding; + Unrevivable = unrevivable; } } diff --git a/Resources/Locale/en-US/medical/components/health-analyzer-component.ftl b/Resources/Locale/en-US/medical/components/health-analyzer-component.ftl index fe1f92e914..eb79358ecc 100644 --- a/Resources/Locale/en-US/medical/components/health-analyzer-component.ftl +++ b/Resources/Locale/en-US/medical/components/health-analyzer-component.ftl @@ -15,7 +15,8 @@ health-analyzer-window-entity-damage-total-text = Total Damage: health-analyzer-window-damage-group-text = {$damageGroup}: {$amount} health-analyzer-window-damage-type-text = {$damageType}: {$amount} -health-analyzer-window-entity-bleeding-text = Patient is bleeding! +health-analyzer-window-entity-unrevivable-text = [color=red]Unique body composition detected! Patient can not be resuscitated by normal means![/color] +health-analyzer-window-entity-bleeding-text = [color=red]Patient is bleeding![/color] health-analyzer-window-scan-mode-text = Scan Mode: health-analyzer-window-scan-mode-active = Active