implement looping
This commit is contained in:
parent
f51215fe4d
commit
c31bad8a06
@ -225,6 +225,7 @@ struct PlayBacker{
|
|||||||
//"Simulation"
|
//"Simulation"
|
||||||
event_id:usize,
|
event_id:usize,
|
||||||
offset:f64,
|
offset:f64,
|
||||||
|
duration:f64,
|
||||||
timer:Timer<Scaled>,
|
timer:Timer<Scaled>,
|
||||||
physics:crate::physics::PhysicsContext,
|
physics:crate::physics::PhysicsContext,
|
||||||
}
|
}
|
||||||
@ -233,8 +234,11 @@ impl PlayBacker{
|
|||||||
physics:crate::physics::PhysicsContext,
|
physics:crate::physics::PhysicsContext,
|
||||||
timelines:strafesnet_roblox_bot_file::v0::Block,
|
timelines:strafesnet_roblox_bot_file::v0::Block,
|
||||||
)->Self{
|
)->Self{
|
||||||
|
let first=timelines.output_events.first().unwrap();
|
||||||
|
let last=timelines.output_events.last().unwrap();
|
||||||
Self{
|
Self{
|
||||||
offset:timelines.output_events[0].time,
|
offset:first.time,
|
||||||
|
duration:last.time-first.time,
|
||||||
timelines,
|
timelines,
|
||||||
event_id:0,
|
event_id:0,
|
||||||
timer:Timer::from_state(Scaled::identity(),false),
|
timer:Timer::from_state(Scaled::identity(),false),
|
||||||
@ -250,14 +254,22 @@ impl PlayBacker{
|
|||||||
_=>(),
|
_=>(),
|
||||||
}
|
}
|
||||||
let simulation_time=self.timer.time(*time);
|
let simulation_time=self.timer.time(*time);
|
||||||
let time_float=simulation_time.get() as f64/Time::ONE_SECOND.get() as f64+self.offset;
|
let mut time_float=simulation_time.get() as f64/Time::ONE_SECOND.get() as f64+self.offset;
|
||||||
while let Some(next_event)=self.timelines.output_events.get(self.event_id+1){
|
loop{
|
||||||
//println!("{}<{}",next_event.time,time_float);
|
match self.timelines.output_events.get(self.event_id+1){
|
||||||
if next_event.time<time_float{
|
Some(next_event)=>{
|
||||||
self.event_id+=1;
|
if next_event.time<time_float{
|
||||||
println!("event_id={}",self.event_id);
|
self.event_id+=1;
|
||||||
}else{
|
}else{
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
None=>{
|
||||||
|
//reset playback
|
||||||
|
self.event_id=0;
|
||||||
|
self.offset-=self.duration;
|
||||||
|
time_float-=self.duration;
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user