Split Door Bolt functionality out of AirlockDoor (#16354)

This commit is contained in:
Tom Leys
2023-06-01 02:23:35 +12:00
committed by GitHub
parent f419c20c49
commit a196756124
26 changed files with 283 additions and 161 deletions

View File

@@ -22,18 +22,6 @@ public sealed class AirlockComponent : Component
[DataField("emergencyAccess")]
public bool EmergencyAccess = false;
/// <summary>
/// Sound to play when the bolts on the airlock go up.
/// </summary>
[DataField("boltUpSound")]
public SoundSpecifier BoltUpSound = new SoundPathSpecifier("/Audio/Machines/boltsup.ogg");
/// <summary>
/// Sound to play when the bolts on the airlock go down.
/// </summary>
[DataField("boltDownSound")]
public SoundSpecifier BoltDownSound = new SoundPathSpecifier("/Audio/Machines/boltsdown.ogg");
/// <summary>
/// Pry modifier for a powered airlock.
/// Most anything that can pry powered has a pry speed bonus,
@@ -55,24 +43,6 @@ public sealed class AirlockComponent : Component
[DataField("keepOpenIfClicked")]
public bool KeepOpenIfClicked = false;
/// <summary>
/// Whether the door bolts are currently deployed.
/// </summary>
[ViewVariables]
public bool BoltsDown;
/// <summary>
/// Whether the bolt lights are currently enabled.
/// </summary>
[ViewVariables]
public bool BoltLightsEnabled = true;
/// <summary>
/// True if the bolt wire is cut, which will force the airlock to always be bolted as long as it has power.
/// </summary>
[ViewVariables]
public bool BoltWireCut;
/// <summary>
/// Whether the airlock should auto close. This value is reset every time the airlock closes.
/// </summary>

View File

@@ -0,0 +1,46 @@
using Content.Shared.Doors.Systems;
using Content.Shared.MachineLinking;
using Robust.Shared.Audio;
using Robust.Shared.GameStates;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
namespace Content.Shared.Doors.Components;
/// <summary>
/// Companion component to DoorComponent that handles bolt-specific behavior.
/// </summary>
[RegisterComponent, NetworkedComponent]
[Access(typeof(SharedDoorBoltSystem))]
public sealed class DoorBoltComponent : Component
{
/// <summary>
/// Sound to play when the bolts on the airlock go up.
/// </summary>
[DataField("boltUpSound"), ViewVariables(VVAccess.ReadWrite)]
public SoundSpecifier BoltUpSound = new SoundPathSpecifier("/Audio/Machines/boltsup.ogg");
/// <summary>
/// Sound to play when the bolts on the airlock go down.
/// </summary>
[DataField("boltDownSound"), ViewVariables(VVAccess.ReadWrite)]
public SoundSpecifier BoltDownSound = new SoundPathSpecifier("/Audio/Machines/boltsdown.ogg");
/// <summary>
/// Whether the door bolts are currently deployed.
/// </summary>
[ViewVariables(VVAccess.ReadWrite)]
public bool BoltsDown;
/// <summary>
/// Whether the bolt lights are currently enabled.
/// </summary>
[ViewVariables(VVAccess.ReadWrite)]
public bool BoltLightsEnabled = true;
/// <summary>
/// True if the bolt wire is cut, which will force the airlock to always be bolted as long as it has power.
/// </summary>
[ViewVariables(VVAccess.ReadWrite)]
public bool BoltWireCut;
}

View File

@@ -7,7 +7,6 @@ namespace Content.Shared.Doors.Systems;
public abstract class SharedAirlockSystem : EntitySystem
{
[Dependency] protected readonly SharedAppearanceSystem Appearance = default!;
[Dependency] protected readonly SharedAudioSystem Audio = default!;
[Dependency] protected readonly SharedDoorSystem DoorSystem = default!;
[Dependency] protected readonly SharedPopupSystem Popup = default!;
@@ -64,9 +63,4 @@ public abstract class SharedAirlockSystem : EntitySystem
{
component.Safety = value;
}
public void SetBoltWireCut(AirlockComponent component, bool value)
{
component.BoltWireCut = value;
}
}

View File

@@ -0,0 +1,54 @@
using Content.Shared.Doors.Components;
using Content.Shared.Popups;
namespace Content.Shared.Doors.Systems;
public abstract class SharedDoorBoltSystem : EntitySystem
{
[Dependency] protected readonly SharedAppearanceSystem Appearance = default!;
[Dependency] protected readonly SharedAudioSystem Audio = default!;
[Dependency] private readonly SharedPopupSystem Popup = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<DoorBoltComponent, BeforeDoorOpenedEvent>(OnBeforeDoorOpened);
SubscribeLocalEvent<DoorBoltComponent, BeforeDoorClosedEvent>(OnBeforeDoorClosed);
SubscribeLocalEvent<DoorBoltComponent, BeforeDoorDeniedEvent>(OnBeforeDoorDenied);
SubscribeLocalEvent<DoorBoltComponent, BeforeDoorPryEvent>(OnDoorPry);
}
private void OnDoorPry(EntityUid uid, DoorBoltComponent component, BeforeDoorPryEvent args)
{
if (component.BoltsDown)
{
Popup.PopupEntity(Loc.GetString("airlock-component-cannot-pry-is-bolted-message"), uid, args.User);
args.Cancel();
}
}
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;
}
}