introduce PlaybackTime to abstract bot file timestamps

This commit is contained in:
2026-02-26 08:31:11 -08:00
parent d03f84c893
commit 29e49587ff
5 changed files with 54 additions and 55 deletions

View File

@@ -118,9 +118,15 @@ impl PlaybackHead{
self.head.advance_time(&bot.bot,time);
}
#[wasm_bindgen]
pub fn get_head_time(&self,time:f64)->f64{
let time=time::from_float(time).unwrap();
let time=self.head.time(time);
time.get() as f64/strafesnet_common::run::Time::ONE_SECOND.get() as f64
}
#[wasm_bindgen]
pub fn get_run_time(&self,bot:&CompleteBot,time:f64,mode_id:u32)->Option<f64>{
let time=time::from_float(time).unwrap();
let time=self.head.time(&bot.bot,time);
let time=bot.bot.time(self.head.time(time));
let mode=v0::ModeID(mode_id);
let run_time=self.head.state().get_run(mode)?.time(time);
Some(run_time.get() as f64/strafesnet_common::run::Time::ONE_SECOND.get() as f64)
@@ -145,21 +151,12 @@ impl PlaybackHead{
let time=time::from_float(time).unwrap();
self.head.set_scale(time,scale.try_into().unwrap());
}
/// Set the playback head position to new_time.
#[wasm_bindgen]
pub fn seek_to(&mut self,time:f64,new_time:f64){
pub fn set_head_time(&mut self,time:f64,new_time:f64){
let time=time::from_float(time).unwrap();
let new_time=time::from_float(new_time).unwrap();
self.head.seek_to(time,new_time);
}
#[wasm_bindgen]
pub fn seek_forward(&mut self,time_offset:f64){
let time_offset=time::from_float(time_offset).unwrap();
self.head.seek_forward(time_offset);
}
#[wasm_bindgen]
pub fn seek_backward(&mut self,time_offset:f64){
let time_offset=time::from_float(time_offset).unwrap();
self.head.seek_backward(time_offset);
self.head.set_time(time,new_time);
}
#[wasm_bindgen]
pub fn get_fov_slope_y(&self)->f64{