code style

This commit is contained in:
Quaternions 2024-02-12 19:52:21 -08:00
parent 4a7cd0a146
commit 7ade6129c7

View File

@ -1046,9 +1046,9 @@ impl PhysicsContext{
} }
//tickless gaming //tickless gaming
pub fn run(&mut self, time_limit:Time){ pub fn run(&mut self,time_limit:Time){
//prepare is ommitted - everything is done via instructions. //prepare is ommitted - everything is done via instructions.
while let Some(instruction) = self.next_instruction(time_limit) {//collect while let Some(instruction)=self.next_instruction(time_limit){//collect
//process //process
self.process_instruction(instruction); self.process_instruction(instruction);
//write hash lol //write hash lol
@ -1339,12 +1339,12 @@ fn run_teleport_behaviour(wormhole:&Option<gameplay_attributes::Wormhole>,models
match &general.trajectory{ match &general.trajectory{
Some(trajectory)=>{ Some(trajectory)=>{
match trajectory{ match trajectory{
gameplay_attributes::SetTrajectory::AirTime(_) => todo!(), gameplay_attributes::SetTrajectory::AirTime(_)=>todo!(),
gameplay_attributes::SetTrajectory::Height(_) => todo!(), gameplay_attributes::SetTrajectory::Height(_)=>todo!(),
gameplay_attributes::SetTrajectory::TargetPointTime { target_point: _, time: _ } => todo!(), gameplay_attributes::SetTrajectory::TargetPointTime { target_point: _, time: _ }=>todo!(),
gameplay_attributes::SetTrajectory::TargetPointSpeed { target_point: _, speed: _, trajectory_choice: _ } => todo!(), gameplay_attributes::SetTrajectory::TargetPointSpeed { target_point: _, speed: _, trajectory_choice: _ }=>todo!(),
&gameplay_attributes::SetTrajectory::Velocity(velocity)=>v=velocity, &gameplay_attributes::SetTrajectory::Velocity(velocity)=>v=velocity,
gameplay_attributes::SetTrajectory::DotVelocity { direction: _, dot: _ } => todo!(), gameplay_attributes::SetTrajectory::DotVelocity { direction: _, dot: _ }=>todo!(),
} }
}, },
None=>(), None=>(),
@ -1365,7 +1365,7 @@ fn run_teleport_behaviour(wormhole:&Option<gameplay_attributes::Wormhole>,models
_=>panic!("invalid pair"), _=>panic!("invalid pair"),
} }
}, },
PhysicsInstruction::CollisionEnd(c) => { PhysicsInstruction::CollisionEnd(c)=>{
match data.models.attr(c.convex_mesh_id().model_id){ match data.models.attr(c.convex_mesh_id().model_id){
PhysicsCollisionAttributes::Contact{contacting:_,general:_}=>{ PhysicsCollisionAttributes::Contact{contacting:_,general:_}=>{
state.touching.remove(&c);//remove contact before calling contact_constrain_acceleration state.touching.remove(&c);//remove contact before calling contact_constrain_acceleration
@ -1377,7 +1377,7 @@ fn run_teleport_behaviour(wormhole:&Option<gameplay_attributes::Wormhole>,models
}, },
} }
}, },
PhysicsInstruction::StrafeTick => { PhysicsInstruction::StrafeTick=>{
let control_dir=state.style.get_control_dir(state.controls); let control_dir=state.style.get_control_dir(state.controls);
if control_dir!=Planar64Vec3::ZERO{ if control_dir!=Planar64Vec3::ZERO{
let camera_mat=state.camera.simulate_move_rotation_y(state.camera.mouse.lerp(&state.next_mouse,state.time).x); let camera_mat=state.camera.simulate_move_rotation_y(state.camera.mouse.lerp(&state.next_mouse,state.time).x);
@ -1394,7 +1394,7 @@ fn run_teleport_behaviour(wormhole:&Option<gameplay_attributes::Wormhole>,models
} }
} }
} }
PhysicsInstruction::ReachWalkTargetVelocity => { PhysicsInstruction::ReachWalkTargetVelocity=>{
match &mut state.move_state{ match &mut state.move_state{
MoveState::Air|MoveState::Water=>(), MoveState::Air|MoveState::Water=>(),
MoveState::Walk(walk_state)|MoveState::Ladder(walk_state)=>{ MoveState::Walk(walk_state)|MoveState::Ladder(walk_state)=>{
@ -1412,24 +1412,24 @@ fn run_teleport_behaviour(wormhole:&Option<gameplay_attributes::Wormhole>,models
} }
} }
}, },
PhysicsInstruction::Input(input_instruction) => { PhysicsInstruction::Input(input_instruction)=>{
let mut b_refresh_walk_target=true; let mut b_refresh_walk_target=true;
match input_instruction{ match input_instruction{
PhysicsInputInstruction::SetNextMouse(m) => { PhysicsInputInstruction::SetNextMouse(m)=>{
state.camera.move_mouse(state.next_mouse.pos); state.camera.move_mouse(state.next_mouse.pos);
(state.camera.mouse,state.next_mouse)=(state.next_mouse.clone(),m); (state.camera.mouse,state.next_mouse)=(state.next_mouse.clone(),m);
}, },
PhysicsInputInstruction::ReplaceMouse(m0,m1) => { PhysicsInputInstruction::ReplaceMouse(m0,m1)=>{
state.camera.move_mouse(m0.pos); state.camera.move_mouse(m0.pos);
(state.camera.mouse,state.next_mouse)=(m0,m1); (state.camera.mouse,state.next_mouse)=(m0,m1);
}, },
PhysicsInputInstruction::SetMoveForward(s) => state.set_control(StyleModifiers::CONTROL_MOVEFORWARD,s), PhysicsInputInstruction::SetMoveForward(s)=>state.set_control(StyleModifiers::CONTROL_MOVEFORWARD,s),
PhysicsInputInstruction::SetMoveLeft(s) => state.set_control(StyleModifiers::CONTROL_MOVELEFT,s), PhysicsInputInstruction::SetMoveLeft(s)=>state.set_control(StyleModifiers::CONTROL_MOVELEFT,s),
PhysicsInputInstruction::SetMoveBack(s) => state.set_control(StyleModifiers::CONTROL_MOVEBACK,s), PhysicsInputInstruction::SetMoveBack(s)=>state.set_control(StyleModifiers::CONTROL_MOVEBACK,s),
PhysicsInputInstruction::SetMoveRight(s) => state.set_control(StyleModifiers::CONTROL_MOVERIGHT,s), PhysicsInputInstruction::SetMoveRight(s)=>state.set_control(StyleModifiers::CONTROL_MOVERIGHT,s),
PhysicsInputInstruction::SetMoveUp(s) => state.set_control(StyleModifiers::CONTROL_MOVEUP,s), PhysicsInputInstruction::SetMoveUp(s)=>state.set_control(StyleModifiers::CONTROL_MOVEUP,s),
PhysicsInputInstruction::SetMoveDown(s) => state.set_control(StyleModifiers::CONTROL_MOVEDOWN,s), PhysicsInputInstruction::SetMoveDown(s)=>state.set_control(StyleModifiers::CONTROL_MOVEDOWN,s),
PhysicsInputInstruction::SetJump(s) => { PhysicsInputInstruction::SetJump(s)=>{
state.set_control(StyleModifiers::CONTROL_JUMP,s); state.set_control(StyleModifiers::CONTROL_JUMP,s);
if let Some(walk_state)=get_walk_state(&state.move_state){ if let Some(walk_state)=get_walk_state(&state.move_state){
let mut v=state.body.velocity; let mut v=state.body.velocity;
@ -1440,11 +1440,11 @@ fn run_teleport_behaviour(wormhole:&Option<gameplay_attributes::Wormhole>,models
} }
b_refresh_walk_target=false; b_refresh_walk_target=false;
}, },
PhysicsInputInstruction::SetZoom(s) => { PhysicsInputInstruction::SetZoom(s)=>{
state.set_control(StyleModifiers::CONTROL_ZOOM,s); state.set_control(StyleModifiers::CONTROL_ZOOM,s);
b_refresh_walk_target=false; b_refresh_walk_target=false;
}, },
PhysicsInputInstruction::Reset => { PhysicsInputInstruction::Reset=>{
//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);
@ -1457,7 +1457,7 @@ fn run_teleport_behaviour(wormhole:&Option<gameplay_attributes::Wormhole>,models
(state.move_state,state.body.acceleration)=state.touching.get_move_state(&state.body,&data.models,&state.style,&data.hitbox_mesh,&state.camera,state.controls,&state.next_mouse,state.time); (state.move_state,state.body.acceleration)=state.touching.get_move_state(&state.body,&data.models,&state.style,&data.hitbox_mesh,&state.camera,state.controls,&state.next_mouse,state.time);
b_refresh_walk_target=false; b_refresh_walk_target=false;
}, },
PhysicsInputInstruction::Idle => {b_refresh_walk_target=false;},//literally idle! PhysicsInputInstruction::Idle=>{b_refresh_walk_target=false;},//literally idle!
} }
if b_refresh_walk_target{ if b_refresh_walk_target{
let a=refresh_walk_target(state,data); let a=refresh_walk_target(state,data);