forked from StrafesNET/strafe-client
tweak teleport_to_spawn
This commit is contained in:
parent
35076f5c17
commit
46db92acd0
@ -1398,10 +1398,9 @@ fn teleport(
|
|||||||
}
|
}
|
||||||
enum TeleportToSpawnError{
|
enum TeleportToSpawnError{
|
||||||
NoModel,
|
NoModel,
|
||||||
NoSpawn,
|
|
||||||
}
|
}
|
||||||
fn teleport_to_spawn(
|
fn teleport_to_spawn(
|
||||||
stage_id:gameplay_modes::StageId,
|
stage:&gameplay_modes::Stage,
|
||||||
move_state:&mut MoveState,
|
move_state:&mut MoveState,
|
||||||
body:&mut Body,
|
body:&mut Body,
|
||||||
touching:&mut TouchingState,
|
touching:&mut TouchingState,
|
||||||
@ -1416,8 +1415,7 @@ fn teleport_to_spawn(
|
|||||||
input_state:&InputState,
|
input_state:&InputState,
|
||||||
time:Time,
|
time:Time,
|
||||||
)->Result<(),TeleportToSpawnError>{
|
)->Result<(),TeleportToSpawnError>{
|
||||||
let model_id=mode.get_spawn_model_id(stage_id).ok_or(TeleportToSpawnError::NoSpawn)?;
|
let transform=models.get_model_transform(stage.spawn()).ok_or(TeleportToSpawnError::NoModel)?;
|
||||||
let transform=models.get_model_transform(model_id).ok_or(TeleportToSpawnError::NoModel)?;
|
|
||||||
let point=transform.vertex.transform_point3(Planar64Vec3::Y)+Planar64Vec3::Y*(style.hitbox.halfsize.y()+Planar64::ONE/16);
|
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);
|
teleport(point,move_state,body,touching,run,mode_state,Some(mode),models,hitbox_mesh,bvh,style,camera,input_state,time);
|
||||||
Ok(())
|
Ok(())
|
||||||
@ -1452,7 +1450,7 @@ fn run_teleport_behaviour(
|
|||||||
if let Some(current_stage)=mode.get_stage(mode_state.get_stage_id()){
|
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()){
|
if !current_stage.is_complete(mode_state.ordered_checkpoint_count(),mode_state.unordered_checkpoint_count()){
|
||||||
//do the stage checkpoints have to be reset?
|
//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;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1464,7 +1462,7 @@ fn run_teleport_behaviour(
|
|||||||
match mode.get_stage(stage_id){
|
match mode.get_stage(stage_id){
|
||||||
Some(stage)=>if !stage.is_empty(){
|
Some(stage)=>if !stage.is_empty(){
|
||||||
mode_state.set_stage_id(stage_id);
|
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;
|
return;
|
||||||
},
|
},
|
||||||
None=>{
|
None=>{
|
||||||
@ -1488,7 +1486,7 @@ fn run_teleport_behaviour(
|
|||||||
gameplay_modes::StageElementBehaviour::Trigger
|
gameplay_modes::StageElementBehaviour::Trigger
|
||||||
|gameplay_modes::StageElementBehaviour::Teleport=>{
|
|gameplay_modes::StageElementBehaviour::Teleport=>{
|
||||||
//I guess this is correct behaviour when trying to teleport to a non-existent spawn but it's still weird
|
//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;
|
return;
|
||||||
},
|
},
|
||||||
gameplay_modes::StageElementBehaviour::Platform=>(),
|
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)=>{
|
PhysicsInputInstruction::Spawn(mode_id,stage_id)=>{
|
||||||
//spawn at a particular stage
|
//spawn at a particular stage
|
||||||
if let Some(mode)=data.modes.get_mode(mode_id){
|
if let Some(mode)=data.modes.get_mode(mode_id){
|
||||||
teleport_to_spawn(
|
if let Some(stage)=mode.get_stage(stage_id){
|
||||||
stage_id,
|
let _=teleport_to_spawn(
|
||||||
&mut state.move_state,&mut state.body,&mut state.touching,&mut state.run,&mut state.mode_state,
|
stage,
|
||||||
mode,
|
&mut state.move_state,&mut state.body,&mut state.touching,&mut state.run,&mut state.mode_state,
|
||||||
&data.models,&data.hitbox_mesh,&data.bvh,&state.style,&state.camera,&state.input_state,state.time
|
mode,
|
||||||
);
|
&data.models,&data.hitbox_mesh,&data.bvh,&state.style,&state.camera,&state.input_state,state.time
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
b_refresh_walk_target=false;
|
b_refresh_walk_target=false;
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user