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