using Content.Server.Power.Components; using Content.Shared.Power.Components; using Content.Shared.Power.EntitySystems; using Content.Shared.UserInterface; using Content.Shared.Wires; using ActivatableUISystem = Content.Shared.UserInterface.ActivatableUISystem; namespace Content.Server.Power.EntitySystems; public sealed class ActivatableUIRequiresPowerSystem : SharedActivatableUIRequiresPowerSystem { [Dependency] private readonly ActivatableUISystem _activatableUI = default!; public override void Initialize() { base.Initialize(); SubscribeLocalEvent(OnPowerChanged); } protected override void OnActivate(Entity ent, ref ActivatableUIOpenAttemptEvent args) { if (args.Cancelled || this.IsPowered(ent.Owner, EntityManager)) { return; } if (TryComp(ent.Owner, out var panel) && panel.Open) return; args.Cancel(); } private void OnPowerChanged(EntityUid uid, ActivatableUIRequiresPowerComponent component, ref PowerChangedEvent args) { if (!args.Powered) _activatableUI.CloseAll(uid); } }