CatStation/Content.Shared/Eye/Blinding/Systems/ActivatableUIRequiresVisionSystem.cs
Whatstone a88d2c5164
Cleanup: Resolve remaining PopupSystem warnings in Content.Shared (#44685)
* PopupClient to PopupEntity/Coordinates

* PopupPredictedX to PopupEntity/Cursor/Coordinates

* The rest of the damn owl

* nullability fixes

* Buckle cleanup

* cleanup, address PR comments

* ExecutionSystem: one popup method

* correct my filthy lies

* Apply most of ajcm's suggestions

* return user to SharedItemRecallSystem.cs

* Fix lingering Ensnarable broadcast popups

* targeted drain popups

* fix lingering untargeted Guardian popups

I read the comment on GuardianHostRecall.  Oops.

* target stethoscope popups

* fix the PDA vibration popup

* Fix target for encryption key removal popup

* anomaly scanner: args.User, not uid

* disposal unit comment, bcast pda vibration popup
2026-07-16 21:54:33 +00:00

53 lines
1.8 KiB
C#

using Content.Shared.UserInterface;
using Content.Shared.Eye.Blinding.Components;
using Content.Shared.Popups;
using Robust.Shared.Collections;
namespace Content.Shared.Eye.Blinding.Systems;
public sealed partial class ActivatableUIRequiresVisionSystem : EntitySystem
{
[Dependency] private SharedPopupSystem _popupSystem = default!;
[Dependency] private SharedUserInterfaceSystem _userInterfaceSystem = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<ActivatableUIRequiresVisionComponent, ActivatableUIOpenAttemptEvent>(OnOpenAttempt);
SubscribeLocalEvent<BlindableComponent, BlindnessChangedEvent>(OnBlindnessChanged);
}
private void OnOpenAttempt(EntityUid uid, ActivatableUIRequiresVisionComponent component, ActivatableUIOpenAttemptEvent args)
{
if (args.Cancelled)
return;
if (TryComp<BlindableComponent>(args.User, out var blindable) && blindable.IsBlind)
{
if (!args.Silent)
_popupSystem.PopupEntity(Loc.GetString("blindness-fail-attempt"), args.User, args.User, PopupType.MediumCaution);
args.Cancel();
}
}
private void OnBlindnessChanged(EntityUid uid, BlindableComponent component, ref BlindnessChangedEvent args)
{
if (!args.Blind)
return;
var toClose = new ValueList<(EntityUid Entity, Enum Key)>();
foreach (var bui in _userInterfaceSystem.GetActorUis(uid))
{
if (HasComp<ActivatableUIRequiresVisionComponent>(bui.Entity))
{
toClose.Add(bui);
}
}
foreach (var bui in toClose)
{
_userInterfaceSystem.CloseUi(bui.Entity, bui.Key, uid);
}
}
}