Files
OldThink/Content.Server/Power/EntitySystems/ActivatableUIRequiresPowerSystem.cs
Aviu00 13c6888eeb Фиксы (#508)
* Fix cult blindfold

* Add stamina resistances

* Energy bolt is energy

* Laser shield is anti-laser

* Cult blindfold welding protection

* Eject id cards on deconstruct

* Wires panel power fix

* Add markings for species

* Ebow gaming
2024-01-25 11:12:03 +03:00

37 lines
1.3 KiB
C#

using Content.Shared.Popups;
using Content.Server.Power.Components;
using Content.Server.UserInterface;
using JetBrains.Annotations;
using Content.Shared.Wires;
namespace Content.Server.Power.EntitySystems;
[UsedImplicitly]
internal sealed class ActivatableUIRequiresPowerSystem : EntitySystem
{
[Dependency] private readonly ActivatableUISystem _activatableUI = default!;
[Dependency] private readonly SharedPopupSystem _popup = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<ActivatableUIRequiresPowerComponent, ActivatableUIOpenAttemptEvent>(OnActivate);
SubscribeLocalEvent<ActivatableUIRequiresPowerComponent, PowerChangedEvent>(OnPowerChanged);
}
private void OnActivate(EntityUid uid, ActivatableUIRequiresPowerComponent component, ActivatableUIOpenAttemptEvent args)
{
if (args.Cancelled) return;
if (this.IsPowered(uid, EntityManager)) return;
_popup.PopupCursor(Loc.GetString("base-computer-ui-component-not-powered", ("machine", uid)), args.User);
args.Cancel();
}
private void OnPowerChanged(EntityUid uid, ActivatableUIRequiresPowerComponent component, ref PowerChangedEvent args)
{
if (!args.Powered)
_activatableUI.CloseAll(uid);
}
}