* Chem master * Drone support for handhelds * Vending machines, scanners * Cloners, R&D computers * make research a little less sussy * Unfuck wires * PA control computer * Unfuck merge * Clean up git gore for good * Disposals * Microwaves * paper * Magic mirror * More vendors for drones * Solar computer whitelist * EFR review updates
40 lines
1.5 KiB
C#
40 lines
1.5 KiB
C#
using Content.Shared.Popups;
|
|
using Content.Server.Power.Components;
|
|
using Content.Server.UserInterface;
|
|
using Content.Server.WireHacking;
|
|
using JetBrains.Annotations;
|
|
|
|
namespace Content.Server.Power.EntitySystems
|
|
{
|
|
[UsedImplicitly]
|
|
internal sealed class ActivatableUIRequiresPowerSystem : EntitySystem
|
|
{
|
|
[Dependency] private readonly ActivatableUISystem _activatableUISystem = 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 (EntityManager.TryGetComponent<ApcPowerReceiverComponent>(uid, out var power) && !power.Powered)
|
|
{
|
|
if (TryComp<WiresComponent>(uid, out var wires) && wires.IsPanelOpen)
|
|
return;
|
|
args.User.PopupMessageCursor(Loc.GetString("base-computer-ui-component-not-powered", ("machine", uid)));
|
|
args.Cancel();
|
|
}
|
|
}
|
|
|
|
private void OnPowerChanged(EntityUid uid, ActivatableUIRequiresPowerComponent component, PowerChangedEvent args)
|
|
{
|
|
if (!args.Powered)
|
|
_activatableUISystem.CloseAll(uid);
|
|
}
|
|
}
|
|
}
|