Telecom server panel check (#14523)
This commit is contained in:
@@ -1,37 +1,38 @@
|
||||
using Content.Shared.Popups;
|
||||
using Content.Server.Power.Components;
|
||||
using Content.Server.UserInterface;
|
||||
using Content.Server.Wires;
|
||||
using JetBrains.Annotations;
|
||||
using Content.Shared.Wires;
|
||||
|
||||
namespace Content.Server.Power.EntitySystems
|
||||
namespace Content.Server.Power.EntitySystems;
|
||||
|
||||
[UsedImplicitly]
|
||||
internal sealed class ActivatableUIRequiresPowerSystem : EntitySystem
|
||||
{
|
||||
[UsedImplicitly]
|
||||
internal sealed class ActivatableUIRequiresPowerSystem : EntitySystem
|
||||
[Dependency] private readonly ActivatableUISystem _activatableUI = default!;
|
||||
[Dependency] private readonly SharedPopupSystem _popup = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
[Dependency] private readonly ActivatableUISystem _activatableUISystem = default!;
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
base.Initialize();
|
||||
|
||||
SubscribeLocalEvent<ActivatableUIRequiresPowerComponent, ActivatableUIOpenAttemptEvent>(OnActivate);
|
||||
SubscribeLocalEvent<ActivatableUIRequiresPowerComponent, PowerChangedEvent>(OnPowerChanged);
|
||||
}
|
||||
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;
|
||||
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 OnActivate(EntityUid uid, ActivatableUIRequiresPowerComponent component, ActivatableUIOpenAttemptEvent args)
|
||||
{
|
||||
if (args.Cancelled) return;
|
||||
if (this.IsPowered(uid, EntityManager)) return;
|
||||
if (TryComp<WiresPanelComponent>(uid, out var panel) && panel.Open)
|
||||
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)
|
||||
_activatableUISystem.CloseAll(uid);
|
||||
}
|
||||
private void OnPowerChanged(EntityUid uid, ActivatableUIRequiresPowerComponent component, ref PowerChangedEvent args)
|
||||
{
|
||||
if (!args.Powered)
|
||||
_activatableUI.CloseAll(uid);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user