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.Shuttles.UI.MapObjects;
using Content.Shared.Timing;
using Robust.Shared.Serialization;
namespace Content.Shared.Shuttles.BUIStates;
@@ -16,9 +17,9 @@ public sealed class ShuttleMapInterfaceState
public readonly FTLState FTLState;
/// <summary>
/// How long the FTL state takes.
/// When the current FTL state starts and ends.
/// </summary>
public float FTLDuration;
public StartEndTime FTLTime;
public List<ShuttleBeaconObject> Destinations;
@@ -26,12 +27,12 @@ public sealed class ShuttleMapInterfaceState
public ShuttleMapInterfaceState(
FTLState ftlState,
float ftlDuration,
StartEndTime ftlTime,
List<ShuttleBeaconObject> destinations,
List<ShuttleExclusionObject> exclusions)
{
FTLState = ftlState;
FTLDuration = ftlDuration;
FTLTime = ftlTime;
Destinations = destinations;
Exclusions = exclusions;
}