Lock Anomaly generator to research access (#24464)

* small patch

* fix

* remove garbage

* fix

* moved to shared events

* fix

* LocId

---------

Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
This commit is contained in:
Ed
2024-02-01 11:45:24 +03:00
committed by GitHub
parent f3ff35dcfa
commit 498ad2d5d7
42 changed files with 142 additions and 92 deletions

View File

@@ -0,0 +1,31 @@
using Content.Shared.Popups;
using Content.Shared.UserInterface;
using Content.Shared.Access.Components;
namespace Content.Shared.Access.Systems;
public sealed class ActivatableUIRequiresAccessSystem : EntitySystem
{
[Dependency] private readonly AccessReaderSystem _access = default!;
[Dependency] private readonly SharedPopupSystem _popup = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<ActivatableUIRequiresAccessComponent, ActivatableUIOpenAttemptEvent>(OnUIOpenAttempt);
}
private void OnUIOpenAttempt(Entity<ActivatableUIRequiresAccessComponent> activatableUI, ref ActivatableUIOpenAttemptEvent args)
{
if (args.Cancelled)
return;
if (!_access.IsAllowed(args.User, activatableUI))
{
args.Cancel();
if (activatableUI.Comp.PopupMessage != null)
_popup.PopupClient(Loc.GetString(activatableUI.Comp.PopupMessage), activatableUI, args.User);
}
}
}