diff --git a/Content.Client/Doors/FirelockSystem.cs b/Content.Client/Doors/FirelockSystem.cs index cfd84a471336cc..0ea4ba20102ec9 100644 --- a/Content.Client/Doors/FirelockSystem.cs +++ b/Content.Client/Doors/FirelockSystem.cs @@ -1,3 +1,4 @@ +using Content.Shared.Doors; using Content.Shared.Doors.Components; using Robust.Client.GameObjects; @@ -10,9 +11,17 @@ public sealed class FirelockSystem : EntitySystem public override void Initialize() { base.Initialize(); + + SubscribeLocalEvent(OnBeforeDoorOpened); SubscribeLocalEvent(OnAppearanceChange); } + private void OnBeforeDoorOpened(EntityUid uid, FirelockComponent component, BeforeDoorOpenedEvent args) + { + if (!component.Powered) + args.Cancel(); + } + private void OnAppearanceChange(EntityUid uid, FirelockComponent comp, ref AppearanceChangeEvent args) { if (args.Sprite == null) diff --git a/Content.Server/Doors/Systems/FirelockSystem.cs b/Content.Server/Doors/Systems/FirelockSystem.cs index 3d4c8a4ec59e04..bc9742daf3a759 100644 --- a/Content.Server/Doors/Systems/FirelockSystem.cs +++ b/Content.Server/Doors/Systems/FirelockSystem.cs @@ -48,6 +48,12 @@ public override void Initialize() private void PowerChanged(EntityUid uid, FirelockComponent component, ref PowerChangedEvent args) { + if (component.Powered != args.Powered) + { + component.Powered = args.Powered; + Dirty(uid, component); + } + // TODO this should REALLLLY not be door specific appearance thing. _appearance.SetData(uid, DoorVisuals.Powered, args.Powered); } @@ -133,10 +139,21 @@ public bool EmergencyPressureStop(EntityUid uid, FirelockComponent? firelock = n private void OnBeforeDoorOpened(EntityUid uid, FirelockComponent component, BeforeDoorOpenedEvent args) { + if (!this.IsPowered(uid, EntityManager)) + { + if (args.User != null) + { + _popupSystem.PopupEntity(Loc.GetString("firelock-component-is-unpowered-message"), + uid, args.User.Value, PopupType.Medium); + } + + args.Cancel(); + return; + } + // Give the Door remote the ability to force a firelock open even if it is holding back dangerous gas var overrideAccess = (args.User != null) && _accessReaderSystem.IsAllowed(args.User.Value, uid); - - if (!this.IsPowered(uid, EntityManager) || (!overrideAccess && IsHoldingPressureOrFire(uid, component))) + if (!overrideAccess && IsHoldingPressureOrFire(uid, component)) args.Cancel(); } diff --git a/Content.Shared/Doors/Components/FirelockComponent.cs b/Content.Shared/Doors/Components/FirelockComponent.cs index 97e57185cac9ad..d9ea3726ba355d 100644 --- a/Content.Shared/Doors/Components/FirelockComponent.cs +++ b/Content.Shared/Doors/Components/FirelockComponent.cs @@ -1,3 +1,4 @@ +using Robust.Shared.GameStates; using Content.Shared.Doors.Components; namespace Content.Shared.Doors.Components @@ -7,9 +8,15 @@ namespace Content.Shared.Doors.Components /// auto-closing on depressurization, air/fire alarm interactions, and preventing normal door functions when /// retaining pressure.. /// - [RegisterComponent] + [RegisterComponent, NetworkedComponent, AutoGenerateComponentState] public sealed partial class FirelockComponent : Component { + /// + /// Networked powered status for firelock to allow for proper client prediction + /// + [DataField, AutoNetworkedField] + public bool Powered; + /// /// Pry time modifier to be used when the firelock is currently closed due to fire or pressure. /// diff --git a/Resources/Locale/en-US/atmos/firelock-component.ftl b/Resources/Locale/en-US/atmos/firelock-component.ftl index fc375183e975e7..4a2c3ad15f291b 100644 --- a/Resources/Locale/en-US/atmos/firelock-component.ftl +++ b/Resources/Locale/en-US/atmos/firelock-component.ftl @@ -1,2 +1,4 @@ firelock-component-is-holding-pressure-message = A gush of air blows in your face... Maybe you should reconsider. -firelock-component-is-holding-fire-message = A gush of warm air blows in your face... Maybe you should reconsider. \ No newline at end of file +firelock-component-is-holding-fire-message = A gush of warm air blows in your face... Maybe you should reconsider. +firelock-component-is-unpowered-message = The door is unpowered and can't be opened by hand! +