Files
tbd-station-14/Content.Server/Shuttles/Components/FTLComponent.cs
Pieter-Jan Briers 3b791459c7 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.
2024-03-30 12:40:55 +11:00

53 lines
1.6 KiB
C#

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;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
namespace Content.Server.Shuttles.Components;
/// <summary>
/// Added to a component when it is queued or is travelling via FTL.
/// </summary>
[RegisterComponent]
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;
/// <summary>
/// Coordinates to arrive it: May be relative to another grid (for docking) or map coordinates.
/// </summary>
[ViewVariables(VVAccess.ReadWrite), DataField]
public EntityCoordinates TargetCoordinates;
[DataField]
public Angle TargetAngle;
/// <summary>
/// If we're docking after FTL what is the prioritised dock tag (if applicable).
/// </summary>
[ViewVariables(VVAccess.ReadWrite), DataField]
public ProtoId<TagPrototype>? PriorityTag;
[ViewVariables(VVAccess.ReadWrite), DataField("soundTravel")]
public SoundSpecifier? TravelSound = new SoundPathSpecifier("/Audio/Effects/Shuttle/hyperspace_progress.ogg")
{
Params = AudioParams.Default.WithVolume(-3f).WithLoop(true)
};
[DataField]
public EntityUid? TravelStream;
}