ghost library

A rival or a past run, drawn from a recorded track.

Three pieces, each usable alone:

  • Ghost — a translucent, unlit, untouchable node put where a GhostTape was at a moment of it, or hidden before it starts and after it ends;
  • ghostOfRun — the track of one body through a shared run: the tape played again when it can be, the run's pose record when it cannot, and the reason when neither will do;
  • BestRun — the best run made in one place, kept between launches.

None of them knows what is being raced. A game hands over its own model, its own staging for a replay and its own name for the file.

Classes

BestRun
The best run somebody has made here, kept between launches: the ghost to race, and the time to beat.
Ghost
A rival or a past run, drawn where a recorded track was at a moment of it.
GhostNote
What ghostOfRun has to say about a ghost: an id and what it carries, worded by say in the player's language.
RunGhost
What ghostOfRun found: the ghost to race, or none, and the note that says what it is or why there is none.

Constants

ghostTapeFormat → const FormatSpec
A best run in the registry: f3d.ghostTape.
ghostTapeFormatVersion → const int
The version of the best-run document tapeToJson writes, and the newest tapeFromJson reads.

Functions

ghostOfRun(Level level, Demo demo, {required String body, required SimulationVersion simulation, required GhostTape replay(), PhysicsBackend physics = const DartPhysics()}) → RunGhost
The track of one body through a shared run, or the reason there is none.
tapeFromJson(Map<String, Object?> json) → GhostTape
Reads back what tapeToJson wrote, and the bare {"version": 1} shape every best run had before the envelope.
tapeToJson(GhostTape tape) → Map<String, Object?>
A tape as BestRun keeps it when the game names no format of its own: the envelope (ghostTapeFormat), then seconds and frames.