Documentation
¶
Overview ¶
Package replay defines the on-disk format for recorded play sessions along with a recorder that captures per-frame controller input and screenshot markers and a player that reproduces them.
Index ¶
Constants ¶
const Version = 1
Version is the replay file format version.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type File ¶
type File struct {
Version int `json:"version"`
DiscID string `json:"discId"`
Frames int `json:"frames"`
Input []InputEvent `json:"input"`
Screenshots []int `json:"screenshots"`
}
File is the full replay document.
type InputEvent ¶
InputEvent is a controller-state change at a given frame. The state holds until the next event, so a held input is a single entry.
type Player ¶
type Player struct {
// contains filtered or unexported fields
}
Player walks a File's input change-events one frame at a time. It reproduces the recorded controller state: each change-event applies at its frame and holds until the next one. Frames are produced in order from 0; the player stops contributing input once the recorded frame count is reached.
func (*Player) Next ¶
Next returns the recorded input for the next frame and advances the player. It must be called once per frame in order. active is false once the recorded frame count is exhausted, at which point p1/p2 are zero and the caller should fall back to live input only.
func (*Player) ShouldScreenshot ¶
ShouldScreenshot reports whether the frame most recently produced by Next is a marked screenshot point.
type Recorder ¶
type Recorder struct {
// contains filtered or unexported fields
}
Recorder accumulates input change-events and screenshot markers while a session plays, then writes them to a replay file. All indices are frame counts, incremented once per recorded frame.
func NewRecorder ¶
func NewRecorder() *Recorder
NewRecorder returns an empty recorder positioned at frame 0.
func (*Recorder) MarkScreenshot ¶
MarkScreenshot marks the most-recently-completed frame as a screenshot point and returns its index. Before any frame has been recorded it marks frame 0.
func (*Recorder) RecordFrame ¶
RecordFrame records the input applied to the next frame and advances the frame counter. An event is appended only when the state differs from the previous frame, plus always on the first frame so the baseline state is captured at frame 0.