A record of everything that was done to a world, and the means to do it again.
Cauldron2D.World started with record: true builds one; Cauldron2D.World.replay/1
returns it. run/4 rebuilds the game from its options and feeds the record back in,
tick by tick, giving the same state the world reached.
replay = Cauldron2D.World.replay(world)
state = Cauldron2D.Replay.run(replay, MyGame, [seed: 7], 1 / 50)Entries are {tick, action} where action is {:join, id, props}, {:leave, id} or
{:input, id, input_state}, and tick is how many steps had run when it happened.
Summary
Functions
The entries oldest first.
An empty record.
Add what happened at tick.
Rebuild game from game_opts and apply the record, stepping by dt each tick.
Note that steps steps have run in total.
Types
@type action() :: {:join, term(), map()} | {:leave, term()} | {:input, term(), Cauldron2D.Input.state()}
@type t() :: %Cauldron2D.Replay{ entries: [{non_neg_integer(), action()}], steps: non_neg_integer() }
Functions
@spec entries(t()) :: [{non_neg_integer(), action()}]
The entries oldest first.
@spec new() :: t()
An empty record.
@spec record(t(), non_neg_integer(), action()) :: t()
Add what happened at tick.
Rebuild game from game_opts and apply the record, stepping by dt each tick.
@spec stepped(t(), non_neg_integer()) :: t()
Note that steps steps have run in total.