forked from StrafesNET/strafe-client
model is supposed to be guaranteed to exist
This commit is contained in:
parent
dd6acbfc2f
commit
a7c7088c1f
@ -249,8 +249,8 @@ impl PhysicsModels{
|
|||||||
&model.transform
|
&model.transform
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
fn model(&self,model_id:PhysicsModelId)->Option<&PhysicsModel>{
|
fn model(&self,model_id:PhysicsModelId)->&PhysicsModel{
|
||||||
self.models.get(&model_id)
|
&self.models[&model_id]
|
||||||
}
|
}
|
||||||
fn attr(&self,model_id:PhysicsModelId)->&PhysicsCollisionAttributes{
|
fn attr(&self,model_id:PhysicsModelId)->&PhysicsCollisionAttributes{
|
||||||
&self.attributes[&self.models[&model_id].attr_id]
|
&self.attributes[&self.models[&model_id].attr_id]
|
||||||
@ -1242,7 +1242,7 @@ fn teleport(body:&mut Body,touching:&mut TouchingState,models:&PhysicsModels,sty
|
|||||||
MoveState::Air
|
MoveState::Air
|
||||||
}
|
}
|
||||||
fn teleport_to_spawn(body:&mut Body,touching:&mut TouchingState,style:&StyleModifiers,hitbox_mesh:&HitboxMesh,mode:&gameplay_modes::Mode,models:&PhysicsModels,stage_id:gameplay_modes::StageId)->Option<MoveState>{
|
fn teleport_to_spawn(body:&mut Body,touching:&mut TouchingState,style:&StyleModifiers,hitbox_mesh:&HitboxMesh,mode:&gameplay_modes::Mode,models:&PhysicsModels,stage_id:gameplay_modes::StageId)->Option<MoveState>{
|
||||||
let model=models.model(mode.get_spawn_model_id(stage_id)?.into()).unwrap();
|
let model=models.model(mode.get_spawn_model_id(stage_id)?.into());
|
||||||
let point=model.transform.vertex.transform_point3(Planar64Vec3::Y)+Planar64Vec3::Y*(style.hitbox.halfsize.y()+Planar64::ONE/16);
|
let point=model.transform.vertex.transform_point3(Planar64Vec3::Y)+Planar64Vec3::Y*(style.hitbox.halfsize.y()+Planar64::ONE/16);
|
||||||
Some(teleport(body,touching,models,style,hitbox_mesh,point))
|
Some(teleport(body,touching,models,style,hitbox_mesh,point))
|
||||||
}
|
}
|
||||||
@ -1298,8 +1298,8 @@ fn run_teleport_behaviour(wormhole:&Option<gameplay_attributes::Wormhole>,models
|
|||||||
}
|
}
|
||||||
match wormhole{
|
match wormhole{
|
||||||
&Some(gameplay_attributes::Wormhole{destination_model})=>{
|
&Some(gameplay_attributes::Wormhole{destination_model})=>{
|
||||||
let origin_model=models.model(convex_mesh_id.model_id).unwrap();
|
let origin_model=models.model(convex_mesh_id.model_id);
|
||||||
let destination_model=models.model(destination_model.into()).unwrap();
|
let destination_model=models.model(destination_model.into());
|
||||||
//ignore the transform for now
|
//ignore the transform for now
|
||||||
Some(teleport(body,touching,models,style,hitbox_mesh,body.position-origin_model.transform.vertex.translation+destination_model.transform.vertex.translation))
|
Some(teleport(body,touching,models,style,hitbox_mesh,body.position-origin_model.transform.vertex.translation+destination_model.transform.vertex.translation))
|
||||||
}
|
}
|
||||||
@ -1521,9 +1521,9 @@ fn run_teleport_behaviour(wormhole:&Option<gameplay_attributes::Wormhole>,models
|
|||||||
//it matters which of these runs first, but I have not thought it through yet as it doesn't matter yet
|
//it matters which of these runs first, but I have not thought it through yet as it doesn't matter yet
|
||||||
state.mode_state.clear();
|
state.mode_state.clear();
|
||||||
state.mode_state.set_stage_id(gameplay_modes::StageId::FIRST);
|
state.mode_state.set_stage_id(gameplay_modes::StageId::FIRST);
|
||||||
let spawn_point=data.modes.get_mode(state.mode_state.get_mode_id()).and_then(|mode|
|
let spawn_point=data.modes.get_mode(state.mode_state.get_mode_id()).map(|mode|
|
||||||
//TODO: spawn at the bottom of the start zone plus the hitbox size
|
//TODO: spawn at the bottom of the start zone plus the hitbox size
|
||||||
data.models.model(mode.get_start().into()).map(|model|model.transform.vertex.translation)
|
data.models.model(mode.get_start().into()).transform.vertex.translation
|
||||||
).unwrap_or(Planar64Vec3::ZERO);
|
).unwrap_or(Planar64Vec3::ZERO);
|
||||||
set_position(&mut state.body,&mut state.touching,spawn_point);
|
set_position(&mut state.body,&mut state.touching,spawn_point);
|
||||||
set_velocity(&mut state.body,&state.touching,&data.models,&data.hitbox_mesh,Planar64Vec3::ZERO);
|
set_velocity(&mut state.body,&state.touching,&data.models,&data.hitbox_mesh,Planar64Vec3::ZERO);
|
||||||
|
Loading…
Reference in New Issue
Block a user