6
StarHorizon_Public/Content.Shared/Lock/LockingWhitelistSystem.cs
2025-11-12 10:55:00 +03:00

29 lines
920 B
C#

using Content.Shared.Popups;
using Content.Shared.Whitelist;
namespace Content.Shared.Lock;
public sealed class LockingWhitelistSystem : EntitySystem
{
[Dependency] private readonly EntityWhitelistSystem _whitelistSystem = default!;
[Dependency] private readonly SharedPopupSystem _popupSystem = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<LockingWhitelistComponent, UserLockToggleAttemptEvent>(OnUserLockToggleAttempt);
}
private void OnUserLockToggleAttempt(Entity<LockingWhitelistComponent> ent, ref UserLockToggleAttemptEvent args)
{
if (_whitelistSystem.CheckBoth(args.Target, ent.Comp.Blacklist, ent.Comp.Whitelist))
return;
if (!args.Silent)
_popupSystem.PopupClient(Loc.GetString("locking-whitelist-component-lock-toggle-deny"), ent.Owner);
args.Cancelled = true;
}
}