From eebde9b54a0971a673d6d45ac8737dcaf58b56cf Mon Sep 17 00:00:00 2001 From: Quaternions Date: Wed, 7 Aug 2024 14:43:34 -0700 Subject: [PATCH] this should all be pub --- src/gameplay_style.rs | 116 +++++++----------------------------------- 1 file changed, 18 insertions(+), 98 deletions(-) diff --git a/src/gameplay_style.rs b/src/gameplay_style.rs index 02c0d66..f03b226 100644 --- a/src/gameplay_style.rs +++ b/src/gameplay_style.rs @@ -75,34 +75,14 @@ impl JumpImpulse{ #[derive(Clone,Debug)] pub struct ControlsActivation{ //allowed keys - controls_mask:Controls, + pub controls_mask:Controls, //allow strafing only if any of the masked controls are held, eg W|S for shsw - controls_intersects:Controls, + pub controls_intersects:Controls, //allow strafing only if all of the masked controls are held, eg W for hsw, w-only - controls_contains:Controls, + pub controls_contains:Controls, //Function(Boxbool>), } impl ControlsActivation{ - pub const fn new( - controls_mask:Controls, - controls_intersects:Controls, - controls_contains:Controls, - )->Self{ - Self{ - controls_mask, - controls_intersects, - controls_contains, - } - } - pub const fn controls_mask(&self)->Controls{ - self.controls_mask - } - pub const fn controls_intersects(&self)->Controls{ - self.controls_intersects - } - pub const fn controls_contains(&self)->Controls{ - self.controls_contains - } pub const fn mask(&self,controls:Controls)->Controls{ controls.intersection(self.controls_mask) } @@ -171,23 +151,12 @@ impl ControlsActivation{ #[derive(Clone,Debug)] pub struct StrafeSettings{ - enable:ControlsActivation, - mv:Planar64, - air_accel_limit:Option, - tick_rate:Ratio64, + pub enable:ControlsActivation, + pub mv:Planar64, + pub air_accel_limit:Option, + pub tick_rate:Ratio64, } impl StrafeSettings{ - pub const fn new( - enable:ControlsActivation, - mv:Planar64, - air_accel_limit:Option, - tick_rate:Ratio64, - )->Self{ - Self{enable,mv,air_accel_limit,tick_rate} - } - pub fn into_inner(self)->(ControlsActivation,Planar64,Option,Ratio64){ - (self.enable,self.mv,self.air_accel_limit,self.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 magnitude(&self)->Planar64{ - self.magnitude - } pub fn acceleration(&self,control_dir:Planar64Vec3)->Planar64Vec3{ control_dir*self.magnitude } @@ -225,20 +188,11 @@ impl PropulsionSettings{ #[derive(Clone,Debug)] pub struct JumpSettings{ //information used to calculate jump power - impulse:JumpImpulse, + pub impulse:JumpImpulse, //information used to calculate jump behaviour - calculation:JumpCalculation, + pub calculation:JumpCalculation, } impl JumpSettings{ - pub const fn new( - impulse:JumpImpulse, - calculation:JumpCalculation, - )->Self{ - Self{impulse,calculation} - } - pub fn into_inner(self)->(JumpImpulse,JumpCalculation){ - (self.impulse,self.calculation) - } pub fn jumped_velocity(&self,style:&StyleModifiers,jump_dir:Planar64Vec3,velocity:Planar64Vec3)->Planar64Vec3{ match self.calculation{ //roblox style @@ -253,43 +207,18 @@ impl JumpSettings{ #[derive(Clone,Debug)] pub struct AccelerateSettings{ - accel:Planar64, - topspeed:Planar64, -} -impl AccelerateSettings{ - pub const fn new( - accel:Planar64, - topspeed:Planar64, - )->Self{ - Self{accel,topspeed} - } - pub const fn accel(&self)->Planar64{ - self.accel - } - pub const fn topspeed(&self)->Planar64{ - self.topspeed - } + pub accel:Planar64, + pub topspeed:Planar64, } #[derive(Clone,Debug)] pub struct WalkSettings{ - accelerate:AccelerateSettings, - static_friction:Planar64, - kinetic_friction:Planar64, + pub accelerate:AccelerateSettings, + pub static_friction:Planar64, + pub kinetic_friction:Planar64, //if a surf slope angle does not exist, then everything is slippery and walking is impossible - surf_dot:Planar64,//surf_dotSelf{ - Self{accelerate,static_friction,kinetic_friction,surf_dot} - } - pub fn into_inner(self)->(AccelerateSettings,Planar64,Planar64,Planar64){ - (self.accelerate,self.static_friction,self.kinetic_friction,self.surf_dot) - } pub fn accel(&self,target_diff:Planar64Vec3,gravity:Planar64Vec3)->Planar64{ //TODO: fallible walk accel let diff_len=target_diff.length(); @@ -329,21 +258,12 @@ impl WalkSettings{ #[derive(Clone,Debug)] pub struct LadderSettings{ - accelerate:AccelerateSettings, + pub accelerate:AccelerateSettings, //how close to pushing directly into/out of the ladder normal //does your input need to be to redirect straight up/down the ladder - dot:Planar64, + pub dot:Planar64, } impl LadderSettings{ - pub const fn new( - accelerate:AccelerateSettings, - dot:Planar64, - )->Self{ - Self{accelerate,dot} - } - pub fn into_inner(self)->(AccelerateSettings,Planar64){ - (self.accelerate,self.dot) - } pub const fn accel(&self,target_diff:Planar64Vec3,gravity:Planar64Vec3)->Planar64{ //TODO: fallible ladder accel self.accelerate.accel