mirror of
https://github.com/WWhiteDreamProject/wwdpublic.git
synced 2026-04-17 05:27:38 +03:00
* alert lock pog * locale * fix * make it better * count * review * review 2 --------- Co-authored-by: vanx <discord@vanxxxx>
31 lines
919 B
C#
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;
|
|
}
|
|
}
|