prevent borgs unlocking eachother and robotics console (#27888)
* prevent borgs from using locks * e * bru * a * blacklist borgs and robotics console * frogro * add IsAllowed to EntityWhitelistSystem * use IsAllowed * move thing to new LockingWhitelistSystem * :trollface: * review * use renamed CheckBoth in locking whitelist * remove unused stuff and add more to doc * Use target entity instead to remove self check * Rename to _whitelistSystem * Add deny lock toggle popup * Prevent duplicate checks and popups * Fix wrong entity in popup when toggling another borg * Make new event * Update comment to user for new event --------- Co-authored-by: deltanedas <@deltanedas:kde.org> Co-authored-by: ShadowCommander <10494922+ShadowCommander@users.noreply.github.com>
This commit is contained in:
28
Content.Shared/Lock/LockingWhitelistSystem.cs
Normal file
28
Content.Shared/Lock/LockingWhitelistSystem.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user