display run duration

This commit is contained in:
2026-02-20 08:52:31 -08:00
parent a238793cdc
commit 3dea810a50
4 changed files with 51 additions and 21 deletions

View File

@@ -1,5 +1,6 @@
use wasm_bindgen::prelude::wasm_bindgen;
use wasm_bindgen::JsValue;
use strafesnet_roblox_bot_file::v0;
use strafesnet_roblox_bot_player::{bot,map,head,time,graphics};
use strafesnet_graphics::setup;
use strafesnet_common::physics::Time as PhysicsTime;
@@ -72,6 +73,11 @@ impl CompleteBot{
pub fn duration(&self)->f64{
self.bot.duration().get() as f64/PhysicsTime::ONE_SECOND.get() as f64
}
#[wasm_bindgen]
pub fn run_duration(&self,mode_id:u32)->Option<f64>{
let mode=v0::ModeID(mode_id);
Some(self.bot.run_duration(mode)?.get() as f64/PhysicsTime::ONE_SECOND.get() as f64)
}
}
#[wasm_bindgen]
@@ -110,18 +116,18 @@ impl PlaybackHead{
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 mode=strafesnet_roblox_bot_file::v0::ModeID(mode_id);
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)
}
#[wasm_bindgen]
pub fn is_run_in_progress(&self,mode_id:u32)->Option<bool>{
let mode=strafesnet_roblox_bot_file::v0::ModeID(mode_id);
let mode=v0::ModeID(mode_id);
Some(self.head.state().get_run(mode)?.is_in_progress())
}
#[wasm_bindgen]
pub fn is_run_finished(&self,mode_id:u32)->Option<bool>{
let mode=strafesnet_roblox_bot_file::v0::ModeID(mode_id);
let mode=v0::ModeID(mode_id);
Some(self.head.state().get_run(mode)?.is_finished())
}
}