Timer Bars — TimerBarHud
TimerBarHud draws GTA-style timer bars (bottom-right, like the vanilla mission timers)
for things like a bleed-out clock, a hold-to-confirm progress bar, or a "UNITS EN ROUTE"
status. It is built on LSPDFR's Engine.UI bars — which are public but undocumented
engine internals — so the entire feature lives behind an abstraction with a kill
switch: if construction or drawing ever throws, timer bars turn themselves off for the
session, the failure is logged once, and the rest of the HUD survives.
Usage
var hud = new TimerBarHud(log);
hud.Start(fibers, flag); // draw fiber; draws only while bars exist
// A text bar. Put EVERYTHING in the text argument and pass label = "" — LSPDFR draws
// Label and Text at overlapping positions, so splitting content between them overprints.
ITextTimerBar status = hud.AddText("", "PANIC — UNITS EN ROUTE");
// A progress bar (red on dark-red by default):
IProgressTimerBar bleedOut = hud.AddProgress("BLEED OUT");
// Update from your logic loop:
status.Text = "PANIC — " + arrivedCount + " ON SCENE";
bleedOut.Percentage = remainingMs / (float)totalMs; // clamped to 0–1 for you
// Remove:
hud.Remove(status); // one bar
hud.Clear(); // all bars (teardown)
API notes
AddText/AddProgressreturn null when timer bars are unavailable on this install (the kill switch tripped). Null-check, or guard updates with?.— a null bar simply means "no HUD", never an error.HasBarstells you whether anything is currently shown.- Bars draw only while present; an empty HUD costs one early-out per frame.
- Multiple bars stack correctly (40 px apart). The base game draws rows 4 px per interval unit and each bar's box is 37 px tall, so the hud spaces rows internally — you never deal with intervals.
Percentagewrites are clamped to 0–1; feed it raw ratios without pre-clamping.
Placement in a plugin
One TimerBarHud per session is the intended shape — create it at duty start, Start it
on your session fibers, Clear() at incident end, and let the session teardown
(flag.Cancel() + AbortAll) stop the draw fiber.
// incident start
_bleedBar = _hud.AddProgress("BLEED OUT");
// incident tick
if (_bleedBar != null) _bleedBar.Percentage = remaining / total;
// incident end
_hud.Clear();