ruin physics code
This commit is contained in:
parent
fb8c2a619a
commit
a8847d3632
@ -20,6 +20,8 @@ type MouseState=strafesnet_common::mouse::MouseState<TimeInner>;
|
||||
//external influence
|
||||
//this is how you influence the physics from outside
|
||||
use strafesnet_common::physics::Instruction as PhysicsInputInstruction;
|
||||
use strafesnet_common::physics::OtherInstruction as PhysicsOtherInstruction;
|
||||
use strafesnet_common::physics::MouseInstruction as PhysicsMouseInstruction;
|
||||
|
||||
//internal influence
|
||||
//when the physics asks itself what happens next, this is how it's represented
|
||||
@ -1751,22 +1753,22 @@ fn atomic_input_instruction(state:&mut PhysicsState,data:&PhysicsData,ins:TimedI
|
||||
let should_advance_body=match ins.instruction{
|
||||
//the body may as well be a quantum wave function
|
||||
//as far as these instruction are concerned (they don't care where it is)
|
||||
PhysicsInputInstruction::SetSensitivity(..)
|
||||
|PhysicsInputInstruction::Reset
|
||||
|PhysicsInputInstruction::Restart
|
||||
|PhysicsInputInstruction::Spawn(..)
|
||||
|PhysicsInputInstruction::SetZoom(..)
|
||||
|PhysicsInputInstruction::Idle=>false,
|
||||
PhysicsInputInstruction::Other(PhysicsOtherInstruction::SetSensitivity(..))
|
||||
|PhysicsInputInstruction::Other(PhysicsOtherInstruction::Reset)
|
||||
|PhysicsInputInstruction::Other(PhysicsOtherInstruction::Restart)
|
||||
|PhysicsInputInstruction::Other(PhysicsOtherInstruction::Spawn(..))
|
||||
|PhysicsInputInstruction::Other(PhysicsOtherInstruction::SetZoom(..))
|
||||
|PhysicsInputInstruction::Other(PhysicsOtherInstruction::Idle)=>false,
|
||||
//these controls only update the body if you are on the ground
|
||||
PhysicsInputInstruction::SetNextMouse(..)
|
||||
|PhysicsInputInstruction::ReplaceMouse(..)
|
||||
|PhysicsInputInstruction::SetMoveForward(..)
|
||||
|PhysicsInputInstruction::SetMoveLeft(..)
|
||||
|PhysicsInputInstruction::SetMoveBack(..)
|
||||
|PhysicsInputInstruction::SetMoveRight(..)
|
||||
|PhysicsInputInstruction::SetMoveUp(..)
|
||||
|PhysicsInputInstruction::SetMoveDown(..)
|
||||
|PhysicsInputInstruction::SetJump(..)=>{
|
||||
PhysicsInputInstruction::Mouse(PhysicsMouseInstruction::SetNextMouse(..))
|
||||
|PhysicsInputInstruction::Mouse(PhysicsMouseInstruction::ReplaceMouse{..})
|
||||
|PhysicsInputInstruction::Other(PhysicsOtherInstruction::SetMoveForward(..))
|
||||
|PhysicsInputInstruction::Other(PhysicsOtherInstruction::SetMoveLeft(..))
|
||||
|PhysicsInputInstruction::Other(PhysicsOtherInstruction::SetMoveBack(..))
|
||||
|PhysicsInputInstruction::Other(PhysicsOtherInstruction::SetMoveRight(..))
|
||||
|PhysicsInputInstruction::Other(PhysicsOtherInstruction::SetMoveUp(..))
|
||||
|PhysicsInputInstruction::Other(PhysicsOtherInstruction::SetMoveDown(..))
|
||||
|PhysicsInputInstruction::Other(PhysicsOtherInstruction::SetJump(..))=>{
|
||||
match &state.move_state{
|
||||
MoveState::Fly
|
||||
|MoveState::Water
|
||||
@ -1776,30 +1778,30 @@ fn atomic_input_instruction(state:&mut PhysicsState,data:&PhysicsData,ins:TimedI
|
||||
}
|
||||
},
|
||||
//the body must be updated unconditionally
|
||||
PhysicsInputInstruction::PracticeFly=>true,
|
||||
PhysicsInputInstruction::Other(PhysicsOtherInstruction::PracticeFly)=>true,
|
||||
};
|
||||
if should_advance_body{
|
||||
state.body.advance_time(state.time);
|
||||
}
|
||||
//TODO: UNTAB
|
||||
|
||||
let mut b_refresh_walk_target=true;
|
||||
match ins.instruction{
|
||||
PhysicsInputInstruction::SetSensitivity(sensitivity)=>state.camera.sensitivity=sensitivity,
|
||||
PhysicsInputInstruction::SetNextMouse(m)=>{
|
||||
PhysicsInputInstruction::Mouse(PhysicsMouseInstruction::SetNextMouse(m))=>{
|
||||
state.camera.move_mouse(state.input_state.mouse_delta());
|
||||
state.input_state.set_next_mouse(m);
|
||||
},
|
||||
PhysicsInputInstruction::ReplaceMouse(m0,m1)=>{
|
||||
PhysicsInputInstruction::Mouse(PhysicsMouseInstruction::ReplaceMouse{m0,m1})=>{
|
||||
state.camera.move_mouse(m0.pos-state.input_state.mouse.pos);
|
||||
state.input_state.replace_mouse(m0,m1);
|
||||
},
|
||||
PhysicsInputInstruction::SetMoveForward(s)=>state.input_state.set_control(Controls::MoveForward,s),
|
||||
PhysicsInputInstruction::SetMoveLeft(s)=>state.input_state.set_control(Controls::MoveLeft,s),
|
||||
PhysicsInputInstruction::SetMoveBack(s)=>state.input_state.set_control(Controls::MoveBackward,s),
|
||||
PhysicsInputInstruction::SetMoveRight(s)=>state.input_state.set_control(Controls::MoveRight,s),
|
||||
PhysicsInputInstruction::SetMoveUp(s)=>state.input_state.set_control(Controls::MoveUp,s),
|
||||
PhysicsInputInstruction::SetMoveDown(s)=>state.input_state.set_control(Controls::MoveDown,s),
|
||||
PhysicsInputInstruction::SetJump(s)=>{
|
||||
PhysicsInputInstruction::Other(PhysicsOtherInstruction::SetSensitivity(sensitivity))=>state.camera.sensitivity=sensitivity,
|
||||
PhysicsInputInstruction::Other(PhysicsOtherInstruction::SetMoveForward(s))=>state.input_state.set_control(Controls::MoveForward,s),
|
||||
PhysicsInputInstruction::Other(PhysicsOtherInstruction::SetMoveLeft(s))=>state.input_state.set_control(Controls::MoveLeft,s),
|
||||
PhysicsInputInstruction::Other(PhysicsOtherInstruction::SetMoveBack(s))=>state.input_state.set_control(Controls::MoveBackward,s),
|
||||
PhysicsInputInstruction::Other(PhysicsOtherInstruction::SetMoveRight(s))=>state.input_state.set_control(Controls::MoveRight,s),
|
||||
PhysicsInputInstruction::Other(PhysicsOtherInstruction::SetMoveUp(s))=>state.input_state.set_control(Controls::MoveUp,s),
|
||||
PhysicsInputInstruction::Other(PhysicsOtherInstruction::SetMoveDown(s))=>state.input_state.set_control(Controls::MoveDown,s),
|
||||
PhysicsInputInstruction::Other(PhysicsOtherInstruction::SetJump(s))=>{
|
||||
state.input_state.set_control(Controls::Jump,s);
|
||||
if let Some(walk_state)=state.move_state.get_walk_state(){
|
||||
if let Some(jump_settings)=&state.style.jump{
|
||||
@ -1811,16 +1813,16 @@ fn atomic_input_instruction(state:&mut PhysicsState,data:&PhysicsData,ins:TimedI
|
||||
}
|
||||
b_refresh_walk_target=false;
|
||||
},
|
||||
PhysicsInputInstruction::SetZoom(s)=>{
|
||||
PhysicsInputInstruction::Other(PhysicsOtherInstruction::SetZoom(s))=>{
|
||||
state.input_state.set_control(Controls::Zoom,s);
|
||||
b_refresh_walk_target=false;
|
||||
},
|
||||
PhysicsInputInstruction::Reset=>{
|
||||
PhysicsInputInstruction::Other(PhysicsOtherInstruction::Reset)=>{
|
||||
//totally reset physics state
|
||||
state.reset_to_default();
|
||||
b_refresh_walk_target=false;
|
||||
},
|
||||
PhysicsInputInstruction::Restart=>{
|
||||
PhysicsInputInstruction::Other(PhysicsOtherInstruction::Restart)=>{
|
||||
//teleport to start zone
|
||||
let mode=data.modes.get_mode(state.mode_state.get_mode_id());
|
||||
let spawn_point=mode.and_then(|mode|
|
||||
@ -1835,7 +1837,7 @@ fn atomic_input_instruction(state:&mut PhysicsState,data:&PhysicsData,ins:TimedI
|
||||
state.set_move_state(data,MoveState::Air);
|
||||
b_refresh_walk_target=false;
|
||||
}
|
||||
PhysicsInputInstruction::Spawn(mode_id,stage_id)=>{
|
||||
PhysicsInputInstruction::Other(PhysicsOtherInstruction::Spawn(mode_id,stage_id))=>{
|
||||
//spawn at a particular stage
|
||||
if let Some(mode)=data.modes.get_mode(mode_id){
|
||||
if let Some(stage)=mode.get_stage(stage_id){
|
||||
@ -1849,7 +1851,7 @@ fn atomic_input_instruction(state:&mut PhysicsState,data:&PhysicsData,ins:TimedI
|
||||
}
|
||||
b_refresh_walk_target=false;
|
||||
},
|
||||
PhysicsInputInstruction::PracticeFly=>{
|
||||
PhysicsInputInstruction::Other(PhysicsOtherInstruction::PracticeFly)=>{
|
||||
match &state.move_state{
|
||||
MoveState::Fly=>{
|
||||
state.set_move_state(data,MoveState::Air);
|
||||
@ -1860,7 +1862,7 @@ fn atomic_input_instruction(state:&mut PhysicsState,data:&PhysicsData,ins:TimedI
|
||||
}
|
||||
b_refresh_walk_target=false;
|
||||
},
|
||||
PhysicsInputInstruction::Idle=>{
|
||||
PhysicsInputInstruction::Other(PhysicsOtherInstruction::Idle)=>{
|
||||
//literally idle!
|
||||
b_refresh_walk_target=false;
|
||||
},
|
||||
|
Loading…
x
Reference in New Issue
Block a user