* small patch * fix * remove garbage * fix * moved to shared events * fix * LocId --------- Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
32 lines
1.0 KiB
C#
32 lines
1.0 KiB
C#
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);
|
|
}
|
|
}
|
|
}
|
|
|