mirror of
https://github.com/DeltaV-Station/Delta-v.git
synced 2026-09-30 16:17:27 +00:00
* Content update for UI refactor
* Big update
* Sharing
* Remaining content updates
* First big update
* Prototype updates
* AUGH
* Fix UI comp ref
* Cleanup
- Fix predicted message, fix item slots, fix interaction range check.
* Fix regressions
* Make this predictive
idk why it wasn't.
* Fix slime merge
* Merge conflict
* Fix merge
(cherry picked from commit 5896e68752)
44 lines
1.5 KiB
C#
44 lines
1.5 KiB
C#
using Content.Server.Lock.Components;
|
|
using Content.Server.Popups;
|
|
using Content.Shared.UserInterface;
|
|
using Content.Shared.Lock;
|
|
using Content.Server.UserInterface;
|
|
using ActivatableUISystem = Content.Shared.UserInterface.ActivatableUISystem;
|
|
|
|
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);
|
|
}
|
|
}
|
|
|