Predict ExamineEvent for CryoPodSystem. (#39322)

commit
This commit is contained in:
Kyle Tyo
2025-08-01 15:38:39 -04:00
committed by GitHub
parent d805704a1f
commit a99615992a
2 changed files with 22 additions and 17 deletions

View File

@@ -68,7 +68,6 @@ public sealed partial class CryoPodSystem : SharedCryoPodSystem
SubscribeLocalEvent<CryoPodComponent, AtmosDeviceUpdateEvent>(OnCryoPodUpdateAtmosphere); SubscribeLocalEvent<CryoPodComponent, AtmosDeviceUpdateEvent>(OnCryoPodUpdateAtmosphere);
SubscribeLocalEvent<CryoPodComponent, DragDropTargetEvent>(HandleDragDropOn); SubscribeLocalEvent<CryoPodComponent, DragDropTargetEvent>(HandleDragDropOn);
SubscribeLocalEvent<CryoPodComponent, InteractUsingEvent>(OnInteractUsing); SubscribeLocalEvent<CryoPodComponent, InteractUsingEvent>(OnInteractUsing);
SubscribeLocalEvent<CryoPodComponent, ExaminedEvent>(OnExamined);
SubscribeLocalEvent<CryoPodComponent, PowerChangedEvent>(OnPowerChanged); SubscribeLocalEvent<CryoPodComponent, PowerChangedEvent>(OnPowerChanged);
SubscribeLocalEvent<CryoPodComponent, GasAnalyzerScanEvent>(OnGasAnalyzed); SubscribeLocalEvent<CryoPodComponent, GasAnalyzerScanEvent>(OnGasAnalyzed);
SubscribeLocalEvent<CryoPodComponent, ActivatableUIOpenAttemptEvent>(OnActivateUIAttempt); SubscribeLocalEvent<CryoPodComponent, ActivatableUIOpenAttemptEvent>(OnActivateUIAttempt);
@@ -218,22 +217,6 @@ public sealed partial class CryoPodSystem : SharedCryoPodSystem
args.Handled = _toolSystem.UseTool(args.Used, args.User, entity.Owner, entity.Comp.PryDelay, PryingQuality, new CryoPodPryFinished()); args.Handled = _toolSystem.UseTool(args.Used, args.User, entity.Owner, entity.Comp.PryDelay, PryingQuality, new CryoPodPryFinished());
} }
private void OnExamined(Entity<CryoPodComponent> entity, ref ExaminedEvent args)
{
var container = _itemSlotsSystem.GetItemOrNull(entity.Owner, entity.Comp.SolutionContainerName);
if (args.IsInDetailsRange && container != null && _solutionContainerSystem.TryGetFitsInDispenser(container.Value, out _, out var containerSolution))
{
using (args.PushGroup(nameof(CryoPodComponent)))
{
args.PushMarkup(Loc.GetString("cryo-pod-examine", ("beaker", Name(container.Value))));
if (containerSolution.Volume == 0)
{
args.PushMarkup(Loc.GetString("cryo-pod-empty-beaker"));
}
}
}
}
private void OnPowerChanged(Entity<CryoPodComponent> entity, ref PowerChangedEvent args) private void OnPowerChanged(Entity<CryoPodComponent> entity, ref PowerChangedEvent args)
{ {
// Needed to avoid adding/removing components on a deleted entity // Needed to avoid adding/removing components on a deleted entity

View File

@@ -1,9 +1,12 @@
using Content.Shared.Administration.Logs; using Content.Shared.Administration.Logs;
using Content.Shared.Body.Components; using Content.Shared.Body.Components;
using Content.Shared.Chemistry.EntitySystems;
using Content.Shared.Containers.ItemSlots;
using Content.Shared.Database; using Content.Shared.Database;
using Content.Shared.DoAfter; using Content.Shared.DoAfter;
using Content.Shared.DragDrop; using Content.Shared.DragDrop;
using Content.Shared.Emag.Systems; using Content.Shared.Emag.Systems;
using Content.Shared.Examine;
using Content.Shared.Mobs.Components; using Content.Shared.Mobs.Components;
using Content.Shared.Mobs.Systems; using Content.Shared.Mobs.Systems;
using Content.Shared.Popups; using Content.Shared.Popups;
@@ -20,10 +23,12 @@ public abstract partial class SharedCryoPodSystem: EntitySystem
[Dependency] private readonly SharedAppearanceSystem _appearanceSystem = default!; [Dependency] private readonly SharedAppearanceSystem _appearanceSystem = default!;
[Dependency] private readonly StandingStateSystem _standingStateSystem = default!; [Dependency] private readonly StandingStateSystem _standingStateSystem = default!;
[Dependency] private readonly EmagSystem _emag = default!; [Dependency] private readonly EmagSystem _emag = default!;
[Dependency] private readonly ItemSlotsSystem _itemSlotsSystem = default!;
[Dependency] private readonly MobStateSystem _mobStateSystem = default!; [Dependency] private readonly MobStateSystem _mobStateSystem = default!;
[Dependency] private readonly SharedPopupSystem _popupSystem = default!; [Dependency] private readonly SharedPopupSystem _popupSystem = default!;
[Dependency] private readonly SharedContainerSystem _containerSystem = default!; [Dependency] private readonly SharedContainerSystem _containerSystem = default!;
[Dependency] private readonly SharedPointLightSystem _light = default!; [Dependency] private readonly SharedPointLightSystem _light = default!;
[Dependency] private readonly SharedSolutionContainerSystem _solutionContainerSystem = default!;
[Dependency] private readonly ISharedAdminLogManager _adminLogger = default!; [Dependency] private readonly ISharedAdminLogManager _adminLogger = default!;
public override void Initialize() public override void Initialize()
@@ -31,9 +36,26 @@ public abstract partial class SharedCryoPodSystem: EntitySystem
base.Initialize(); base.Initialize();
SubscribeLocalEvent<CryoPodComponent, CanDropTargetEvent>(OnCryoPodCanDropOn); SubscribeLocalEvent<CryoPodComponent, CanDropTargetEvent>(OnCryoPodCanDropOn);
SubscribeLocalEvent<CryoPodComponent, ExaminedEvent>(OnExamined);
InitializeInsideCryoPod(); InitializeInsideCryoPod();
} }
private void OnExamined(Entity<CryoPodComponent> entity, ref ExaminedEvent args)
{
var container = _itemSlotsSystem.GetItemOrNull(entity.Owner, entity.Comp.SolutionContainerName);
if (args.IsInDetailsRange && container != null && _solutionContainerSystem.TryGetFitsInDispenser(container.Value, out _, out var containerSolution))
{
using (args.PushGroup(nameof(CryoPodComponent)))
{
args.PushMarkup(Loc.GetString("cryo-pod-examine", ("beaker", Name(container.Value))));
if (containerSolution.Volume == 0)
{
args.PushMarkup(Loc.GetString("cryo-pod-empty-beaker"));
}
}
}
}
private void OnCryoPodCanDropOn(EntityUid uid, CryoPodComponent component, ref CanDropTargetEvent args) private void OnCryoPodCanDropOn(EntityUid uid, CryoPodComponent component, ref CanDropTargetEvent args)
{ {
if (args.Handled) if (args.Handled)