This commit is contained in:
2026-02-23 06:56:42 -08:00
parent 87fa1220c6
commit cb7474522f
4 changed files with 4 additions and 8 deletions

View File

@@ -52,6 +52,7 @@ impl PlaybackHead{
} }
pub fn seek_to(&mut self,time:SessionTime,new_time:PhysicsTime){ pub fn seek_to(&mut self,time:SessionTime,new_time:PhysicsTime){
self.timer.set_time(time,new_time); self.timer.set_time(time,new_time);
self.loop_offset=PhysicsTime::ZERO;
// reset head // reset head
self.head=HEAD_NO_CRASH; self.head=HEAD_NO_CRASH;
} }

View File

@@ -1,5 +1,6 @@
use strafesnet_common::instruction::TimedInstruction; use strafesnet_common::instruction::TimedInstruction;
use strafesnet_common::session::Time as SessionTime; use strafesnet_common::session::Time as SessionTime;
use strafesnet_common::physics::Time as PhysicsTime;
use strafesnet_roblox_bot_player::{bot::CompleteBot,graphics::Graphics,head::PlaybackHead}; use strafesnet_roblox_bot_player::{bot::CompleteBot,graphics::Graphics,head::PlaybackHead};
pub enum SessionControlInstruction{ pub enum SessionControlInstruction{
@@ -54,9 +55,7 @@ impl<'a> PlayerWorker<'a>{
self.playback_head.set_paused(ins.time,paused); self.playback_head.set_paused(ins.time,paused);
}, },
Instruction::SessionControl(SessionControlInstruction::Restart)=>{ Instruction::SessionControl(SessionControlInstruction::Restart)=>{
if let Some(bot)=&self.bot{ self.playback_head.seek_to(ins.time,PhysicsTime::ZERO);
self.playback_head.seek_to(ins.time,bot.time_base());
}
}, },
Instruction::SessionControl(SessionControlInstruction::SkipForward)=>{ Instruction::SessionControl(SessionControlInstruction::SkipForward)=>{
self.playback_head.seek_forward(SessionTime::from_secs(2)); self.playback_head.seek_forward(SessionTime::from_secs(2));

View File

@@ -71,10 +71,6 @@ impl CompleteBot{
}) })
} }
#[wasm_bindgen] #[wasm_bindgen]
pub fn time_base(&self)->f64{
self.bot.time_base().get() as f64/PhysicsTime::ONE_SECOND.get() as f64
}
#[wasm_bindgen]
pub fn duration(&self)->f64{ pub fn duration(&self)->f64{
self.bot.duration().get() as f64/PhysicsTime::ONE_SECOND.get() as f64 self.bot.duration().get() as f64/PhysicsTime::ONE_SECOND.get() as f64
} }

View File

@@ -53,7 +53,7 @@ function speed_ratio(speed) {
// Controls // Controls
document.getElementById("control_reset").addEventListener("click", (e) => { document.getElementById("control_reset").addEventListener("click", (e) => {
playback.seek_to(elapsed(), bot.time_base()); playback.seek_to(elapsed(), 0.0);
}); });
document.getElementById("control_pause").addEventListener("click", (e) => { document.getElementById("control_pause").addEventListener("click", (e) => {
paused = !paused; paused = !paused;