From 46db92acd022bcae2645e2967aee4fa9c88e155d Mon Sep 17 00:00:00 2001 From: Quaternions Date: Mon, 19 Aug 2024 16:41:23 -0700 Subject: [PATCH] tweak teleport_to_spawn --- src/physics.rs | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/physics.rs b/src/physics.rs index a3d99c4..81c98f4 100644 --- a/src/physics.rs +++ b/src/physics.rs @@ -1398,10 +1398,9 @@ fn teleport( } enum TeleportToSpawnError{ NoModel, - NoSpawn, } fn teleport_to_spawn( - stage_id:gameplay_modes::StageId, + stage:&gameplay_modes::Stage, move_state:&mut MoveState, body:&mut Body, touching:&mut TouchingState, @@ -1416,8 +1415,7 @@ fn teleport_to_spawn( input_state:&InputState, time:Time, )->Result<(),TeleportToSpawnError>{ - let model_id=mode.get_spawn_model_id(stage_id).ok_or(TeleportToSpawnError::NoSpawn)?; - let transform=models.get_model_transform(model_id).ok_or(TeleportToSpawnError::NoModel)?; + let transform=models.get_model_transform(stage.spawn()).ok_or(TeleportToSpawnError::NoModel)?; let point=transform.vertex.transform_point3(Planar64Vec3::Y)+Planar64Vec3::Y*(style.hitbox.halfsize.y()+Planar64::ONE/16); teleport(point,move_state,body,touching,run,mode_state,Some(mode),models,hitbox_mesh,bvh,style,camera,input_state,time); Ok(()) @@ -1452,7 +1450,7 @@ fn run_teleport_behaviour( if let Some(current_stage)=mode.get_stage(mode_state.get_stage_id()){ if !current_stage.is_complete(mode_state.ordered_checkpoint_count(),mode_state.unordered_checkpoint_count()){ //do the stage checkpoints have to be reset? - teleport_to_spawn(mode_state.get_stage_id(),move_state,body,touching,run,mode_state,mode,models,hitbox_mesh,bvh,style,camera,input_state,time); + let _=teleport_to_spawn(current_stage,move_state,body,touching,run,mode_state,mode,models,hitbox_mesh,bvh,style,camera,input_state,time); return; } } @@ -1464,7 +1462,7 @@ fn run_teleport_behaviour( match mode.get_stage(stage_id){ Some(stage)=>if !stage.is_empty(){ mode_state.set_stage_id(stage_id); - teleport_to_spawn(stage_id,move_state,body,touching,run,mode_state,mode,models,hitbox_mesh,bvh,style,camera,input_state,time); + let _=teleport_to_spawn(stage,move_state,body,touching,run,mode_state,mode,models,hitbox_mesh,bvh,style,camera,input_state,time); return; }, None=>{ @@ -1488,7 +1486,7 @@ fn run_teleport_behaviour( gameplay_modes::StageElementBehaviour::Trigger |gameplay_modes::StageElementBehaviour::Teleport=>{ //I guess this is correct behaviour when trying to teleport to a non-existent spawn but it's still weird - teleport_to_spawn(mode_state.get_stage_id(),move_state,body,touching,run,mode_state,mode,models,hitbox_mesh,bvh,style,camera,input_state,time); + let _=teleport_to_spawn(stage,move_state,body,touching,run,mode_state,mode,models,hitbox_mesh,bvh,style,camera,input_state,time); return; }, gameplay_modes::StageElementBehaviour::Platform=>(), @@ -1868,12 +1866,14 @@ fn atomic_input_instruction(state:&mut PhysicsState,data:&PhysicsData,ins:TimedI PhysicsInputInstruction::Spawn(mode_id,stage_id)=>{ //spawn at a particular stage if let Some(mode)=data.modes.get_mode(mode_id){ - teleport_to_spawn( - stage_id, - &mut state.move_state,&mut state.body,&mut state.touching,&mut state.run,&mut state.mode_state, - mode, - &data.models,&data.hitbox_mesh,&data.bvh,&state.style,&state.camera,&state.input_state,state.time - ); + if let Some(stage)=mode.get_stage(stage_id){ + let _=teleport_to_spawn( + stage, + &mut state.move_state,&mut state.body,&mut state.touching,&mut state.run,&mut state.mode_state, + mode, + &data.models,&data.hitbox_mesh,&data.bvh,&state.style,&state.camera,&state.input_state,state.time + ); + } } b_refresh_walk_target=false; },