diff --git a/lib/common/src/gameplay_attributes.rs b/lib/common/src/gameplay_attributes.rs index ff01731..09fd1e4 100644 --- a/lib/common/src/gameplay_attributes.rs +++ b/lib/common/src/gameplay_attributes.rs @@ -1,5 +1,5 @@ use crate::model; -use crate::integer::{Time,Planar64,Planar64Vec3}; +use crate::integer::{RawTime,Planar64,Planar64Vec3}; //you have this effect while in contact #[derive(Clone,Hash,Eq,PartialEq)] @@ -31,7 +31,7 @@ pub enum Booster{ //Affine(crate::integer::Planar64Affine3),//capable of SetVelocity,DotVelocity,normal booster,bouncy part,redirect velocity, and much more Velocity(Planar64Vec3),//straight up boost velocity adds to your current velocity Energy{direction:Planar64Vec3,energy:Planar64},//increase energy in direction - AirTime(Time),//increase airtime, invariant across mass and gravity changes + AirTime(RawTime),//increase airtime, invariant across mass and gravity changes Height(Planar64),//increase height, invariant across mass and gravity changes } impl Booster{ @@ -57,13 +57,13 @@ pub enum TrajectoryChoice{ #[derive(Clone,Hash,Eq,PartialEq)] pub enum SetTrajectory{ //Speed-type SetTrajectory - AirTime(Time),//air time (relative to gravity direction) is invariant across mass and gravity changes + AirTime(RawTime),//air time (relative to gravity direction) is invariant across mass and gravity changes Height(Planar64),//boost height (relative to gravity direction) is invariant across mass and gravity changes DotVelocity{direction:Planar64Vec3,dot:Planar64},//set your velocity in a specific direction without touching other directions //Velocity-type SetTrajectory TargetPointTime{//launch on a trajectory that will land at a target point in a set amount of time target_point:Planar64Vec3, - time:Time,//short time = fast and direct, long time = launch high in the air, negative time = wrong way + time:RawTime,//short time = fast and direct, long time = launch high in the air, negative time = wrong way }, TargetPointSpeed{//launch at a fixed speed and land at a target point target_point:Planar64Vec3, diff --git a/lib/common/src/gameplay_style.rs b/lib/common/src/gameplay_style.rs index ec49ce1..26a323a 100644 --- a/lib/common/src/gameplay_style.rs +++ b/lib/common/src/gameplay_style.rs @@ -1,7 +1,8 @@ const VALVE_SCALE:Planar64=Planar64::raw(1<<28);// 1/16 -use crate::integer::{int,vec3::int as int3,Time,Ratio64,Planar64,Planar64Vec3}; +use crate::integer::{int,vec3::int as int3,RawTime,Ratio64,Planar64,Planar64Vec3}; use crate::controls_bitflag::Controls; +use crate::physics::Time as PhysicsTime; #[derive(Clone,Debug)] pub struct StyleModifiers{ @@ -48,7 +49,7 @@ pub enum JumpCalculation{ #[derive(Clone,Debug)] pub enum JumpImpulse{ - Time(Time),//jump time is invariant across mass and gravity changes + Time(RawTime),//jump time is invariant across mass and gravity changes Height(Planar64),//jump height is invariant across mass and gravity changes Linear(Planar64),//jump velocity is invariant across mass and gravity changes Energy(Planar64),// :) @@ -272,8 +273,8 @@ impl StrafeSettings{ false=>None, } } - pub fn next_tick(&self,time:Time)->Time{ - Time::from_nanos(self.tick_rate.rhs_div_int(self.tick_rate.mul_int(time.nanos())+1)) + pub fn next_tick(&self,time:PhysicsTime)->PhysicsTime{ + PhysicsTime::from_nanos(self.tick_rate.rhs_div_int(self.tick_rate.mul_int(time.nanos())+1)) } pub const fn activates(&self,controls:Controls)->bool{ self.enable.activates(controls) @@ -435,7 +436,7 @@ impl StyleModifiers{ enable:ControlsActivation::full_2d(), air_accel_limit:None, mv:int(3), - tick_rate:Ratio64::new(64,Time::ONE_SECOND.nanos() as u64).unwrap(), + tick_rate:Ratio64::new(64,RawTime::ONE_SECOND.get() as u64).unwrap(), }), jump:Some(JumpSettings{ impulse:JumpImpulse::Energy(int(512)), @@ -477,10 +478,10 @@ impl StyleModifiers{ enable:ControlsActivation::full_2d(), air_accel_limit:None, mv:int(27)/10, - tick_rate:Ratio64::new(100,Time::ONE_SECOND.nanos() as u64).unwrap(), + tick_rate:Ratio64::new(100,RawTime::ONE_SECOND.get() as u64).unwrap(), }), jump:Some(JumpSettings{ - impulse:JumpImpulse::Time(Time::from_micros(715_588)), + impulse:JumpImpulse::Time(RawTime::from_micros(715_588)), calculation:JumpCalculation::Max, limit_minimum:true, }), @@ -534,7 +535,7 @@ impl StyleModifiers{ enable:ControlsActivation::full_2d(), air_accel_limit:Some(Planar64::raw(150<<28)*100), mv:(Planar64::raw(30)*VALVE_SCALE).fix_1(), - tick_rate:Ratio64::new(100,Time::ONE_SECOND.nanos() as u64).unwrap(), + tick_rate:Ratio64::new(100,RawTime::ONE_SECOND.get() as u64).unwrap(), }), jump:Some(JumpSettings{ impulse:JumpImpulse::Height((int(52)*VALVE_SCALE).fix_1()), @@ -575,7 +576,7 @@ impl StyleModifiers{ enable:ControlsActivation::full_2d(), air_accel_limit:Some((int(150)*66*VALVE_SCALE).fix_1()), mv:(int(30)*VALVE_SCALE).fix_1(), - tick_rate:Ratio64::new(66,Time::ONE_SECOND.nanos() as u64).unwrap(), + tick_rate:Ratio64::new(66,RawTime::ONE_SECOND.get() as u64).unwrap(), }), jump:Some(JumpSettings{ impulse:JumpImpulse::Height((int(52)*VALVE_SCALE).fix_1()), diff --git a/lib/common/src/instruction.rs b/lib/common/src/instruction.rs index df07598..cefc580 100644 --- a/lib/common/src/instruction.rs +++ b/lib/common/src/instruction.rs @@ -1,35 +1,41 @@ use crate::integer::Time; #[derive(Debug)] -pub struct TimedInstruction{ - pub time:Time, +pub struct TimedInstruction{ + pub time:Time, pub instruction:I, } -pub trait InstructionEmitter{ - fn next_instruction(&self,time_limit:Time)->Option>; +pub trait InstructionEmitter{ + type Instruction; + type TimeInner; + fn next_instruction(&self,time_limit:Time)->Option>; } -pub trait InstructionConsumer{ - fn process_instruction(&mut self, instruction:TimedInstruction); +pub trait InstructionConsumer{ + type Instruction; + type TimeInner; + fn process_instruction(&mut self, instruction:TimedInstruction); } //PROPER PRIVATE FIELDS!!! -pub struct InstructionCollector{ - time:Time, +pub struct InstructionCollector{ + time:Time, instruction:Option, } -impl InstructionCollector{ - pub const fn new(time:Time)->Self{ +impl InstructionCollector + where Time:Copy+PartialOrd, +{ + pub const fn new(time:Time)->Self{ Self{ time, instruction:None } } #[inline] - pub const fn time(&self)->Time{ + pub const fn time(&self)->Time{ self.time } - pub fn collect(&mut self,instruction:Option>){ + pub fn collect(&mut self,instruction:Option>){ match instruction{ Some(unwrap_instruction)=>{ if unwrap_instruction.time InstructionCollector{ None=>(), } } - pub fn instruction(self)->Option>{ + pub fn instruction(self)->Option>{ //STEAL INSTRUCTION AND DESTROY INSTRUCTIONCOLLECTOR match self.instruction{ Some(instruction)=>Some(TimedInstruction{ diff --git a/lib/common/src/mouse.rs b/lib/common/src/mouse.rs index c3795de..3ab0807 100644 --- a/lib/common/src/mouse.rs +++ b/lib/common/src/mouse.rs @@ -1,11 +1,11 @@ use crate::integer::Time; #[derive(Clone,Debug)] -pub struct MouseState{ +pub struct MouseState{ pub pos:glam::IVec2, - pub time:Time, + pub time:Time, } -impl Default for MouseState{ +impl Default for MouseState{ fn default()->Self{ Self{ time:Time::ZERO, @@ -13,8 +13,10 @@ impl Default for MouseState{ } } } -impl MouseState{ - pub fn lerp(&self,target:&MouseState,time:Time)->glam::IVec2{ +impl MouseState + where Time:Copy, +{ + pub fn lerp(&self,target:&MouseState,time:Time)->glam::IVec2{ let m0=self.pos.as_i64vec2(); let m1=target.pos.as_i64vec2(); //these are deltas diff --git a/lib/common/src/physics.rs b/lib/common/src/physics.rs index e3e7ac9..dc6be13 100644 --- a/lib/common/src/physics.rs +++ b/lib/common/src/physics.rs @@ -1,7 +1,11 @@ +#[derive(Clone,Copy,Hash,Eq,PartialEq,PartialOrd,Debug)] +pub enum TimeInner{} +pub type Time=crate::integer::Time; + #[derive(Clone,Debug)] pub enum Instruction{ - ReplaceMouse(crate::mouse::MouseState,crate::mouse::MouseState), - SetNextMouse(crate::mouse::MouseState), + ReplaceMouse(crate::mouse::MouseState,crate::mouse::MouseState), + SetNextMouse(crate::mouse::MouseState), SetMoveRight(bool), SetMoveUp(bool), SetMoveBack(bool), diff --git a/lib/common/src/run.rs b/lib/common/src/run.rs index ae0836a..cac44a1 100644 --- a/lib/common/src/run.rs +++ b/lib/common/src/run.rs @@ -1,5 +1,10 @@ use crate::timer::{TimerFixed,Realtime,Paused,Unpaused}; -use crate::integer::Time; + +use crate::physics::{TimeInner as PhysicsTimeInner,Time as PhysicsTime}; + +#[derive(Clone,Copy,Hash,Eq,PartialEq,PartialOrd,Debug)] +pub enum TimeInner{} +pub type Time=crate::integer::Time; #[derive(Clone,Copy,Debug)] pub enum FlagReason{ @@ -45,8 +50,8 @@ impl std::error::Error for Error{} #[derive(Clone,Copy,Debug)] enum RunState{ Created, - Started{timer:TimerFixed}, - Finished{timer:TimerFixed}, + Started{timer:TimerFixed,Unpaused>}, + Finished{timer:TimerFixed,Paused>}, } #[derive(Clone,Copy,Debug)] @@ -62,14 +67,14 @@ impl Run{ flagged:None, } } - pub fn time(&self,time:Time)->Time{ + pub fn time(&self,time:PhysicsTime)->Time{ match &self.state{ RunState::Created=>Time::ZERO, RunState::Started{timer}=>timer.time(time), RunState::Finished{timer}=>timer.time(time), } } - pub fn start(&mut self,time:Time)->Result<(),Error>{ + pub fn start(&mut self,time:PhysicsTime)->Result<(),Error>{ match &self.state{ RunState::Created=>{ self.state=RunState::Started{ @@ -81,7 +86,7 @@ impl Run{ RunState::Finished{..}=>Err(Error::AlreadyFinished), } } - pub fn finish(&mut self,time:Time)->Result<(),Error>{ + pub fn finish(&mut self,time:PhysicsTime)->Result<(),Error>{ //this uses Copy match &self.state{ RunState::Created=>Err(Error::NotStarted),