rename last_instruction_id to next_instruction_id
This commit is contained in:
parent
b45b92c627
commit
40ea0e6c7d
@ -99,7 +99,7 @@ impl Recording{
|
||||
}
|
||||
}
|
||||
pub struct Replay{
|
||||
last_instruction_id:usize,
|
||||
next_instruction_id:usize,
|
||||
recording:Recording,
|
||||
simulation:Simulation,
|
||||
}
|
||||
@ -109,7 +109,7 @@ impl Replay{
|
||||
simulation:Simulation,
|
||||
)->Self{
|
||||
Self{
|
||||
last_instruction_id:0,
|
||||
next_instruction_id:0,
|
||||
recording,
|
||||
simulation,
|
||||
}
|
||||
@ -117,16 +117,16 @@ impl Replay{
|
||||
pub fn advance(&mut self,physics_data:&PhysicsData,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 let Some(ins)=self.recording.instructions.get(self.next_instruction_id){
|
||||
if ins.time<time{
|
||||
PhysicsContext::run_input_instruction(&mut self.simulation.physics,physics_data,ins.clone());
|
||||
self.last_instruction_id+=1;
|
||||
self.next_instruction_id+=1;
|
||||
}else{
|
||||
break;
|
||||
}
|
||||
}else{
|
||||
// loop playback
|
||||
self.last_instruction_id=0;
|
||||
self.next_instruction_id=0;
|
||||
// No need to reset physics because the very first instruction is 'Reset'
|
||||
let new_time=self.recording.instructions.first().map_or(PhysicsTime::ZERO,|ins|ins.time);
|
||||
self.simulation.timer.set_time(time_limit,new_time);
|
||||
@ -340,7 +340,7 @@ impl InstructionConsumer<Instruction<'_>> for Session{
|
||||
let time=replay.simulation.timer.time(ins.time+SessionTime::from_secs(5));
|
||||
replay.simulation.timer.set_time(ins.time,time);
|
||||
// resimulate the entire playback lol
|
||||
replay.last_instruction_id=0;
|
||||
replay.next_instruction_id=0;
|
||||
},
|
||||
}
|
||||
},
|
||||
|
Loading…
x
Reference in New Issue
Block a user