From 2d2f0099abf2424daaed461a6bb013127a2279ec Mon Sep 17 00:00:00 2001 From: Quaternions Date: Tue, 17 Oct 2023 15:12:43 -0700 Subject: [PATCH] invalid states unrepresentable --- src/load_roblox.rs | 4 ++-- src/model.rs | 10 ++++++---- src/physics.rs | 4 ++-- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/load_roblox.rs b/src/load_roblox.rs index 6564b49..3fd1c68 100644 --- a/src/load_roblox.rs +++ b/src/load_roblox.rs @@ -97,8 +97,8 @@ fn get_attributes(name:&str,can_collide:bool,velocity:Planar64Vec3,force_interse true=>{ match name{ "Bounce"=>contacting.elasticity=Some(u32::MAX), - "Surf"=>contacting.surf=Some(crate::model::ContactingSurf{}), - "Ladder"=>contacting.ladder=Some(crate::model::ContactingLadder{sticky:true}), + "Surf"=>contacting.contact_behaviour=Some(crate::model::ContactingBehaviour::Surf), + "Ladder"=>contacting.contact_behaviour=Some(crate::model::ContactingBehaviour::Ladder(crate::model::ContactingLadder{sticky:true})), other=>{ if let Some(captures)=lazy_regex::regex!(r"^(Jump|WormholeIn)(\d+)$") .captures(other){ diff --git a/src/model.rs b/src/model.rs index 802dee4..edde0b3 100644 --- a/src/model.rs +++ b/src/model.rs @@ -92,11 +92,14 @@ pub enum TempIndexedAttributes{ //you have this effect while in contact #[derive(Clone)] -pub struct ContactingSurf{} -#[derive(Clone)] pub struct ContactingLadder{ pub sticky:bool } +#[derive(Clone)] +pub enum ContactingBehaviour{ + Surf, + Ladder(ContactingLadder), +} //you have this effect while intersecting #[derive(Clone)] pub struct IntersectingWater{ @@ -175,8 +178,7 @@ pub struct GameMechanicAttributes{ pub struct ContactingAttributes{ pub elasticity:Option,//[1/2^32,1] 0=None (elasticity+1)/2^32 //friction? - pub surf:Option, - pub ladder:Option, + pub contact_behaviour:Option, } #[derive(Default,Clone)] pub struct IntersectingAttributes{ diff --git a/src/physics.rs b/src/physics.rs index 7987db7..9326d78 100644 --- a/src/physics.rs +++ b/src/physics.rs @@ -1165,8 +1165,8 @@ impl crate::instruction::InstructionConsumer for PhysicsStat let model=c.model(&self.models).unwrap(); match &model.attributes{ PhysicsCollisionAttributes::Contact{contacting,general}=>{ - match &contacting.surf{ - Some(surf)=>println!("I'm surfing!"), + match &contacting.contact_behaviour{ + Some(crate::model::ContactingBehaviour::Surf)=>println!("I'm surfing!"), None=>match &c.face { TreyMeshFace::Top => { //ground