fix attributes & modes

This commit is contained in:
Quaternions 2024-02-12 20:43:09 -08:00
parent cb80773db4
commit 77fb784c7e

View File

@ -124,12 +124,13 @@ impl ModesBuilder{
self.stage_updates.push((mode_id,stage_id,stage_update));
}
}
fn get_attributes(object:&rbx_dom_weak::Instance,can_collide:bool,velocity:Planar64Vec3,force_intersecting:bool,model_id:model::ModelId,modes_builder:&mut ModesBuilder,wormhole_in_model_to_id:&mut HashMap<model::ModelId,u32>)->attr::CollisionAttributes{
fn get_attributes(object:&rbx_dom_weak::Instance,can_collide:bool,velocity:Planar64Vec3,model_id:model::ModelId,modes_builder:&mut ModesBuilder,wormhole_in_model_to_id:&mut HashMap<model::ModelId,u32>,wormhole_id_to_out_model:&mut HashMap<u32,model::ModelId>)->attr::CollisionAttributes{
let name=object.name.as_str();
let mut general=attr::GeneralAttributes::default();
let mut intersecting=attr::IntersectingAttributes::default();
let mut contacting=attr::ContactingAttributes::default();
let mut force_can_collide=can_collide;
let mut force_intersecting=false;
match name{
"Water"=>{
force_can_collide=false;
@ -148,8 +149,20 @@ fn get_attributes(object:&rbx_dom_weak::Instance,can_collide:bool,velocity:Plana
// behaviour:model::StageElementBehaviour::Unordered
// })),
"SetVelocity"=>general.trajectory=Some(attr::SetTrajectory::Velocity(velocity)),
"MapStart"=>{
force_can_collide=false;
force_intersecting=true;
modes_builder.insert_mode(
gameplay_modes::ModeId::MAIN,
gameplay_modes::Mode::new(
gameplay_style::StyleModifiers::roblox_bhop(),
model_id
)
);
},
"MapFinish"=>{
force_can_collide=false;
force_intersecting=true;
modes_builder.push_mode_update(
gameplay_modes::ModeId::MAIN,
gameplay_modes::ModeUpdate::zone(
@ -160,6 +173,7 @@ fn get_attributes(object:&rbx_dom_weak::Instance,can_collide:bool,velocity:Plana
},
"MapAnticheat"=>{
force_can_collide=false;
force_intersecting=true;
modes_builder.push_mode_update(
gameplay_modes::ModeId::MAIN,
gameplay_modes::ModeUpdate::zone(
@ -178,8 +192,37 @@ fn get_attributes(object:&rbx_dom_weak::Instance,can_collide:bool,velocity:Plana
);
},
other=>{
if let Some(captures)=lazy_regex::regex!(r"^(Force)?(Spawn|SpawnAt|Trigger|Teleport|Platform)(\d+)$")
let regman=lazy_regex::regex!(r"^(BonusStart|Spawn|WormholeOut)(\d+)$");
if let Some(captures)=regman.captures(other){
match &captures[1]{
"BonusStart"=>{
force_can_collide=false;
force_intersecting=true;
modes_builder.insert_mode(
gameplay_modes::ModeId::new(captures[2].parse::<u32>().unwrap()),
gameplay_modes::Mode::new(
gameplay_style::StyleModifiers::roblox_bhop(),
model_id
)
);
},
"Spawn"=>{
force_intersecting=true;
modes_builder.insert_stage(
gameplay_modes::ModeId::MAIN,
gameplay_modes::StageId::new(captures[2].parse::<u32>().unwrap()),
gameplay_modes::Stage::new(model_id),
);
},
"WormholeOut"=>{
//this object is not special in strafe client, but the roblox mapping needs to be converted to model id
assert!(wormhole_id_to_out_model.insert(captures[2].parse::<u32>().unwrap(),model_id).is_none(),"Cannot have multiple WormholeOut with same id");
},
_=>(),
}
}else if let Some(captures)=lazy_regex::regex!(r"^(Force)?(Spawn|SpawnAt|Trigger|Teleport|Platform)(\d+)$")
.captures(other){
force_intersecting=true;
modes_builder.push_mode_update(
gameplay_modes::ModeId::MAIN,
gameplay_modes::ModeUpdate::element(
@ -218,6 +261,7 @@ fn get_attributes(object:&rbx_dom_weak::Instance,can_collide:bool,velocity:Plana
),
"WormholeIn"=>{
force_can_collide=false;
force_intersecting=true;
assert!(wormhole_in_model_to_id.insert(model_id,captures[2].parse::<u32>().unwrap()).is_none(),"Impossible");
},
_=>panic!("regex2[1] messed up bad"),
@ -225,6 +269,7 @@ fn get_attributes(object:&rbx_dom_weak::Instance,can_collide:bool,velocity:Plana
}else if let Some(captures)=lazy_regex::regex!(r"^Bonus(Finish|Anticheat)(\d+)$")
.captures(other){
force_can_collide=false;
force_intersecting=true;
modes_builder.push_mode_update(
gameplay_modes::ModeId::new(captures[2].parse::<u32>().unwrap()),
gameplay_modes::ModeUpdate::zone(
@ -417,52 +462,6 @@ pub fn convert(dom:rbx_dom_weak::WeakDom)->map::CompleteMap{
//at this point a new model is going to be generated for sure.
let model_id=model::ModelId::new(models1.len() as u32);
let force_intersecting=match &object.name[..]{
"MapStart"=>{
modes_builder.insert_mode(
gameplay_modes::ModeId::MAIN,
gameplay_modes::Mode::new(
gameplay_style::StyleModifiers::roblox_bhop(),
model_id
)
);
true
},
other=>{
let regman=lazy_regex::regex!(r"^(BonusStart|Spawn|WormholeOut)(\d+)$");
if let Some(captures)=regman.captures(other){
match &captures[1]{
"BonusStart"=>{
modes_builder.insert_mode(
gameplay_modes::ModeId::new(captures[2].parse::<u32>().unwrap()),
gameplay_modes::Mode::new(
gameplay_style::StyleModifiers::roblox_bhop(),
model_id
)
);
true
},
"Spawn"=>{
modes_builder.insert_stage(
gameplay_modes::ModeId::MAIN,
gameplay_modes::StageId::new(captures[2].parse::<u32>().unwrap()),
gameplay_modes::Stage::new(model_id),
);
true
},
"WormholeOut"=>{
//this object is not special in strafe client, but the roblox mapping needs to be converted to model id
assert!(wormhole_id_to_out_model.insert(captures[2].parse::<u32>().unwrap(),model_id).is_none(),"Cannot have multiple WormholeOut with same id");
false
},
_=>false,
}
}else{
false
}
}
};
//TODO: also detect "CylinderMesh" etc here
let shape=match &object.class[..]{
"Part"=>{
@ -672,10 +671,10 @@ pub fn convert(dom:rbx_dom_weak::WeakDom)->map::CompleteMap{
&object,
*can_collide,
Planar64Vec3::try_from([velocity.x,velocity.y,velocity.z]).unwrap(),
force_intersecting,
model_id,
&mut modes_builder,
&mut wormhole_in_model_to_id,
&mut wormhole_id_to_out_model,
);
models1.push(ModelOwnedAttributes{
mesh:indexed_model_id,