Files
wwdpublic/Content.Shared/_White/Lockers/SharedStationAlertLevelLockSystem.cs
vanx b90965177f [Add] Alert Level Locks (#635)
* alert lock pog

* locale

* fix

* make it better

* count

* review

* review 2

---------

Co-authored-by: vanx <discord@vanxxxx>
2025-07-05 12:22:19 +10:00

31 lines
919 B
C#

using Content.Shared.Lock;
using Content.Shared.Popups;
namespace Content.Shared._White.Lockers;
public sealed class SharedStationAlertLevelLockSystem : EntitySystem
{
[Dependency] private readonly SharedPopupSystem _popup = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<StationAlertLevelLockComponent, LockToggleAttemptEvent>(OnTryAccess);
}
private void OnTryAccess(Entity<StationAlertLevelLockComponent> ent, ref LockToggleAttemptEvent args)
{
if (!TryComp<LockComponent>(ent.Owner, out var lockComponent))
return;
var locking = !lockComponent.Locked; // Allow locking
if (!ent.Comp.Enabled || !ent.Comp.Locked || locking)
return;
_popup.PopupClient(Loc.GetString("access-failed-wrong-station-alert-level"), ent.Owner, args.User);
args.Cancelled = true;
}
}