invalid states unrepresentable

This commit is contained in:
Quaternions 2023-10-17 15:12:43 -07:00
parent edd15d0a09
commit 2d2f0099ab
3 changed files with 10 additions and 8 deletions

View File

@ -97,8 +97,8 @@ fn get_attributes(name:&str,can_collide:bool,velocity:Planar64Vec3,force_interse
true=>{ true=>{
match name{ match name{
"Bounce"=>contacting.elasticity=Some(u32::MAX), "Bounce"=>contacting.elasticity=Some(u32::MAX),
"Surf"=>contacting.surf=Some(crate::model::ContactingSurf{}), "Surf"=>contacting.contact_behaviour=Some(crate::model::ContactingBehaviour::Surf),
"Ladder"=>contacting.ladder=Some(crate::model::ContactingLadder{sticky:true}), "Ladder"=>contacting.contact_behaviour=Some(crate::model::ContactingBehaviour::Ladder(crate::model::ContactingLadder{sticky:true})),
other=>{ other=>{
if let Some(captures)=lazy_regex::regex!(r"^(Jump|WormholeIn)(\d+)$") if let Some(captures)=lazy_regex::regex!(r"^(Jump|WormholeIn)(\d+)$")
.captures(other){ .captures(other){

View File

@ -92,11 +92,14 @@ pub enum TempIndexedAttributes{
//you have this effect while in contact //you have this effect while in contact
#[derive(Clone)] #[derive(Clone)]
pub struct ContactingSurf{}
#[derive(Clone)]
pub struct ContactingLadder{ pub struct ContactingLadder{
pub sticky:bool pub sticky:bool
} }
#[derive(Clone)]
pub enum ContactingBehaviour{
Surf,
Ladder(ContactingLadder),
}
//you have this effect while intersecting //you have this effect while intersecting
#[derive(Clone)] #[derive(Clone)]
pub struct IntersectingWater{ pub struct IntersectingWater{
@ -175,8 +178,7 @@ pub struct GameMechanicAttributes{
pub struct ContactingAttributes{ pub struct ContactingAttributes{
pub elasticity:Option<u32>,//[1/2^32,1] 0=None (elasticity+1)/2^32 pub elasticity:Option<u32>,//[1/2^32,1] 0=None (elasticity+1)/2^32
//friction? //friction?
pub surf:Option<ContactingSurf>, pub contact_behaviour:Option<ContactingBehaviour>,
pub ladder:Option<ContactingLadder>,
} }
#[derive(Default,Clone)] #[derive(Default,Clone)]
pub struct IntersectingAttributes{ pub struct IntersectingAttributes{

View File

@ -1165,8 +1165,8 @@ impl crate::instruction::InstructionConsumer<PhysicsInstruction> for PhysicsStat
let model=c.model(&self.models).unwrap(); let model=c.model(&self.models).unwrap();
match &model.attributes{ match &model.attributes{
PhysicsCollisionAttributes::Contact{contacting,general}=>{ PhysicsCollisionAttributes::Contact{contacting,general}=>{
match &contacting.surf{ match &contacting.contact_behaviour{
Some(surf)=>println!("I'm surfing!"), Some(crate::model::ContactingBehaviour::Surf)=>println!("I'm surfing!"),
None=>match &c.face { None=>match &c.face {
TreyMeshFace::Top => { TreyMeshFace::Top => {
//ground //ground