diff --git a/Content.Server/GameObjects/Components/Doors/AirlockComponent.cs b/Content.Server/GameObjects/Components/Doors/AirlockComponent.cs index 000d8b331e..7e7839c630 100644 --- a/Content.Server/GameObjects/Components/Doors/AirlockComponent.cs +++ b/Content.Server/GameObjects/Components/Doors/AirlockComponent.cs @@ -62,6 +62,16 @@ namespace Content.Server.GameObjects.Components.Doors _wires.SetStatus(WiresStatus.PowerIndicator, _localizationMgr.GetString(powerMessage)); } + protected override DoorState State + { + set + { + base.State = value; + // Only show the maintenance panel if the airlock is closed + _wires.IsPanelVisible = value == DoorState.Closed; + } + } + public override void Initialize() { base.Initialize(); @@ -71,7 +81,7 @@ namespace Content.Server.GameObjects.Components.Doors protected override void ActivateImpl(ActivateEventArgs args) { - if (_wires.IsOpen) + if (_wires.IsPanelOpen) { if (args.User.TryGetComponent(out IActorComponent actor)) { @@ -174,11 +184,11 @@ namespace Content.Server.GameObjects.Components.Doors { if (eventArgs.AttackWith.HasComponent() && !IsPowered()) { - if (_state == DoorState.Closed) + if (State == DoorState.Closed) { Open(); } - else if(_state == DoorState.Open) + else if(State == DoorState.Open) { Close(); } diff --git a/Content.Server/GameObjects/Components/Doors/ServerDoorComponent.cs b/Content.Server/GameObjects/Components/Doors/ServerDoorComponent.cs index a3928b7449..31d5db8e96 100644 --- a/Content.Server/GameObjects/Components/Doors/ServerDoorComponent.cs +++ b/Content.Server/GameObjects/Components/Doors/ServerDoorComponent.cs @@ -17,7 +17,13 @@ namespace Content.Server.GameObjects { public override string Name => "Door"; - protected DoorState _state = DoorState.Closed; + private DoorState _state = DoorState.Closed; + + protected virtual DoorState State + { + get => _state; + set => _state = value; + } private float OpenTimeCounter; @@ -47,11 +53,11 @@ namespace Content.Server.GameObjects protected virtual void ActivateImpl(ActivateEventArgs eventArgs) { - if (_state == DoorState.Open) + if (State == DoorState.Open) { Close(); } - else if (_state == DoorState.Closed) + else if (State == DoorState.Closed) { TryOpen(eventArgs.User); } @@ -69,7 +75,7 @@ namespace Content.Server.GameObjects switch (message) { case BumpedEntMsg msg: - if (_state != DoorState.Closed) + if (State != DoorState.Closed) { return; } @@ -112,12 +118,12 @@ namespace Content.Server.GameObjects public void Open() { - if (_state != DoorState.Closed) + if (State != DoorState.Closed) { return; } - _state = DoorState.Opening; + State = DoorState.Opening; _appearance.SetData(DoorVisuals.VisualState, DoorVisualState.Opening); Timer.Spawn(OpenTimeOne, async () => @@ -126,7 +132,7 @@ namespace Content.Server.GameObjects await Timer.Delay(OpenTimeTwo); - _state = DoorState.Open; + State = DoorState.Open; _appearance.SetData(DoorVisuals.VisualState, DoorVisualState.Open); }); } @@ -139,14 +145,14 @@ namespace Content.Server.GameObjects return false; } - _state = DoorState.Closing; + State = DoorState.Closing; collidableComponent.IsHardCollidable = true; OpenTimeCounter = 0; _appearance.SetData(DoorVisuals.VisualState, DoorVisualState.Closing); Timer.Spawn(CloseTime, () => { - _state = DoorState.Closed; + State = DoorState.Closed; _appearance.SetData(DoorVisuals.VisualState, DoorVisualState.Closed); }); return true; @@ -164,7 +170,7 @@ namespace Content.Server.GameObjects private const float AUTO_CLOSE_DELAY = 5; public virtual void OnUpdate(float frameTime) { - if (_state != DoorState.Open) + if (State != DoorState.Open) { return; } diff --git a/Content.Server/GameObjects/Components/VendingMachines/VendingMachineComponent.cs b/Content.Server/GameObjects/Components/VendingMachines/VendingMachineComponent.cs index 288e218281..9223f122d4 100644 --- a/Content.Server/GameObjects/Components/VendingMachines/VendingMachineComponent.cs +++ b/Content.Server/GameObjects/Components/VendingMachines/VendingMachineComponent.cs @@ -48,7 +48,7 @@ namespace Content.Server.GameObjects.Components.VendingMachines } var wires = Owner.GetComponent(); - if (wires.IsOpen) + if (wires.IsPanelOpen) { wires.OpenInterface(actor.playerSession); } else diff --git a/Content.Server/GameObjects/Components/WiresComponent.cs b/Content.Server/GameObjects/Components/WiresComponent.cs index 759991b0d0..ca5f73d577 100644 --- a/Content.Server/GameObjects/Components/WiresComponent.cs +++ b/Content.Server/GameObjects/Components/WiresComponent.cs @@ -35,18 +35,48 @@ namespace Content.Server.GameObjects.Components private AudioSystem _audioSystem; private AppearanceComponent _appearance; private BoundUserInterface _userInterface; - private bool _isOpen; - public bool IsOpen + private bool _isPanelOpen; + /// + /// Opening the maintenance panel (typically with a screwdriver) changes this. + /// + public bool IsPanelOpen { - get => _isOpen; + get => _isPanelOpen; private set { - _isOpen = value; - _appearance.SetData(WiresVisuals.MaintenancePanelState, value); + if (_isPanelOpen == value) + { + return; + } + _isPanelOpen = value; + UpdateAppearance(); } } + private bool _isPanelVisible = true; + /// + /// Components can set this to prevent the maintenance panel overlay from showing even if it's open + /// + public bool IsPanelVisible + { + get => _isPanelVisible; + set + { + if (_isPanelVisible == value) + { + return; + } + _isPanelVisible = value; + UpdateAppearance(); + } + } + + private void UpdateAppearance() + { + _appearance.SetData(WiresVisuals.MaintenancePanelState, IsPanelOpen && IsPanelVisible); + } + /// /// Contains all registered wires. /// @@ -83,7 +113,7 @@ namespace Content.Server.GameObjects.Components base.Initialize(); _audioSystem = IoCManager.Resolve().GetEntitySystem(); _appearance = Owner.GetComponent(); - _appearance.SetData(WiresVisuals.MaintenancePanelState, IsOpen); + _appearance.SetData(WiresVisuals.MaintenancePanelState, IsPanelOpen); _userInterface = Owner.GetComponent() .GetBoundUserInterface(WiresUiKey.Key); _userInterface.OnReceiveMessage += UserInterfaceOnReceiveMessage; @@ -257,13 +287,13 @@ namespace Content.Server.GameObjects.Components bool IAttackBy.AttackBy(AttackByEventArgs eventArgs) { if (!eventArgs.AttackWith.HasComponent()) return false; - IsOpen = !IsOpen; + IsPanelOpen = !IsPanelOpen; return true; } void IExamine.Examine(FormattedMessage message) { - message.AddText($"The maintenance panel is {(IsOpen ? "open" : "closed")}."); + message.AddText($"The maintenance panel is {(IsPanelOpen ? "open" : "closed")}."); } public void SetStatus(object statusIdentifier, string newMessage)