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));
|
_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()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
base.Initialize();
|
base.Initialize();
|
||||||
@@ -71,7 +81,7 @@ namespace Content.Server.GameObjects.Components.Doors
|
|||||||
|
|
||||||
protected override void ActivateImpl(ActivateEventArgs args)
|
protected override void ActivateImpl(ActivateEventArgs args)
|
||||||
{
|
{
|
||||||
if (_wires.IsOpen)
|
if (_wires.IsPanelOpen)
|
||||||
{
|
{
|
||||||
if (args.User.TryGetComponent(out IActorComponent actor))
|
if (args.User.TryGetComponent(out IActorComponent actor))
|
||||||
{
|
{
|
||||||
@@ -174,11 +184,11 @@ namespace Content.Server.GameObjects.Components.Doors
|
|||||||
{
|
{
|
||||||
if (eventArgs.AttackWith.HasComponent<CrowbarComponent>() && !IsPowered())
|
if (eventArgs.AttackWith.HasComponent<CrowbarComponent>() && !IsPowered())
|
||||||
{
|
{
|
||||||
if (_state == DoorState.Closed)
|
if (State == DoorState.Closed)
|
||||||
{
|
{
|
||||||
Open();
|
Open();
|
||||||
}
|
}
|
||||||
else if(_state == DoorState.Open)
|
else if(State == DoorState.Open)
|
||||||
{
|
{
|
||||||
Close();
|
Close();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,13 @@ namespace Content.Server.GameObjects
|
|||||||
{
|
{
|
||||||
public override string Name => "Door";
|
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;
|
private float OpenTimeCounter;
|
||||||
|
|
||||||
@@ -47,11 +53,11 @@ namespace Content.Server.GameObjects
|
|||||||
|
|
||||||
protected virtual void ActivateImpl(ActivateEventArgs eventArgs)
|
protected virtual void ActivateImpl(ActivateEventArgs eventArgs)
|
||||||
{
|
{
|
||||||
if (_state == DoorState.Open)
|
if (State == DoorState.Open)
|
||||||
{
|
{
|
||||||
Close();
|
Close();
|
||||||
}
|
}
|
||||||
else if (_state == DoorState.Closed)
|
else if (State == DoorState.Closed)
|
||||||
{
|
{
|
||||||
TryOpen(eventArgs.User);
|
TryOpen(eventArgs.User);
|
||||||
}
|
}
|
||||||
@@ -69,7 +75,7 @@ namespace Content.Server.GameObjects
|
|||||||
switch (message)
|
switch (message)
|
||||||
{
|
{
|
||||||
case BumpedEntMsg msg:
|
case BumpedEntMsg msg:
|
||||||
if (_state != DoorState.Closed)
|
if (State != DoorState.Closed)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -112,12 +118,12 @@ namespace Content.Server.GameObjects
|
|||||||
|
|
||||||
public void Open()
|
public void Open()
|
||||||
{
|
{
|
||||||
if (_state != DoorState.Closed)
|
if (State != DoorState.Closed)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_state = DoorState.Opening;
|
State = DoorState.Opening;
|
||||||
_appearance.SetData(DoorVisuals.VisualState, DoorVisualState.Opening);
|
_appearance.SetData(DoorVisuals.VisualState, DoorVisualState.Opening);
|
||||||
|
|
||||||
Timer.Spawn(OpenTimeOne, async () =>
|
Timer.Spawn(OpenTimeOne, async () =>
|
||||||
@@ -126,7 +132,7 @@ namespace Content.Server.GameObjects
|
|||||||
|
|
||||||
await Timer.Delay(OpenTimeTwo);
|
await Timer.Delay(OpenTimeTwo);
|
||||||
|
|
||||||
_state = DoorState.Open;
|
State = DoorState.Open;
|
||||||
_appearance.SetData(DoorVisuals.VisualState, DoorVisualState.Open);
|
_appearance.SetData(DoorVisuals.VisualState, DoorVisualState.Open);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -139,14 +145,14 @@ namespace Content.Server.GameObjects
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
_state = DoorState.Closing;
|
State = DoorState.Closing;
|
||||||
collidableComponent.IsHardCollidable = true;
|
collidableComponent.IsHardCollidable = true;
|
||||||
OpenTimeCounter = 0;
|
OpenTimeCounter = 0;
|
||||||
_appearance.SetData(DoorVisuals.VisualState, DoorVisualState.Closing);
|
_appearance.SetData(DoorVisuals.VisualState, DoorVisualState.Closing);
|
||||||
|
|
||||||
Timer.Spawn(CloseTime, () =>
|
Timer.Spawn(CloseTime, () =>
|
||||||
{
|
{
|
||||||
_state = DoorState.Closed;
|
State = DoorState.Closed;
|
||||||
_appearance.SetData(DoorVisuals.VisualState, DoorVisualState.Closed);
|
_appearance.SetData(DoorVisuals.VisualState, DoorVisualState.Closed);
|
||||||
});
|
});
|
||||||
return true;
|
return true;
|
||||||
@@ -164,7 +170,7 @@ namespace Content.Server.GameObjects
|
|||||||
private const float AUTO_CLOSE_DELAY = 5;
|
private const float AUTO_CLOSE_DELAY = 5;
|
||||||
public virtual void OnUpdate(float frameTime)
|
public virtual void OnUpdate(float frameTime)
|
||||||
{
|
{
|
||||||
if (_state != DoorState.Open)
|
if (State != DoorState.Open)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ namespace Content.Server.GameObjects.Components.VendingMachines
|
|||||||
}
|
}
|
||||||
|
|
||||||
var wires = Owner.GetComponent<WiresComponent>();
|
var wires = Owner.GetComponent<WiresComponent>();
|
||||||
if (wires.IsOpen)
|
if (wires.IsPanelOpen)
|
||||||
{
|
{
|
||||||
wires.OpenInterface(actor.playerSession);
|
wires.OpenInterface(actor.playerSession);
|
||||||
} else
|
} else
|
||||||
|
|||||||
@@ -35,18 +35,48 @@ namespace Content.Server.GameObjects.Components
|
|||||||
private AudioSystem _audioSystem;
|
private AudioSystem _audioSystem;
|
||||||
private AppearanceComponent _appearance;
|
private AppearanceComponent _appearance;
|
||||||
private BoundUserInterface _userInterface;
|
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
|
private set
|
||||||
{
|
{
|
||||||
_isOpen = value;
|
if (_isPanelOpen == value)
|
||||||
_appearance.SetData(WiresVisuals.MaintenancePanelState, 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>
|
/// <summary>
|
||||||
/// Contains all registered wires.
|
/// Contains all registered wires.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -83,7 +113,7 @@ namespace Content.Server.GameObjects.Components
|
|||||||
base.Initialize();
|
base.Initialize();
|
||||||
_audioSystem = IoCManager.Resolve<IEntitySystemManager>().GetEntitySystem<AudioSystem>();
|
_audioSystem = IoCManager.Resolve<IEntitySystemManager>().GetEntitySystem<AudioSystem>();
|
||||||
_appearance = Owner.GetComponent<AppearanceComponent>();
|
_appearance = Owner.GetComponent<AppearanceComponent>();
|
||||||
_appearance.SetData(WiresVisuals.MaintenancePanelState, IsOpen);
|
_appearance.SetData(WiresVisuals.MaintenancePanelState, IsPanelOpen);
|
||||||
_userInterface = Owner.GetComponent<ServerUserInterfaceComponent>()
|
_userInterface = Owner.GetComponent<ServerUserInterfaceComponent>()
|
||||||
.GetBoundUserInterface(WiresUiKey.Key);
|
.GetBoundUserInterface(WiresUiKey.Key);
|
||||||
_userInterface.OnReceiveMessage += UserInterfaceOnReceiveMessage;
|
_userInterface.OnReceiveMessage += UserInterfaceOnReceiveMessage;
|
||||||
@@ -257,13 +287,13 @@ namespace Content.Server.GameObjects.Components
|
|||||||
bool IAttackBy.AttackBy(AttackByEventArgs eventArgs)
|
bool IAttackBy.AttackBy(AttackByEventArgs eventArgs)
|
||||||
{
|
{
|
||||||
if (!eventArgs.AttackWith.HasComponent<ScrewdriverComponent>()) return false;
|
if (!eventArgs.AttackWith.HasComponent<ScrewdriverComponent>()) return false;
|
||||||
IsOpen = !IsOpen;
|
IsPanelOpen = !IsPanelOpen;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void IExamine.Examine(FormattedMessage message)
|
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)
|
public void SetStatus(object statusIdentifier, string newMessage)
|
||||||
|
|||||||
Reference in New Issue
Block a user