CatStation/Content.Shared/Power/EntitySystems/SharedActivatableUIRequiresPowerSystem.cs
slarticodefast 0552b28cf5
cleanup all popups on client and server (#44572)
* cleanup popups on client and server

* fix RDC BUI
2026-07-11 14:13:19 +00:00

23 lines
811 B
C#

using Content.Shared.Popups;
using Content.Shared.Power.Components;
using Content.Shared.UserInterface;
namespace Content.Shared.Power.EntitySystems;
public abstract partial class SharedActivatableUIRequiresPowerSystem : EntitySystem
{
[Dependency] private SharedPowerReceiverSystem _powerReceiver = default!;
[Dependency] private SharedPopupSystem _popup = default!;
[SubscribeLocalEvent]
protected void OnActivate(Entity<ActivatableUIRequiresPowerComponent> ent, ref ActivatableUIOpenAttemptEvent args)
{
if (args.Cancelled || _powerReceiver.IsPowered(ent.Owner))
return;
if (!args.Silent)
_popup.PopupEntity(Loc.GetString("base-computer-ui-component-not-powered", ("machine", ent.Owner)), args.User, args.User);
args.Cancel();
}
}