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>
This commit is contained in:
Fildrance
2024-02-21 17:47:23 +03:00
committed by GitHub
parent a18e2c0547
commit ef849a0156
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. /// After scanning, retrieves the target Uid to use with its related UI.
/// </summary> /// </summary>
[RegisterComponent] [RegisterComponent]
[Access(typeof(HealthAnalyzerSystem))] [Access(typeof(HealthAnalyzerSystem), typeof(CryoPodSystem))]
public sealed partial class HealthAnalyzerComponent : Component public sealed partial class HealthAnalyzerComponent : Component
{ {
/// <summary> /// <summary>

View File

@@ -30,6 +30,7 @@ using Content.Shared.Medical.Cryogenics;
using Content.Shared.MedicalScanner; using Content.Shared.MedicalScanner;
using Content.Shared.Verbs; using Content.Shared.Verbs;
using Robust.Server.GameObjects; using Robust.Server.GameObjects;
using Robust.Shared.Containers;
using Robust.Shared.Timing; using Robust.Shared.Timing;
using SharedToolSystem = Content.Shared.Tools.Systems.SharedToolSystem; using SharedToolSystem = Content.Shared.Tools.Systems.SharedToolSystem;
@@ -71,6 +72,7 @@ public sealed partial class CryoPodSystem : SharedCryoPodSystem
SubscribeLocalEvent<CryoPodComponent, GasAnalyzerScanEvent>(OnGasAnalyzed); SubscribeLocalEvent<CryoPodComponent, GasAnalyzerScanEvent>(OnGasAnalyzed);
SubscribeLocalEvent<CryoPodComponent, ActivatableUIOpenAttemptEvent>(OnActivateUIAttempt); SubscribeLocalEvent<CryoPodComponent, ActivatableUIOpenAttemptEvent>(OnActivateUIAttempt);
SubscribeLocalEvent<CryoPodComponent, AfterActivatableUIOpenEvent>(OnActivateUI); SubscribeLocalEvent<CryoPodComponent, AfterActivatableUIOpenEvent>(OnActivateUI);
SubscribeLocalEvent<CryoPodComponent, EntRemovedFromContainerMessage>(OnEjected);
} }
public override void Update(float frameTime) 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<TemperatureComponent>(entity.Comp.BodyContainer.ContainedEntity, out var temp);
TryComp<BloodstreamComponent>(entity.Comp.BodyContainer.ContainedEntity, out var bloodstream); TryComp<BloodstreamComponent>(entity.Comp.BodyContainer.ContainedEntity, out var bloodstream);
if (TryComp<HealthAnalyzerComponent>(entity, out var healthAnalyzer))
{
healthAnalyzer.ScannedEntity = entity.Comp.BodyContainer.ContainedEntity;
}
_userInterfaceSystem.TrySendUiMessage( _userInterfaceSystem.TrySendUiMessage(
entity.Owner, entity.Owner,
HealthAnalyzerUiKey.Key, HealthAnalyzerUiKey.Key,
@@ -282,5 +289,16 @@ public sealed partial class CryoPodSystem : SharedCryoPodSystem
args.GasMixtures = gasMixDict; 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 #endregion
} }

View File

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