diff --git a/src/aabb.rs b/src/aabb.rs index 65e783f..4421eef 100644 --- a/src/aabb.rs +++ b/src/aabb.rs @@ -13,6 +13,9 @@ impl Default for Aabb { } impl Aabb{ + pub fn new(min:Planar64Vec3,max:Planar64Vec3)->Self{ + Self{min,max} + } pub fn grow(&mut self,point:Planar64Vec3){ self.min=self.min.min(point); self.max=self.max.max(point); @@ -43,4 +46,4 @@ impl Aabb{ // let d=self.max-self.min; // d.x*d.y*d.z // } -} \ No newline at end of file +} diff --git a/src/gameplay_modes.rs b/src/gameplay_modes.rs index e9ea2ca..872646e 100644 --- a/src/gameplay_modes.rs +++ b/src/gameplay_modes.rs @@ -71,7 +71,22 @@ pub struct Stage{ unordered_checkpoints:HashSet, } impl Stage{ - pub fn new(spawn:ModelId)->Self{ + pub fn new( + spawn:ModelId, + ordered_checkpoints_count:u32, + unordered_checkpoints_count:u32, + ordered_checkpoints:HashMap, + unordered_checkpoints:HashSet, + )->Self{ + Self{ + spawn, + ordered_checkpoints_count, + unordered_checkpoints_count, + ordered_checkpoints, + unordered_checkpoints, + } + } + pub fn empty(spawn:ModelId)->Self{ Self{ spawn, ordered_checkpoints_count:0, @@ -136,7 +151,22 @@ pub struct Mode{ elements:HashMap, } impl Mode{ - pub fn new(style:gameplay_style::StyleModifiers,start:ModelId)->Self{ + pub fn new( + style:gameplay_style::StyleModifiers, + start:ModelId, + zones:HashMap, + stages:Vec, + elements:HashMap, + )->Self{ + Self{ + style, + start, + zones, + stages, + elements, + } + } + pub fn empty(style:gameplay_style::StyleModifiers,start:ModelId)->Self{ Self{ style, start, @@ -269,4 +299,4 @@ impl Updatable for Modes{ } } } -} \ No newline at end of file +} diff --git a/src/gameplay_style.rs b/src/gameplay_style.rs index 944eab4..d7c826e 100644 --- a/src/gameplay_style.rs +++ b/src/gameplay_style.rs @@ -15,7 +15,7 @@ pub struct StyleModifiers{ pub rocket:Option, //flying //pub move_type:MoveType::Fly(FlySettings) - //MoveType::Physics(PhysicsSettings) -> PhysicsSettings includes gravity + //MoveType::Physics(PhysicsSettings) -> PhysicsSettings (strafe,rocket,jump,walk,ladder,swim,gravity) //jumping is allowed pub jump:Option, //standing & walking is allowed @@ -168,6 +168,14 @@ pub struct StrafeSettings{ tick_rate:Ratio64, } impl StrafeSettings{ + pub fn new( + enable:ControlsActivation, + mv:Planar64, + air_accel_limit:Option, + tick_rate:Ratio64, + )->Self{ + Self{enable,mv,air_accel_limit,tick_rate} + } pub fn tick_velocity(&self,velocity:Planar64Vec3,control_dir:Planar64Vec3)->Option{ let d=velocity.dot(control_dir); match dSelf{ + Self{magnitude} + } pub fn acceleration(&self,control_dir:Planar64Vec3)->Planar64Vec3{ control_dir*self.magnitude } @@ -204,6 +215,12 @@ pub struct JumpSettings{ calculation:JumpCalculation, } impl JumpSettings{ + pub fn new( + impulse:JumpImpulse, + calculation:JumpCalculation, + )->Self{ + Self{impulse,calculation} + } pub fn jumped_velocity(&self,style:&StyleModifiers,jump_dir:Planar64Vec3,velocity:Planar64Vec3)->Planar64Vec3{ match self.calculation{ //roblox style @@ -221,6 +238,14 @@ pub struct AccelerateSettings{ accel:Planar64, topspeed:Planar64, } +impl AccelerateSettings{ + pub fn new( + accel:Planar64, + topspeed:Planar64, + )->Self{ + Self{accel,topspeed} + } +} #[derive(Clone,Debug)] pub struct WalkSettings{ accelerate:AccelerateSettings, @@ -230,6 +255,14 @@ pub struct WalkSettings{ surf_dot:Planar64,//surf_dotSelf{ + Self{accelerate,static_friction,kinetic_friction,surf_dot} + } pub fn accel(&self,target_diff:Planar64Vec3,gravity:Planar64Vec3)->Planar64{ //TODO: fallible walk accel let diff_len=target_diff.length(); @@ -275,6 +308,12 @@ pub struct LadderSettings{ dot:Planar64, } impl LadderSettings{ + pub fn new( + accelerate:AccelerateSettings, + dot:Planar64, + )->Self{ + Self{accelerate,dot} + } pub fn accel(&self,target_diff:Planar64Vec3,gravity:Planar64Vec3)->Planar64{ //TODO: fallible ladder accel self.accelerate.accel diff --git a/src/integer.rs b/src/integer.rs index 9d44cce..35153e2 100644 --- a/src/integer.rs +++ b/src/integer.rs @@ -10,6 +10,10 @@ impl Time{ pub const ONE_MICROSECOND:Self=Self(1_000); pub const ONE_NANOSECOND:Self=Self(1); #[inline] + pub const fn raw(num:i64)->Self{ + Self(num) + } + #[inline] pub const fn from_secs(num:i64)->Self{ Self(Self::ONE_SECOND.0*num) } @@ -1046,4 +1050,4 @@ fn test_sqrt(){ assert_eq!(1717986918400,r.get()); let s=r.sqrt(); assert_eq!(85899345920,s.get()); -} \ No newline at end of file +}