From 14ccebc703a52c8235b17d8a45e025686bac62bf Mon Sep 17 00:00:00 2001 From: Tangent Wantwight Date: Sat, 15 Feb 2020 14:12:53 -0500 Subject: [PATCH] Add stub demo-playback code --- src/Ecs/Lockstep.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/Ecs/Lockstep.ts b/src/Ecs/Lockstep.ts index 71e42fa..26e6950 100644 --- a/src/Ecs/Lockstep.ts +++ b/src/Ecs/Lockstep.ts @@ -80,6 +80,24 @@ export class LockstepState { } } +export class Playback { + private frame = 0; + + public constructor( + private state: State, + private inputLog: Input[], + private engine: LockstepProcessor, + ) {} + + public getNextState(): State { + if(this.frame < this.inputLog.length) { + this.engine.advanceState(this.state, this.inputLog[this.frame]); + this.frame++; + } + return this.state; + } +} + export class LockstepLoop> { }