From 2e88ae0612fb2031414ba49ae46e8e1965a2fe4a Mon Sep 17 00:00:00 2001 From: Quaternions Date: Tue, 7 Jan 2025 20:30:13 -0800 Subject: [PATCH] wip --- strafe-client/src/mouse_interpolator.rs | 15 ++++----------- strafe-client/src/physics_worker.rs | 15 +++++++++------ 2 files changed, 13 insertions(+), 17 deletions(-) diff --git a/strafe-client/src/mouse_interpolator.rs b/strafe-client/src/mouse_interpolator.rs index 25cfd21..37ec583 100644 --- a/strafe-client/src/mouse_interpolator.rs +++ b/strafe-client/src/mouse_interpolator.rs @@ -29,8 +29,6 @@ pub enum Instruction{ //Graphics(crate::graphics_worker::Instruction), } pub struct MouseInterpolator{ - //"PlayerController" - user_settings:crate::settings::UserSettings, //"MouseInterpolator" timeline:std::collections::VecDeque>, last_mouse_time:Time,//this value is pre-transformed to simulation time @@ -40,27 +38,22 @@ pub struct MouseInterpolator{ } impl instruction::InstructionConsumer for MouseInterpolator{ fn process_instruction(&mut self,ins:TimedInstruction){ - atomic_state_update(&mut self,ins) + self.atomic_state_update(ins) } } impl instruction::InstructionEmitter for MouseInterpolator{ fn next_instruction(&self,time_limit:Time)->Option>{ - next_instruction_internal(&self,time_limit) + self.next_instruction_internal(time_limit) } } impl MouseInterpolator{ - pub fn new( - physics:crate::physics::PhysicsContext, - user_settings:crate::settings::UserSettings, - )->MouseInterpolator{ - MouseInterpolator{ + pub fn new( )->Self{ + Self{ mouse_blocking:true, last_mouse_time:physics.get_next_mouse().time, timeline:std::collections::VecDeque::new(), timer:Timer::from_state(Scaled::identity(),false), - physics, - user_settings, } } fn push_mouse_instruction(&mut self,ins:&TimedInstruction,m:glam::IVec2){ diff --git a/strafe-client/src/physics_worker.rs b/strafe-client/src/physics_worker.rs index 7c48b9d..8113b29 100644 --- a/strafe-client/src/physics_worker.rs +++ b/strafe-client/src/physics_worker.rs @@ -1,26 +1,29 @@ -use strafesnet_common::instruction::TimedInstruction; +use crate::session::SessionState; + +type TimedSessionInstruction=strafesnet_common::instruction::TimedInstruction; pub fn new<'a>( mut graphics_worker:crate::compat_worker::INWorker<'a,crate::graphics_worker::Instruction>, user_settings:crate::settings::UserSettings, )->crate::compat_worker::QNWorker<'a,TimedInstruction>{ let physics=crate::physics::PhysicsContext::default(); - let mut interpolator=MouseInterpolator::new( + let mouse_interpolator=crate::mouse_interpolator::MouseInterpolator::new(); + let mut session=SessionState::new( physics, user_settings ); crate::compat_worker::QNWorker::new(move |ins:TimedInstruction|{ - interpolator.handle_instruction(&ins); + session.handle_instruction(&ins); match ins.instruction{ Instruction::Render=>{ - let frame_state=interpolator.get_frame_state(ins.time); + let frame_state=session.get_frame_state(ins.time); graphics_worker.send(crate::graphics_worker::Instruction::Render(frame_state)).unwrap(); }, Instruction::Resize(size)=>{ - graphics_worker.send(crate::graphics_worker::Instruction::Resize(size,interpolator.user_settings().clone())).unwrap(); + graphics_worker.send(crate::graphics_worker::Instruction::Resize(size,session.user_settings().clone())).unwrap(); }, Instruction::ChangeMap(map)=>{ - interpolator.change_map(ins.time,&map); + session.change_map(ins.time,&map); graphics_worker.send(crate::graphics_worker::Instruction::ChangeMap(map)).unwrap(); }, Instruction::Input(_)=>(),