this should all be pub
This commit is contained in:
parent
7d1058164b
commit
eebde9b54a
@ -75,34 +75,14 @@ impl JumpImpulse{
|
|||||||
#[derive(Clone,Debug)]
|
#[derive(Clone,Debug)]
|
||||||
pub struct ControlsActivation{
|
pub struct ControlsActivation{
|
||||||
//allowed keys
|
//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
|
//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
|
//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(Box<dyn Fn(u32)->bool>),
|
//Function(Box<dyn Fn(u32)->bool>),
|
||||||
}
|
}
|
||||||
impl ControlsActivation{
|
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{
|
pub const fn mask(&self,controls:Controls)->Controls{
|
||||||
controls.intersection(self.controls_mask)
|
controls.intersection(self.controls_mask)
|
||||||
}
|
}
|
||||||
@ -171,23 +151,12 @@ impl ControlsActivation{
|
|||||||
|
|
||||||
#[derive(Clone,Debug)]
|
#[derive(Clone,Debug)]
|
||||||
pub struct StrafeSettings{
|
pub struct StrafeSettings{
|
||||||
enable:ControlsActivation,
|
pub enable:ControlsActivation,
|
||||||
mv:Planar64,
|
pub mv:Planar64,
|
||||||
air_accel_limit:Option<Planar64>,
|
pub air_accel_limit:Option<Planar64>,
|
||||||
tick_rate:Ratio64,
|
pub tick_rate:Ratio64,
|
||||||
}
|
}
|
||||||
impl StrafeSettings{
|
impl StrafeSettings{
|
||||||
pub const fn new(
|
|
||||||
enable:ControlsActivation,
|
|
||||||
mv:Planar64,
|
|
||||||
air_accel_limit:Option<Planar64>,
|
|
||||||
tick_rate:Ratio64,
|
|
||||||
)->Self{
|
|
||||||
Self{enable,mv,air_accel_limit,tick_rate}
|
|
||||||
}
|
|
||||||
pub fn into_inner(self)->(ControlsActivation,Planar64,Option<Planar64>,Ratio64){
|
|
||||||
(self.enable,self.mv,self.air_accel_limit,self.tick_rate)
|
|
||||||
}
|
|
||||||
pub fn tick_velocity(&self,velocity:Planar64Vec3,control_dir:Planar64Vec3)->Option<Planar64Vec3>{
|
pub fn tick_velocity(&self,velocity:Planar64Vec3,control_dir:Planar64Vec3)->Option<Planar64Vec3>{
|
||||||
let d=velocity.dot(control_dir);
|
let d=velocity.dot(control_dir);
|
||||||
match d<self.mv{
|
match d<self.mv{
|
||||||
@ -208,15 +177,9 @@ impl StrafeSettings{
|
|||||||
|
|
||||||
#[derive(Clone,Debug)]
|
#[derive(Clone,Debug)]
|
||||||
pub struct PropulsionSettings{
|
pub struct PropulsionSettings{
|
||||||
magnitude:Planar64,
|
pub magnitude:Planar64,
|
||||||
}
|
}
|
||||||
impl PropulsionSettings{
|
impl PropulsionSettings{
|
||||||
pub const fn new(magnitude:Planar64)->Self{
|
|
||||||
Self{magnitude}
|
|
||||||
}
|
|
||||||
pub fn magnitude(&self)->Planar64{
|
|
||||||
self.magnitude
|
|
||||||
}
|
|
||||||
pub fn acceleration(&self,control_dir:Planar64Vec3)->Planar64Vec3{
|
pub fn acceleration(&self,control_dir:Planar64Vec3)->Planar64Vec3{
|
||||||
control_dir*self.magnitude
|
control_dir*self.magnitude
|
||||||
}
|
}
|
||||||
@ -225,20 +188,11 @@ impl PropulsionSettings{
|
|||||||
#[derive(Clone,Debug)]
|
#[derive(Clone,Debug)]
|
||||||
pub struct JumpSettings{
|
pub struct JumpSettings{
|
||||||
//information used to calculate jump power
|
//information used to calculate jump power
|
||||||
impulse:JumpImpulse,
|
pub impulse:JumpImpulse,
|
||||||
//information used to calculate jump behaviour
|
//information used to calculate jump behaviour
|
||||||
calculation:JumpCalculation,
|
pub calculation:JumpCalculation,
|
||||||
}
|
}
|
||||||
impl JumpSettings{
|
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{
|
pub fn jumped_velocity(&self,style:&StyleModifiers,jump_dir:Planar64Vec3,velocity:Planar64Vec3)->Planar64Vec3{
|
||||||
match self.calculation{
|
match self.calculation{
|
||||||
//roblox style
|
//roblox style
|
||||||
@ -253,43 +207,18 @@ impl JumpSettings{
|
|||||||
|
|
||||||
#[derive(Clone,Debug)]
|
#[derive(Clone,Debug)]
|
||||||
pub struct AccelerateSettings{
|
pub struct AccelerateSettings{
|
||||||
accel:Planar64,
|
pub accel:Planar64,
|
||||||
topspeed:Planar64,
|
pub 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
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#[derive(Clone,Debug)]
|
#[derive(Clone,Debug)]
|
||||||
pub struct WalkSettings{
|
pub struct WalkSettings{
|
||||||
accelerate:AccelerateSettings,
|
pub accelerate:AccelerateSettings,
|
||||||
static_friction:Planar64,
|
pub static_friction:Planar64,
|
||||||
kinetic_friction:Planar64,
|
pub kinetic_friction:Planar64,
|
||||||
//if a surf slope angle does not exist, then everything is slippery and walking is impossible
|
//if a surf slope angle does not exist, then everything is slippery and walking is impossible
|
||||||
surf_dot:Planar64,//surf_dot<n.dot(up)/n.length()
|
pub surf_dot:Planar64,//surf_dot<n.dot(up)/n.length()
|
||||||
}
|
}
|
||||||
impl WalkSettings{
|
impl WalkSettings{
|
||||||
pub const fn new(
|
|
||||||
accelerate:AccelerateSettings,
|
|
||||||
static_friction:Planar64,
|
|
||||||
kinetic_friction:Planar64,
|
|
||||||
surf_dot:Planar64,
|
|
||||||
)->Self{
|
|
||||||
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{
|
pub fn accel(&self,target_diff:Planar64Vec3,gravity:Planar64Vec3)->Planar64{
|
||||||
//TODO: fallible walk accel
|
//TODO: fallible walk accel
|
||||||
let diff_len=target_diff.length();
|
let diff_len=target_diff.length();
|
||||||
@ -329,21 +258,12 @@ impl WalkSettings{
|
|||||||
|
|
||||||
#[derive(Clone,Debug)]
|
#[derive(Clone,Debug)]
|
||||||
pub struct LadderSettings{
|
pub struct LadderSettings{
|
||||||
accelerate:AccelerateSettings,
|
pub accelerate:AccelerateSettings,
|
||||||
//how close to pushing directly into/out of the ladder normal
|
//how close to pushing directly into/out of the ladder normal
|
||||||
//does your input need to be to redirect straight up/down the ladder
|
//does your input need to be to redirect straight up/down the ladder
|
||||||
dot:Planar64,
|
pub dot:Planar64,
|
||||||
}
|
}
|
||||||
impl LadderSettings{
|
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{
|
pub const fn accel(&self,target_diff:Planar64Vec3,gravity:Planar64Vec3)->Planar64{
|
||||||
//TODO: fallible ladder accel
|
//TODO: fallible ladder accel
|
||||||
self.accelerate.accel
|
self.accelerate.accel
|
||||||
|
Loading…
Reference in New Issue
Block a user