fix: #25102 cryo pod now uses health-analyzer system to update body state in UI (#25109)

* fix: cryo pod now uses health-analyzer system to update body state in UI

* refactor: use EntityEventRefHandler instead ComponentEventRefHandler in CryoPodComponent subscribe on EntRemovedFromContainerMessage

---------

Co-authored-by: pa.pecherskij <pa.pecherskij@interfax.ru>
(cherry picked from commit ef849a0156e52d93c3a3c3b03f30858b33400292)
This commit is contained in:
Fildrance 2024-02-21 17:47:23 +03:00 committed by Debug
parent 9338e0d12b
commit d0a55859df
No known key found for this signature in database
GPG Key ID: 271270A74EF9C350
3 changed files with 21 additions and 1 deletions

View File

@ -7,7 +7,7 @@ namespace Content.Server.Medical.Components;
/// After scanning, retrieves the target Uid to use with its related UI.
/// </summary>
[RegisterComponent]
[Access(typeof(HealthAnalyzerSystem))]
[Access(typeof(HealthAnalyzerSystem), typeof(CryoPodSystem))]
public sealed partial class HealthAnalyzerComponent : Component
{
/// <summary>

View File

@ -30,6 +30,7 @@ using Content.Shared.Medical.Cryogenics;
using Content.Shared.MedicalScanner;
using Content.Shared.Verbs;
using Robust.Server.GameObjects;
using Robust.Shared.Containers;
using Robust.Shared.Timing;
using SharedToolSystem = Content.Shared.Tools.Systems.SharedToolSystem;
@ -71,6 +72,7 @@ public sealed partial class CryoPodSystem : SharedCryoPodSystem
SubscribeLocalEvent<CryoPodComponent, GasAnalyzerScanEvent>(OnGasAnalyzed);
SubscribeLocalEvent<CryoPodComponent, ActivatableUIOpenAttemptEvent>(OnActivateUIAttempt);
SubscribeLocalEvent<CryoPodComponent, AfterActivatableUIOpenEvent>(OnActivateUI);
SubscribeLocalEvent<CryoPodComponent, EntRemovedFromContainerMessage>(OnEjected);
}
public override void Update(float frameTime)
@ -187,6 +189,11 @@ public sealed partial class CryoPodSystem : SharedCryoPodSystem
TryComp<TemperatureComponent>(entity.Comp.BodyContainer.ContainedEntity, out var temp);
TryComp<BloodstreamComponent>(entity.Comp.BodyContainer.ContainedEntity, out var bloodstream);
if (TryComp<HealthAnalyzerComponent>(entity, out var healthAnalyzer))
{
healthAnalyzer.ScannedEntity = entity.Comp.BodyContainer.ContainedEntity;
}
_userInterfaceSystem.TrySendUiMessage(
entity.Owner,
HealthAnalyzerUiKey.Key,
@ -282,5 +289,16 @@ public sealed partial class CryoPodSystem : SharedCryoPodSystem
args.GasMixtures = gasMixDict;
}
private void OnEjected(Entity<CryoPodComponent> cryoPod, ref EntRemovedFromContainerMessage args)
{
if (TryComp<HealthAnalyzerComponent>(cryoPod.Owner, out var healthAnalyzer))
{
healthAnalyzer.ScannedEntity = null;
}
// if body is ejected - no need to display health-analyzer
_uiSystem.TryCloseAll(cryoPod.Owner, HealthAnalyzerUiKey.Key);
}
#endregion
}

View File

@ -85,6 +85,8 @@
whitelist:
components:
- FitsInDispenser
- type: HealthAnalyzer
scanDelay: 0
- type: UserInterface
interfaces:
- key: enum.HealthAnalyzerUiKey.Key