playback advance time

This commit is contained in:
2026-02-16 09:37:42 -08:00
parent b2b682187f
commit 35fb7dc014
2 changed files with 32 additions and 0 deletions

View File

@@ -19,4 +19,13 @@ impl Bot{
timelines,
})
}
pub const fn offset(&self)->f64{
self.offset
}
pub const fn duration(&self)->f64{
self.duration
}
pub const fn timelines(&self)->&strafesnet_roblox_bot_file::v0::Block{
&self.timelines
}
}

View File

@@ -14,6 +14,7 @@ pub enum PlaybackInstructionExternal{
pub struct PlaybackHead{
//"Simulation"
event_id:usize,
offset:f64,
timer:Timer<Scaled<SessionTimeInner,PhysicsTimeInner>>,
}
impl PlaybackHead{
@@ -21,7 +22,29 @@ impl PlaybackHead{
let timer=Timer::unpaused(time,PhysicsTime::ZERO);
Self{
event_id:0,
offset:0.0,
timer,
}
}
pub fn advance_time(&mut self,bot:&crate::bot::Bot,time:SessionTime){
let simulation_time=self.timer.time(time);
let mut time_float=simulation_time.get() as f64/PhysicsTime::ONE_SECOND.get() as f64+bot.offset()+self.offset;
loop{
match bot.timelines().output_events.get(self.event_id+1){
Some(next_event)=>{
if next_event.time<time_float{
self.event_id+=1;
}else{
break;
}
},
None=>{
//reset playback
self.event_id=0;
self.offset-=bot.duration();
time_float-=bot.duration();
},
}
}
}
}