Fixed airlock maintenance panel showing when the airlock was open (#346)
This commit is contained in:
committed by
Pieter-Jan Briers
parent
375813e5e2
commit
b496e8ef29
@@ -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<CrowbarComponent>() && !IsPowered())
|
||||
{
|
||||
if (_state == DoorState.Closed)
|
||||
if (State == DoorState.Closed)
|
||||
{
|
||||
Open();
|
||||
}
|
||||
else if(_state == DoorState.Open)
|
||||
else if(State == DoorState.Open)
|
||||
{
|
||||
Close();
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ namespace Content.Server.GameObjects.Components.VendingMachines
|
||||
}
|
||||
|
||||
var wires = Owner.GetComponent<WiresComponent>();
|
||||
if (wires.IsOpen)
|
||||
if (wires.IsPanelOpen)
|
||||
{
|
||||
wires.OpenInterface(actor.playerSession);
|
||||
} else
|
||||
|
||||
@@ -35,16 +35,46 @@ namespace Content.Server.GameObjects.Components
|
||||
private AudioSystem _audioSystem;
|
||||
private AppearanceComponent _appearance;
|
||||
private BoundUserInterface _userInterface;
|
||||
private bool _isOpen;
|
||||
|
||||
public bool IsOpen
|
||||
private bool _isPanelOpen;
|
||||
/// <summary>
|
||||
/// Opening the maintenance panel (typically with a screwdriver) changes this.
|
||||
/// </summary>
|
||||
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;
|
||||
/// <summary>
|
||||
/// Components can set this to prevent the maintenance panel overlay from showing even if it's open
|
||||
/// </summary>
|
||||
public bool IsPanelVisible
|
||||
{
|
||||
get => _isPanelVisible;
|
||||
set
|
||||
{
|
||||
if (_isPanelVisible == value)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_isPanelVisible = value;
|
||||
UpdateAppearance();
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateAppearance()
|
||||
{
|
||||
_appearance.SetData(WiresVisuals.MaintenancePanelState, IsPanelOpen && IsPanelVisible);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -83,7 +113,7 @@ namespace Content.Server.GameObjects.Components
|
||||
base.Initialize();
|
||||
_audioSystem = IoCManager.Resolve<IEntitySystemManager>().GetEntitySystem<AudioSystem>();
|
||||
_appearance = Owner.GetComponent<AppearanceComponent>();
|
||||
_appearance.SetData(WiresVisuals.MaintenancePanelState, IsOpen);
|
||||
_appearance.SetData(WiresVisuals.MaintenancePanelState, IsPanelOpen);
|
||||
_userInterface = Owner.GetComponent<ServerUserInterfaceComponent>()
|
||||
.GetBoundUserInterface(WiresUiKey.Key);
|
||||
_userInterface.OnReceiveMessage += UserInterfaceOnReceiveMessage;
|
||||
@@ -257,13 +287,13 @@ namespace Content.Server.GameObjects.Components
|
||||
bool IAttackBy.AttackBy(AttackByEventArgs eventArgs)
|
||||
{
|
||||
if (!eventArgs.AttackWith.HasComponent<ScrewdriverComponent>()) 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)
|
||||
|
||||
Reference in New Issue
Block a user