LockingWhitelistSystem.cs 920 B

12345678910111213141516171819202122232425262728
  1. using Content.Shared.Popups;
  2. using Content.Shared.Whitelist;
  3. namespace Content.Shared.Lock;
  4. public sealed class LockingWhitelistSystem : EntitySystem
  5. {
  6. [Dependency] private readonly EntityWhitelistSystem _whitelistSystem = default!;
  7. [Dependency] private readonly SharedPopupSystem _popupSystem = default!;
  8. public override void Initialize()
  9. {
  10. base.Initialize();
  11. SubscribeLocalEvent<LockingWhitelistComponent, UserLockToggleAttemptEvent>(OnUserLockToggleAttempt);
  12. }
  13. private void OnUserLockToggleAttempt(Entity<LockingWhitelistComponent> ent, ref UserLockToggleAttemptEvent args)
  14. {
  15. if (_whitelistSystem.CheckBoth(args.Target, ent.Comp.Blacklist, ent.Comp.Whitelist))
  16. return;
  17. if (!args.Silent)
  18. _popupSystem.PopupClient(Loc.GetString("locking-whitelist-component-lock-toggle-deny"), ent.Owner);
  19. args.Cancelled = true;
  20. }
  21. }