forked from space-wizards/space-station-14
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
prevent borgs unlocking eachother and robotics console (space-wizards…
…#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 * * 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 <[email protected]>
- Loading branch information
1 parent
b6811d3
commit 8f6326c
Showing
7 changed files
with
82 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using Content.Shared.Whitelist; | ||
using Robust.Shared.GameStates; | ||
|
||
namespace Content.Shared.Lock; | ||
|
||
/// <summary> | ||
/// Adds whitelist and blacklist for this mob to lock things. | ||
/// The whitelist and blacklist are checked against the object being locked, not the mob. | ||
/// </summary> | ||
[RegisterComponent, NetworkedComponent, Access(typeof(LockingWhitelistSystem))] | ||
public sealed partial class LockingWhitelistComponent : Component | ||
{ | ||
[DataField] | ||
public EntityWhitelist? Whitelist; | ||
|
||
[DataField] | ||
public EntityWhitelist? Blacklist; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
locking-whitelist-component-lock-toggle-deny = You can't toggle the lock. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters