using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom; namespace Content.Client.TextScreen; /// /// A component for text screens that support countdown timers with frame-by-frame updates. /// /// /// Entities must have to work! /// [RegisterComponent, Access(typeof(TextScreenSystem))] [AutoGenerateComponentPause] public sealed partial class TextScreenTimerVisualsComponent : Component { /// /// The time that the timer is counting down to. /// [DataField(customTypeSerializer: typeof(TimeOffsetSerializer))] [AutoPausedField] public TimeSpan? TargetTime; /// /// The text to render onto the screen while the timer is running. /// [DataField] public string RunningText = ""; /// /// The string to draw onto the screen when the target time is reached. /// [DataField] public string FinishedText = ""; /// /// The 0-indexed row to use for the timer data. /// [DataField] public int TimerRow; /// /// If true, the timer will show small durations with centisecond precision. /// If false, times will be shown with second precision at most. /// [DataField] public bool ShowCentiseconds = true; /// /// The last value being displayed on the screen. /// /// /// A value of all zeros implies the timer is done, and should be displayed instead. [DataField] public TimerDisplay ScreenValue; /// /// The state to use for the layer when the timer is in progress. /// [DataField] public string? RunningState; /// /// The state to use for the layer when the timer elapses. /// [DataField] public string? FinishedState; } /// /// A value to display on a timer, agnostic of time unit. /// /// /// Values to be expressed as HIGH:LOW, both values effectively capped at 99. /// Used to avoid string comparisons. /// [DataDefinition, Serializable] public partial record struct TimerDisplay(int HighValue, int LowValue) { public override readonly string ToString() { var high = int.Clamp(HighValue, 0, 99); var low = int.Clamp(LowValue, 0, 99); return $"{high:D2}:{low:D2}"; } } /// /// Sprite layers for text screen timers. /// [Serializable] public enum TimerVisualLayers : byte { /// A light that turns on with the status of the timer. Light }