2023-06-01 02:23:35 +12:00
|
|
|
using Content.Shared.Doors.Components;
|
|
|
|
|
using Content.Shared.Popups;
|
2023-09-28 11:34:21 +00:00
|
|
|
using Content.Shared.Prying.Components;
|
2023-11-27 22:12:34 +11:00
|
|
|
using Robust.Shared.Audio;
|
|
|
|
|
using Robust.Shared.Audio.Systems;
|
2023-06-01 02:23:35 +12:00
|
|
|
|
|
|
|
|
namespace Content.Shared.Doors.Systems;
|
|
|
|
|
|
|
|
|
|
public abstract class SharedDoorBoltSystem : EntitySystem
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
[Dependency] protected readonly SharedAppearanceSystem Appearance = default!;
|
|
|
|
|
[Dependency] protected readonly SharedAudioSystem Audio = default!;
|
2023-08-11 21:29:33 +12:00
|
|
|
[Dependency] protected readonly SharedPopupSystem Popup = default!;
|
2023-06-01 02:23:35 +12:00
|
|
|
public override void Initialize()
|
|
|
|
|
{
|
|
|
|
|
base.Initialize();
|
|
|
|
|
|
|
|
|
|
SubscribeLocalEvent<DoorBoltComponent, BeforeDoorOpenedEvent>(OnBeforeDoorOpened);
|
|
|
|
|
SubscribeLocalEvent<DoorBoltComponent, BeforeDoorClosedEvent>(OnBeforeDoorClosed);
|
|
|
|
|
SubscribeLocalEvent<DoorBoltComponent, BeforeDoorDeniedEvent>(OnBeforeDoorDenied);
|
2023-09-28 11:34:21 +00:00
|
|
|
SubscribeLocalEvent<DoorBoltComponent, BeforePryEvent>(OnDoorPry);
|
2023-06-01 02:23:35 +12:00
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2023-09-28 11:34:21 +00:00
|
|
|
private void OnDoorPry(EntityUid uid, DoorBoltComponent component, ref BeforePryEvent args)
|
2023-06-01 02:23:35 +12:00
|
|
|
{
|
2023-10-27 02:26:52 +00:00
|
|
|
if (args.Cancelled)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (!component.BoltsDown || args.Force)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
args.Message = "airlock-component-cannot-pry-is-bolted-message";
|
|
|
|
|
|
|
|
|
|
args.Cancelled = true;
|
2023-06-01 02:23:35 +12:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnBeforeDoorOpened(EntityUid uid, DoorBoltComponent component, BeforeDoorOpenedEvent args)
|
|
|
|
|
{
|
|
|
|
|
if (component.BoltsDown)
|
|
|
|
|
args.Cancel();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnBeforeDoorClosed(EntityUid uid, DoorBoltComponent component, BeforeDoorClosedEvent args)
|
|
|
|
|
{
|
|
|
|
|
if (component.BoltsDown)
|
|
|
|
|
args.Cancel();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnBeforeDoorDenied(EntityUid uid, DoorBoltComponent component, BeforeDoorDeniedEvent args)
|
|
|
|
|
{
|
|
|
|
|
if (component.BoltsDown)
|
|
|
|
|
args.Cancel();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void SetBoltWireCut(DoorBoltComponent component, bool value)
|
|
|
|
|
{
|
|
|
|
|
component.BoltWireCut = value;
|
|
|
|
|
}
|
|
|
|
|
}
|