forked from StrafesNET/strafe-client
fix cancollide false triggers + losing speed from hitting teleports
why can't I make this into a function
This commit is contained in:
parent
5b935c32fe
commit
4adce7acd3
@ -34,11 +34,12 @@ fn get_attributes(name:&str,can_collide:bool,velocity:glam::Vec3,force_intersect
|
||||
let mut general=crate::model::GameMechanicAttributes::default();
|
||||
let mut intersecting=crate::model::IntersectingAttributes::default();
|
||||
let mut contacting=crate::model::ContactingAttributes::default();
|
||||
let mut force_can_collide=can_collide;
|
||||
match name{
|
||||
//"Water"=>intersecting.water=Some(crate::model::IntersectingWater{density:1.0,drag:1.0}),
|
||||
"Accelerator"=>intersecting.accelerator=Some(crate::model::IntersectingAccelerator{acceleration:velocity}),
|
||||
"MapFinish"=>general.zone=Some(crate::model::GameMechanicZone{mode_id:0,behaviour:crate::model::ZoneBehaviour::Finish}),
|
||||
"MapAnticheat"=>general.zone=Some(crate::model::GameMechanicZone{mode_id:0,behaviour:crate::model::ZoneBehaviour::Anitcheat}),
|
||||
"Accelerator"=>{force_can_collide=false;intersecting.accelerator=Some(crate::model::IntersectingAccelerator{acceleration:velocity})},
|
||||
"MapFinish"=>{force_can_collide=false;general.zone=Some(crate::model::GameMechanicZone{mode_id:0,behaviour:crate::model::ZoneBehaviour::Finish})},
|
||||
"MapAnticheat"=>{force_can_collide=false;general.zone=Some(crate::model::GameMechanicZone{mode_id:0,behaviour:crate::model::ZoneBehaviour::Anitcheat})},
|
||||
"Platform"=>general.stage_element=Some(crate::model::GameMechanicStageElement{
|
||||
mode_id:0,
|
||||
stage_id:0,
|
||||
@ -57,14 +58,15 @@ fn get_attributes(name:&str,can_collide:bool,velocity:glam::Vec3,force_intersect
|
||||
},
|
||||
behaviour:match &captures[2]{
|
||||
"Spawn"|"SpawnAt"=>crate::model::StageElementBehaviour::SpawnAt,
|
||||
"Trigger"=>crate::model::StageElementBehaviour::Trigger,
|
||||
"Teleport"=>crate::model::StageElementBehaviour::Teleport,
|
||||
"Trigger"=>{force_can_collide=false;crate::model::StageElementBehaviour::Trigger},
|
||||
"Teleport"=>{force_can_collide=false;crate::model::StageElementBehaviour::Teleport},
|
||||
"Platform"=>crate::model::StageElementBehaviour::Platform,
|
||||
_=>panic!("regex1[2] messed up bad"),
|
||||
}
|
||||
})
|
||||
}else if let Some(captures)=lazy_regex::regex!(r"^Bonus(Finish|Anticheat)(\d+)$")
|
||||
.captures(other){
|
||||
force_can_collide=false;
|
||||
match &captures[1]{
|
||||
"Finish"=>general.zone=Some(crate::model::GameMechanicZone{mode_id:captures[2].parse::<u32>().unwrap(),behaviour:crate::model::ZoneBehaviour::Finish}),
|
||||
"Anticheat"=>general.zone=Some(crate::model::GameMechanicZone{mode_id:captures[2].parse::<u32>().unwrap(),behaviour:crate::model::ZoneBehaviour::Anitcheat}),
|
||||
@ -77,7 +79,7 @@ fn get_attributes(name:&str,can_collide:bool,velocity:glam::Vec3,force_intersect
|
||||
if velocity!=glam::Vec3::ZERO{
|
||||
general.booster=Some(crate::model::GameMechanicBooster{velocity});
|
||||
}
|
||||
match can_collide{
|
||||
match force_can_collide{
|
||||
true=>{
|
||||
match name{
|
||||
//"Bounce"=>(),
|
||||
|
@ -1094,35 +1094,35 @@ impl crate::instruction::InstructionConsumer<PhysicsInstruction> for PhysicsStat
|
||||
}
|
||||
//check ground
|
||||
self.contacts.insert(c.model,c);
|
||||
match &general.stage_element{
|
||||
Some(stage_element)=>{
|
||||
if stage_element.force||self.game.stage_id<stage_element.stage_id{
|
||||
self.game.stage_id=stage_element.stage_id;
|
||||
}
|
||||
match stage_element.behaviour{
|
||||
crate::model::StageElementBehaviour::SpawnAt=>(),
|
||||
crate::model::StageElementBehaviour::Trigger
|
||||
|crate::model::StageElementBehaviour::Teleport=>{
|
||||
//TODO make good
|
||||
if let Some(mode)=self.get_mode(stage_element.mode_id){
|
||||
if let Some(&spawn)=mode.get_spawn_model_id(self.game.stage_id){
|
||||
if let Some(model)=self.models.get(spawn as usize){
|
||||
self.body.position=model.transform.transform_point3(glam::Vec3::Y)+glam::Vec3::Y*(self.style.hitbox_halfsize.y+0.1);
|
||||
//manual clear //for c in self.contacts{process_instruction(CollisionEnd(c))}
|
||||
self.contacts.clear();
|
||||
self.intersects.clear();
|
||||
self.body.acceleration=self.style.gravity;
|
||||
self.walk.state=WalkEnum::Reached;
|
||||
self.grounded=false;
|
||||
}else{println!("bad1");}
|
||||
}else{println!("bad2");}
|
||||
}else{println!("bad3");}
|
||||
},
|
||||
crate::model::StageElementBehaviour::Platform=>(),
|
||||
}
|
||||
},
|
||||
None=>(),
|
||||
}
|
||||
match &general.stage_element{
|
||||
Some(stage_element)=>{
|
||||
if stage_element.force||self.game.stage_id<stage_element.stage_id{
|
||||
self.game.stage_id=stage_element.stage_id;
|
||||
}
|
||||
match stage_element.behaviour{
|
||||
crate::model::StageElementBehaviour::SpawnAt=>(),
|
||||
crate::model::StageElementBehaviour::Trigger
|
||||
|crate::model::StageElementBehaviour::Teleport=>{
|
||||
//TODO make good
|
||||
if let Some(mode)=self.get_mode(stage_element.mode_id){
|
||||
if let Some(&spawn)=mode.get_spawn_model_id(self.game.stage_id){
|
||||
if let Some(model)=self.models.get(spawn as usize){
|
||||
self.body.position=model.transform.transform_point3(glam::Vec3::Y)+glam::Vec3::Y*(self.style.hitbox_halfsize.y+0.1);
|
||||
//manual clear //for c in self.contacts{process_instruction(CollisionEnd(c))}
|
||||
self.contacts.clear();
|
||||
self.intersects.clear();
|
||||
self.body.acceleration=self.style.gravity;
|
||||
self.walk.state=WalkEnum::Reached;
|
||||
self.grounded=false;
|
||||
}else{println!("bad1");}
|
||||
}else{println!("bad2");}
|
||||
}else{println!("bad3");}
|
||||
},
|
||||
crate::model::StageElementBehaviour::Platform=>(),
|
||||
}
|
||||
},
|
||||
None=>(),
|
||||
}
|
||||
//flatten v
|
||||
let mut v=self.body.velocity;
|
||||
self.contact_constrain_velocity(&mut v);
|
||||
@ -1142,6 +1142,35 @@ impl crate::instruction::InstructionConsumer<PhysicsInstruction> for PhysicsStat
|
||||
PhysicsCollisionAttributes::Intersect{intersecting,general}=>{
|
||||
//I think that setting the velocity to 0 was preventing surface contacts from entering an infinite loop
|
||||
self.intersects.insert(c.model,c);
|
||||
match &general.stage_element{
|
||||
Some(stage_element)=>{
|
||||
if stage_element.force||self.game.stage_id<stage_element.stage_id{
|
||||
self.game.stage_id=stage_element.stage_id;
|
||||
}
|
||||
match stage_element.behaviour{
|
||||
crate::model::StageElementBehaviour::SpawnAt=>(),
|
||||
crate::model::StageElementBehaviour::Trigger
|
||||
|crate::model::StageElementBehaviour::Teleport=>{
|
||||
//TODO make good
|
||||
if let Some(mode)=self.get_mode(stage_element.mode_id){
|
||||
if let Some(&spawn)=mode.get_spawn_model_id(self.game.stage_id){
|
||||
if let Some(model)=self.models.get(spawn as usize){
|
||||
self.body.position=model.transform.transform_point3(glam::Vec3::Y)+glam::Vec3::Y*(self.style.hitbox_halfsize.y+0.1);
|
||||
//manual clear //for c in self.contacts{process_instruction(CollisionEnd(c))}
|
||||
self.contacts.clear();
|
||||
self.intersects.clear();
|
||||
self.body.acceleration=self.style.gravity;
|
||||
self.walk.state=WalkEnum::Reached;
|
||||
self.grounded=false;
|
||||
}else{println!("bad1");}
|
||||
}else{println!("bad2");}
|
||||
}else{println!("bad3");}
|
||||
},
|
||||
crate::model::StageElementBehaviour::Platform=>(),
|
||||
}
|
||||
},
|
||||
None=>(),
|
||||
}
|
||||
},
|
||||
}
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user