diff --git a/strafe-client/src/session.rs b/strafe-client/src/session.rs index 145f474..47b3ba7 100644 --- a/strafe-client/src/session.rs +++ b/strafe-client/src/session.rs @@ -106,6 +106,26 @@ impl Replay{ simulation, } } + pub fn advance(&mut self,time_limit:SessionTime){ + let mut time=self.simulation.timer.time(time_limit); + loop{ + if let Some(ins)=self.recording.instructions.get(self.last_instruction_id){ + if ins.time> for Session{ recording.instructions.extend(self.recording.instructions.iter().cloned()); // create timer starting at first instruction (or zero if the list is empty) - let timer=Timer::unpaused(ins.time,recording.instructions.first().map_or(PhysicsTime::ZERO,|ins|ins.time)); + let new_time=recording.instructions.first().map_or(PhysicsTime::ZERO,|ins|ins.time); + let timer=Timer::unpaused(ins.time,new_time); // create default physics state let simulation=Simulation::new(timer,Default::default()); @@ -261,6 +282,10 @@ impl InstructionConsumer> for Session{ }, Instruction::Idle=>{ run_mouse_interpolator_instruction!(MouseInterpolatorInstruction::Idle); + // this just refreshes the replays + for replay in self.replays.values_mut(){ + replay.advance(ins.time); + } } };