Skip to content

Commit

Permalink
move to UnrevivableComponent instead of husked
Browse files Browse the repository at this point in the history
- Move UnrevivableComponent to shared

- add Analyzable and ReasonMessage to UnrevivableComponent
to give granular control of the message and whether or not it shows up
in the analyzer

- remove the check for HuskedComponent in DefibrillatorSystem
  • Loading branch information
poklj committed Jan 31, 2025
1 parent ebcf385 commit 09e9071
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 20 deletions.
11 changes: 3 additions & 8 deletions Content.Server/Medical/DefibrillatorSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
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.Changeling.Devour;
using Content.Shared.Damage;
using Content.Shared.DoAfter;
Expand Down Expand Up @@ -194,14 +194,9 @@ public void Zap(EntityUid uid, EntityUid target, EntityUid user, DefibrillatorCo
_chatManager.TrySendInGameICMessage(uid, Loc.GetString("defibrillator-rotten"),
InGameICChatType.Speak, true);
}
else if (HasComp<UnrevivableComponent>(target))
else if (TryComp<UnrevivableComponent>(target, out var unrevivable))
{
_chatManager.TrySendInGameICMessage(uid, Loc.GetString("defibrillator-unrevivable"),
InGameICChatType.Speak, true);
}
else if (HasComp<ChangelingHuskedCorpseComponent>(target))
{
_chatManager.TrySendInGameICMessage(uid, Loc.GetString("changeling-defibrillator-failure"),
_chatManager.TrySendInGameICMessage(uid, Loc.GetString(unrevivable.ReasonMessage),
InGameICChatType.Speak, true);
}
else
Expand Down
4 changes: 2 additions & 2 deletions Content.Server/Medical/HealthAnalyzerSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
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;
Expand Down Expand Up @@ -207,7 +207,7 @@ public void UpdateScannedUser(EntityUid healthAnalyzer, EntityUid target, bool s
bleeding = bloodstream.BleedAmount > 0;
}

if (HasComp<UnrevivableComponent>(target))
if (TryComp<UnrevivableComponent>(target, out var unrevivableComp) && unrevivableComp.Analyzable)
unrevivable = true;

_uiSystem.ServerSendUiMessage(healthAnalyzer, HealthAnalyzerUiKey.Key, new HealthAnalyzerScannedUserMessage(
Expand Down
10 changes: 0 additions & 10 deletions Content.Server/Traits/Assorted/UnrevivableComponent.cs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
using Content.Shared.Mobs.Systems;
using Content.Shared.Nutrition.Components;
using Content.Shared.Popups;
using Content.Shared.Traits.Assorted;
using Content.Shared.Whitelist;
using Robust.Shared.Audio;
using Robust.Shared.Audio.Systems;
Expand Down Expand Up @@ -202,6 +203,10 @@ private void OnDevourConsume(Entity<ChangelingDevourComponent> ent, ref Changeli
_changelingIdentitySystem.CloneToNullspace((ent, identityStorage), target.Value);
EnsureComp<ChangelingHuskedCorpseComponent>(target.Value);

var unrevivable = EnsureComp<UnrevivableComponent>(target.Value);
unrevivable.Analyzable = false; // Remove the analyser text
unrevivable.ReasonMessage = "changeling-defibrillator-failure";

foreach (var organ in _bodySystem.GetBodyOrgans(target, body))
{
_entityManager.QueueDeleteEntity(organ.Id);
Expand Down
19 changes: 19 additions & 0 deletions Content.Shared/Traits/Assorted/UnrevivableComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
namespace Content.Shared.Traits.Assorted;

/// <summary>
/// This is used for the unrevivable trait.
/// </summary>
[RegisterComponent]
public sealed partial class UnrevivableComponent : Component
{
/// <summary>
/// A field to define if we should display the "Genetic incompatibility" warning on health analysers
/// </summary>
[DataField]
public bool Analyzable { get; set; } = true;

/// <summary>
/// The loc string used to provide a reason for being unrevivable
/// </summary>
public string ReasonMessage = "changeling-defibrillator-failure";
}

0 comments on commit 09e9071

Please sign in to comment.