mirror of
https://github.com/WWhiteDreamProject/wwdpublic.git
synced 2026-04-19 14:38:36 +03:00
Predict ActivatableUIRequiresPower (#28405)
A lot of BUIs aren't going to handle the state coming in cleanly but we can fix em as we find em. (cherry picked from commit e4a5f2a1450d226bf281e46f1323f41213707bb6)
This commit is contained in:
@@ -1,32 +1,34 @@
|
||||
using Content.Shared.Popups;
|
||||
using Content.Server.Power.Components;
|
||||
using Content.Shared.Power;
|
||||
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 : EntitySystem
|
||||
public sealed class ActivatableUIRequiresPowerSystem : SharedActivatableUIRequiresPowerSystem
|
||||
{
|
||||
[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)
|
||||
protected override void OnActivate(Entity<ActivatableUIRequiresPowerComponent> ent, ref ActivatableUIOpenAttemptEvent args)
|
||||
{
|
||||
if (args.Cancelled) return;
|
||||
if (this.IsPowered(uid, EntityManager)) return;
|
||||
if (TryComp<WiresPanelComponent>(uid, out var panel) && panel.Open)
|
||||
if (args.Cancelled || this.IsPowered(ent.Owner, EntityManager))
|
||||
{
|
||||
return;
|
||||
_popup.PopupCursor(Loc.GetString("base-computer-ui-component-not-powered", ("machine", uid)), args.User);
|
||||
}
|
||||
|
||||
if (TryComp<WiresPanelComponent>(ent.Owner, out var panel) && panel.Open)
|
||||
return;
|
||||
|
||||
args.Cancel();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user