From 62dfe23539efe6b815e603e675c91cb73d0edb81 Mon Sep 17 00:00:00 2001 From: Quaternions Date: Mon, 6 Jan 2025 21:05:25 -0800 Subject: [PATCH] prevent hitting side of spawn from updating current stage --- strafe-client/src/physics.rs | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/strafe-client/src/physics.rs b/strafe-client/src/physics.rs index fbf4d39..1d09a62 100644 --- a/strafe-client/src/physics.rs +++ b/strafe-client/src/physics.rs @@ -1583,6 +1583,18 @@ fn run_teleport_behaviour( } } +fn not_spawn_at( + mode:Option<&gameplay_modes::Mode>, + model_id:ModelId, +)->bool{ + if let Some(mode)=mode{ + if let Some(stage_element)=mode.get_element(model_id){ + return stage_element.behaviour()!=gameplay_modes::StageElementBehaviour::SpawnAt; + } + } + true +} + fn collision_start_contact( move_state:&mut MoveState, body:&mut Body, @@ -1605,6 +1617,8 @@ fn collision_start_contact( touching.insert(Collision::Contact(contact)); //clip v set_velocity(body,touching,models,hitbox_mesh,incident_velocity); + let model_id=contact.model_id.into(); + let mut allow_run_teleport_behaviour=not_spawn_at(mode,model_id); match &attr.contacting.contact_behaviour{ Some(gameplay_attributes::ContactingBehaviour::Surf)=>println!("I'm surfing!"), Some(gameplay_attributes::ContactingBehaviour::Cling)=>println!("Unimplemented!"), @@ -1628,6 +1642,7 @@ fn collision_start_contact( Some(gameplay_attributes::ContactingBehaviour::NoJump)=>todo!("nyi"), None=>if let Some(walk_settings)=&style.walk{ if walk_settings.is_slope_walkable(contact_normal(models,hitbox_mesh,&contact),vec3::Y){ + allow_run_teleport_behaviour=true; //ground let (gravity,target_velocity)=ground_things(walk_settings,&contact,touching,models,hitbox_mesh,style,camera,input_state); let walk_state=ContactMoveState::ground(walk_settings,body,gravity,target_velocity,contact); @@ -1636,7 +1651,9 @@ fn collision_start_contact( }, } //I love making functions with 10 arguments to dodge the borrow checker - run_teleport_behaviour(contact.model_id.into(),attr.general.wormhole.as_ref(),mode,move_state,body,touching,run,mode_state,models,hitbox_mesh,bvh,style,camera,input_state,time); + if allow_run_teleport_behaviour{ + run_teleport_behaviour(model_id,attr.general.wormhole.as_ref(),mode,move_state,body,touching,run,mode_state,models,hitbox_mesh,bvh,style,camera,input_state,time); + } if style.get_control(Controls::Jump,input_state.controls){ if let (Some(jump_settings),Some(walk_state))=(&style.jump,move_state.get_walk_state()){ let jump_dir=walk_state.jump_direction.direction(models,hitbox_mesh,&walk_state.contact);