This commit is contained in:
Quaternions 2025-01-08 01:08:41 -08:00
parent 3f0e3e0d3c
commit 5072e5d7a8

View File

@ -1,8 +1,7 @@
use strafesnet_common::mouse::MouseState; use strafesnet_common::mouse::MouseState;
use strafesnet_common::physics::{Instruction as PhysicsInputInstruction,Time as PhysicsTime,TimeInner as PhysicsTimeInner}; use strafesnet_common::physics::{Instruction as PhysicsInputInstruction,Time as PhysicsTime,TimeInner as PhysicsTimeInner};
use strafesnet_common::session::{Time as SessionTime,TimeInner as SessionTimeInner}; use strafesnet_common::session::{Time as SessionTime,TimeInner as SessionTimeInner};
use strafesnet_common::instruction::TimedInstruction; use strafesnet_common::instruction::{self,TimedInstruction};
use strafesnet_common::timer::{Scaled,Timer,TimerState};
#[derive(Debug)] #[derive(Debug)]
pub enum InputInstruction{ pub enum InputInstruction{
@ -34,11 +33,23 @@ pub struct MouseInterpolator{
last_mouse_time:PhysicsTime, last_mouse_time:PhysicsTime,
mouse_blocking:bool, mouse_blocking:bool,
} }
impl instruction::InstructionConsumer for MouseInterpolator{
type Instruction=Instruction;
type TimeInner=SessionTimeInner;
fn process_instruction(&mut self,ins:TimedInstruction<Instruction,SessionTimeInner>){
self.atomic_state_update(ins)
}
}
// InstructionEmitter does not make sense for MouseInterpolator, because it can emit multiple instructions.
impl instruction::InstructionEmitter for MouseInterpolator{
type Instruction=PhysicsInputInstruction;
type TimeInner=PhysicsTimeInner;
fn next_instruction(&self,time_limit:PhysicsTime)->Option<TimedInstruction<PhysicsInputInstruction,PhysicsTimeInner>>{
self.next_instruction_internal(time_limit)
}
}
impl MouseInterpolator{ impl MouseInterpolator{
pub fn new( pub fn new()->MouseInterpolator{
physics:crate::physics::PhysicsContext,
user_settings:crate::settings::UserSettings,
)->MouseInterpolator{
MouseInterpolator{ MouseInterpolator{
mouse_blocking:true, mouse_blocking:true,
last_mouse_time:physics.get_next_mouse().time, last_mouse_time:physics.get_next_mouse().time,