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:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user