Refactor FTL time tracking code to fix a UI bug (#26538)

The FTL UI on the shuttle console would reset the FTL progress bar every time you open it. This is because the server only sends "time until completion", not a start/end time. The FTL code now uses a separate start/end time so the exact same progress bar can be preserved.

For convenience, I made a StartEndTime record struct that stores the actual tuple. This is now used by the code and has some helpers.
This commit is contained in:
Pieter-Jan Briers
2024-03-30 02:40:55 +01:00
committed by GitHub
parent 72c6a14d59
commit 3b791459c7
7 changed files with 111 additions and 46 deletions

View File

@@ -1,5 +1,6 @@
using Content.Shared.Shuttles.Systems;
using Content.Shared.Tag;
using Content.Shared.Timing;
using Robust.Shared.Audio;
using Robust.Shared.Map;
using Robust.Shared.Prototypes;
@@ -16,15 +17,15 @@ public sealed partial class FTLComponent : Component
[ViewVariables]
public FTLState State = FTLState.Available;
[ViewVariables(VVAccess.ReadWrite)]
public StartEndTime StateTime;
[ViewVariables(VVAccess.ReadWrite)]
public float StartupTime = 0f;
[ViewVariables(VVAccess.ReadWrite)]
public float TravelTime = 0f;
[ViewVariables(VVAccess.ReadWrite)]
public float Accumulator = 0f;
/// <summary>
/// Coordinates to arrive it: May be relative to another grid (for docking) or map coordinates.
/// </summary>