Fix cyborg locking (#21809)
* Fix cyborg locking * Revert "Fix cyborg locking" This reverts commit bd5bbbb8b46edb720a9d479772f7931f5f497907. * create generic component * update submodules * Revert "update submodules" This reverts commit 303200f298f1c56660955d13caa8218b02e306ad.
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
namespace Content.Server.Lock.Components;
|
||||
|
||||
/// <summary>
|
||||
/// This is used for activatable UIs that require the entity to have a lock in a certain state.
|
||||
/// </summary>
|
||||
[RegisterComponent]
|
||||
public sealed partial class ActivatableUIRequiresLockComponent : Component
|
||||
{
|
||||
/// <summary>
|
||||
/// TRUE: the lock must be locked to access the UI.
|
||||
/// FALSE: the lock must be unlocked to access the UI.
|
||||
/// </summary>
|
||||
[DataField("requireLocked"), ViewVariables(VVAccess.ReadWrite)]
|
||||
public bool requireLocked = false;
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
using Content.Server.Lock.Components;
|
||||
using Content.Server.Popups;
|
||||
using Content.Server.UserInterface;
|
||||
using Content.Shared.Lock;
|
||||
|
||||
namespace Content.Server.Lock.EntitySystems;
|
||||
public sealed class ActivatableUIRequiresLockSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly ActivatableUISystem _activatableUI = default!;
|
||||
[Dependency] private readonly PopupSystem _popupSystem = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
SubscribeLocalEvent<ActivatableUIRequiresLockComponent, ActivatableUIOpenAttemptEvent>(OnUIOpenAttempt);
|
||||
SubscribeLocalEvent<ActivatableUIRequiresLockComponent, LockToggledEvent>(LockToggled);
|
||||
}
|
||||
|
||||
private void OnUIOpenAttempt(EntityUid uid, ActivatableUIRequiresLockComponent component, ActivatableUIOpenAttemptEvent args)
|
||||
{
|
||||
if (args.Cancelled)
|
||||
return;
|
||||
|
||||
if (TryComp<LockComponent>(uid, out var lockComp) && lockComp.Locked != component.requireLocked)
|
||||
{
|
||||
args.Cancel();
|
||||
if (lockComp.Locked)
|
||||
_popupSystem.PopupEntity(Loc.GetString("entity-storage-component-locked-message"), uid, args.User);
|
||||
}
|
||||
}
|
||||
|
||||
private void LockToggled(EntityUid uid, ActivatableUIRequiresLockComponent component, LockToggledEvent args)
|
||||
{
|
||||
if (!TryComp<LockComponent>(uid, out var lockComp) || lockComp.Locked == component.requireLocked)
|
||||
return;
|
||||
|
||||
_activatableUI.CloseAll(uid);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -208,5 +208,6 @@
|
||||
- AllAccess
|
||||
- type: Lock
|
||||
locked: true
|
||||
- type: ActivatableUIRequiresLock
|
||||
- type: AccessReader
|
||||
access: [["Command"], ["Research"]]
|
||||
|
||||
Reference in New Issue
Block a user