From 6cb30b309215a751b192cc80c4061f0bbe0abfbd Mon Sep 17 00:00:00 2001 From: Zachary Higgs Date: Sun, 9 Feb 2025 19:16:21 -0400 Subject: [PATCH] Make UnrevivableComponent shared, give the component reason messages and if it shows up on the analyzer (#35013) * Make UnrevivableComponent shared - Move UnrevivableComponent to shared - add reason messages and if the status shows up in a health analyzer * Update Content.Shared/Traits/Assorted/UnrevivableComponent.cs Co-authored-by: Tayrtahn * Make UnrevivableComponent networked * Update Content.Shared/Traits/Assorted/UnrevivableComponent.cs Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com> --------- Co-authored-by: Tayrtahn Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com> --- Content.Server/Medical/DefibrillatorSystem.cs | 6 ++--- .../Medical/HealthAnalyzerSystem.cs | 4 ++-- .../Traits/Assorted/UnrevivableComponent.cs | 10 --------- .../Traits/Assorted/UnrevivableComponent.cs | 22 +++++++++++++++++++ 4 files changed, 27 insertions(+), 15 deletions(-) delete mode 100644 Content.Server/Traits/Assorted/UnrevivableComponent.cs create mode 100644 Content.Shared/Traits/Assorted/UnrevivableComponent.cs diff --git a/Content.Server/Medical/DefibrillatorSystem.cs b/Content.Server/Medical/DefibrillatorSystem.cs index 6bd563101b..ba272c92f5 100644 --- a/Content.Server/Medical/DefibrillatorSystem.cs +++ b/Content.Server/Medical/DefibrillatorSystem.cs @@ -6,7 +6,7 @@ using Content.Server.EUI; using Content.Server.Ghost; using Content.Server.Popups; using Content.Server.PowerCell; -using Content.Server.Traits.Assorted; +using Content.Shared.Traits.Assorted; using Content.Shared.Damage; using Content.Shared.DoAfter; using Content.Shared.Interaction; @@ -193,9 +193,9 @@ public sealed class DefibrillatorSystem : EntitySystem _chatManager.TrySendInGameICMessage(uid, Loc.GetString("defibrillator-rotten"), InGameICChatType.Speak, true); } - else if (HasComp(target)) + else if (TryComp(target, out var unrevivable)) { - _chatManager.TrySendInGameICMessage(uid, Loc.GetString("defibrillator-unrevivable"), + _chatManager.TrySendInGameICMessage(uid, Loc.GetString(unrevivable.ReasonMessage), InGameICChatType.Speak, true); } else diff --git a/Content.Server/Medical/HealthAnalyzerSystem.cs b/Content.Server/Medical/HealthAnalyzerSystem.cs index 90646725bb..9f8ee92e3d 100644 --- a/Content.Server/Medical/HealthAnalyzerSystem.cs +++ b/Content.Server/Medical/HealthAnalyzerSystem.cs @@ -2,7 +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.Traits.Assorted; using Content.Shared.Chemistry.EntitySystems; using Content.Shared.Damage; using Content.Shared.DoAfter; @@ -207,7 +207,7 @@ public sealed class HealthAnalyzerSystem : EntitySystem bleeding = bloodstream.BleedAmount > 0; } - if (HasComp(target)) + if (TryComp(target, out var unrevivableComp) && unrevivableComp.Analyzable) unrevivable = true; _uiSystem.ServerSendUiMessage(healthAnalyzer, HealthAnalyzerUiKey.Key, new HealthAnalyzerScannedUserMessage( diff --git a/Content.Server/Traits/Assorted/UnrevivableComponent.cs b/Content.Server/Traits/Assorted/UnrevivableComponent.cs deleted file mode 100644 index b95c922d54..0000000000 --- a/Content.Server/Traits/Assorted/UnrevivableComponent.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace Content.Server.Traits.Assorted; - -/// -/// This is used for the urevivable trait. -/// -[RegisterComponent] -public sealed partial class UnrevivableComponent : Component -{ - -} diff --git a/Content.Shared/Traits/Assorted/UnrevivableComponent.cs b/Content.Shared/Traits/Assorted/UnrevivableComponent.cs new file mode 100644 index 0000000000..19b4cac5e0 --- /dev/null +++ b/Content.Shared/Traits/Assorted/UnrevivableComponent.cs @@ -0,0 +1,22 @@ +using Robust.Shared.GameStates; + +namespace Content.Shared.Traits.Assorted; + +/// +/// This is used for the unrevivable trait as well as generally preventing revival. +/// +[RegisterComponent, NetworkedComponent, AutoGenerateComponentState] +public sealed partial class UnrevivableComponent : Component +{ + /// + /// A field to define if we should display the "Genetic incompatibility" warning on health analysers + /// + [DataField, AutoNetworkedField] + public bool Analyzable = true; + + /// + /// The loc string used to provide a reason for being unrevivable + /// + [DataField, AutoNetworkedField] + public LocId ReasonMessage = "defibrillator-unrevivable"; +}