diff --git a/Cargo.lock b/Cargo.lock index 6b4bdcc..8404efc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1632,9 +1632,9 @@ checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" [[package]] name = "strafesnet_common" -version = "0.8.2" +version = "0.8.3" source = "sparse+https://git.itzana.me/api/packages/strafesnet/cargo/" -checksum = "33f0b25c3987a82c68ec73690fe5309dc7737f20667f2f61e23a48bf9efb6e09" +checksum = "c51de04816a98559f315d57b8a13a3bc010e2dc9bb033906a424ec8d56601731" dependencies = [ "arrayvec", "bitflags 2.10.0", diff --git a/Cargo.toml b/Cargo.toml index 37e70a1..3476409 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,7 +12,7 @@ strip = true codegen-units = 1 [workspace.dependencies] -strafesnet_common = { version = "0.8.2", registry = "strafesnet" } +strafesnet_common = { version = "0.8.3", registry = "strafesnet" } strafesnet_graphics = { version = "0.0.2", registry = "strafesnet" } strafesnet_roblox_bot_file = { version = "0.9.0", registry = "strafesnet" } strafesnet_snf = { version = "0.3.2", registry = "strafesnet" } diff --git a/lib/src/head.rs b/lib/src/head.rs index 2814887..0e4a09c 100644 --- a/lib/src/head.rs +++ b/lib/src/head.rs @@ -1,7 +1,6 @@ use glam::Vec3Swizzles; use strafesnet_common::timer::{Scaled,Timer,TimerState}; use strafesnet_common::session::{Time as SessionTime,TimeInner as SessionTimeInner}; -use strafesnet_common::physics::{Time as PhysicsTime}; use strafesnet_roblox_bot_file::v0::{EventType,Head,Timed}; use crate::bot::CompleteBot; @@ -62,7 +61,7 @@ impl PlaybackHead{ } pub fn advance_time(&mut self,bot:&CompleteBot,time:SessionTime){ let mut simulation_time=bot.time(self.time(time)); - let mut time_float=simulation_time.get() as f64/PhysicsTime::ONE_SECOND.get() as f64; + let mut time_float=simulation_time.into(); loop{ match self.next_event(bot){ Some(next_event)=>{ @@ -84,7 +83,7 @@ impl PlaybackHead{ // update loop variables simulation_time-=bot.duration(); - time_float=simulation_time.get() as f64/PhysicsTime::ONE_SECOND.get() as f64; + time_float=simulation_time.into(); }, } } @@ -101,7 +100,7 @@ impl PlaybackHead{ // let a1=vector3_to_glam(&event1.event.acceleration); let t0=event0.time; let t1=event1.time; - let time_float=time.get() as f64/PhysicsTime::ONE_SECOND.get() as f64; + let time_float:f64=time.into(); let t=((time_float-t0)/(t1-t0)) as f32; let p=p0.lerp(p1,t); // let v=v0.lerp(v1,t); diff --git a/lib/src/state.rs b/lib/src/state.rs index f3512e1..3b8fed7 100644 --- a/lib/src/state.rs +++ b/lib/src/state.rs @@ -111,13 +111,13 @@ impl PlaybackState{ self.style=run_event_prepare.style; }, v0::RunEvent::Start(run_event_zone)=>{ - let time=PhysicsTime::raw((event.time*PhysicsTime::ONE_SECOND.get() as f64) as i64); + let time=crate::time::from_float(event.time).unwrap(); if let Some(run)=self.runs.get_mut(&run_event_zone.mode){ _=run.run.start(time); } }, v0::RunEvent::Finish(run_event_zone)=>{ - let time=PhysicsTime::raw((event.time*PhysicsTime::ONE_SECOND.get() as f64) as i64); + let time=crate::time::from_float(event.time).unwrap(); if let Some(run)=self.runs.get_mut(&run_event_zone.mode){ _=run.run.finish(time); } diff --git a/wasm-module/src/lib.rs b/wasm-module/src/lib.rs index b91d445..5ce8898 100644 --- a/wasm-module/src/lib.rs +++ b/wasm-module/src/lib.rs @@ -3,8 +3,6 @@ use wasm_bindgen::JsValue; use strafesnet_roblox_bot_file::v0; use strafesnet_roblox_bot_player::{bot,head,time,graphics}; use strafesnet_graphics::setup; -use strafesnet_common::physics::Time as PhysicsTime; -use strafesnet_common::run::Time as RunTime; // Hack to keep the code compiling, // SurfaceTarget::Canvas is not available in IDE for whatever reason. @@ -73,12 +71,12 @@ impl CompleteBot{ } #[wasm_bindgen] pub fn duration(&self)->f64{ - self.bot.duration().get() as f64/PhysicsTime::ONE_SECOND.get() as f64 + self.bot.duration().into() } #[wasm_bindgen] pub fn run_duration(&self,mode_id:u32)->Option{ let mode=v0::ModeID(mode_id); - Some(self.bot.run_duration(mode)?.get() as f64/RunTime::ONE_SECOND.get() as f64) + Some(self.bot.run_duration(mode)?.into()) } } @@ -132,7 +130,7 @@ impl PlaybackHead{ 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/PhysicsTime::ONE_SECOND.get() as f64 + time.into() } /// Set the playback head position to new_time. #[wasm_bindgen] @@ -147,7 +145,7 @@ impl PlaybackHead{ 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/RunTime::ONE_SECOND.get() as f64) + Some(run_time.into()) } #[wasm_bindgen] pub fn is_run_in_progress(&self,mode_id:u32)->Option{