mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Fix fall->climb, tweak jump and glide
This commit is contained in:
@ -335,6 +335,7 @@ impl<'a> System<'a> for Sys {
|
|||||||
|
|
||||||
inputs.update_look_dir();
|
inputs.update_look_dir();
|
||||||
inputs.update_move_dir();
|
inputs.update_move_dir();
|
||||||
|
|
||||||
match (character.action, character.movement) {
|
match (character.action, character.movement) {
|
||||||
// Jumping, one frame state that calls jump server event
|
// Jumping, one frame state that calls jump server event
|
||||||
(_, Jump) => {
|
(_, Jump) => {
|
||||||
@ -392,11 +393,20 @@ impl<'a> System<'a> for Sys {
|
|||||||
}
|
}
|
||||||
// Any Action + Falling
|
// Any Action + Falling
|
||||||
(action_state, Fall) => {
|
(action_state, Fall) => {
|
||||||
// character.movement = get_state_from_move_dir(&inputs.move_dir);
|
character.movement = get_state_from_move_dir(&inputs.move_dir);
|
||||||
if inputs.glide.is_pressed() && !inputs.glide.is_held_down() {
|
if inputs.glide.is_pressed() {
|
||||||
character.movement = Glide;
|
character.movement = Glide;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
// Try to climb
|
||||||
|
if let (true, Some(_wall_dir)) = (
|
||||||
|
inputs.climb.is_pressed() | inputs.climb_down.is_pressed()
|
||||||
|
&& body.is_humanoid(),
|
||||||
|
physics.on_wall,
|
||||||
|
) {
|
||||||
|
character.movement = Climb;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
// Reset to Falling while not standing on ground,
|
// Reset to Falling while not standing on ground,
|
||||||
// otherwise keep the state given above
|
// otherwise keep the state given above
|
||||||
if !physics.on_ground {
|
if !physics.on_ground {
|
||||||
@ -421,15 +431,38 @@ impl<'a> System<'a> for Sys {
|
|||||||
Idle => {
|
Idle => {
|
||||||
if inputs.primary.is_pressed() || inputs.secondary.is_pressed() {
|
if inputs.primary.is_pressed() || inputs.secondary.is_pressed() {
|
||||||
character.action = try_wield(stats);
|
character.action = try_wield(stats);
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Cancel blocks
|
// Cancel blocks
|
||||||
Block { .. } => {
|
Block { .. } => {
|
||||||
character.action = try_wield(stats);
|
character.action = try_wield(stats);
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
// Don't change action
|
// Don't change action
|
||||||
Charge { .. } | Roll { .. } => {}
|
Charge { .. } | Roll { .. } => {}
|
||||||
}
|
}
|
||||||
|
if inputs.primary.is_pressed() {
|
||||||
|
character.action = Self::handle_primary(
|
||||||
|
inputs,
|
||||||
|
character,
|
||||||
|
stats,
|
||||||
|
entity,
|
||||||
|
uid,
|
||||||
|
&mut server_emitter,
|
||||||
|
&mut local_emitter,
|
||||||
|
);
|
||||||
|
} else if inputs.secondary.is_pressed() {
|
||||||
|
character.action = Self::handle_secondary(
|
||||||
|
inputs,
|
||||||
|
character,
|
||||||
|
stats,
|
||||||
|
entity,
|
||||||
|
uid,
|
||||||
|
&mut server_emitter,
|
||||||
|
&mut local_emitter,
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Any Action + Swimming
|
// Any Action + Swimming
|
||||||
(_action_state, Swim) => {
|
(_action_state, Swim) => {
|
||||||
@ -478,8 +511,12 @@ impl<'a> System<'a> for Sys {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if !physics.on_ground && physics.in_fluid {
|
if !physics.on_ground {
|
||||||
character.movement = Swim;
|
if physics.in_fluid {
|
||||||
|
character.movement = Swim;
|
||||||
|
} else {
|
||||||
|
character.movement = Fall;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Standing and Running states, typical states :shrug:
|
// Standing and Running states, typical states :shrug:
|
||||||
@ -502,15 +539,18 @@ impl<'a> System<'a> for Sys {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Try to swim
|
// Try to swim
|
||||||
if !physics.on_ground && physics.in_fluid {
|
if !physics.on_ground {
|
||||||
character.movement = Swim;
|
if physics.in_fluid {
|
||||||
continue;
|
character.movement = Swim;
|
||||||
|
} else {
|
||||||
|
character.movement = Fall;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// While on ground ...
|
// While on ground ...
|
||||||
if physics.on_ground {
|
if physics.on_ground {
|
||||||
// Try to jump
|
// Try to jump
|
||||||
if inputs.jump.is_pressed() && !inputs.jump.is_held_down() {
|
if inputs.jump.is_pressed() {
|
||||||
character.movement = Jump;
|
character.movement = Jump;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -540,7 +580,6 @@ impl<'a> System<'a> for Sys {
|
|||||||
// Try to glide
|
// Try to glide
|
||||||
if physics.on_wall == None
|
if physics.on_wall == None
|
||||||
&& inputs.glide.is_pressed()
|
&& inputs.glide.is_pressed()
|
||||||
&& !inputs.glide.is_held_down()
|
|
||||||
&& body.is_humanoid()
|
&& body.is_humanoid()
|
||||||
{
|
{
|
||||||
character.movement = Glide;
|
character.movement = Glide;
|
||||||
@ -598,7 +637,7 @@ impl<'a> System<'a> for Sys {
|
|||||||
if character.movement == Stand {
|
if character.movement == Stand {
|
||||||
character.movement = Sit;
|
character.movement = Sit;
|
||||||
}
|
}
|
||||||
if inputs.jump.is_pressed() && !inputs.jump.is_held_down() {
|
if inputs.jump.is_pressed() {
|
||||||
character.movement = Jump;
|
character.movement = Jump;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -614,7 +653,7 @@ impl<'a> System<'a> for Sys {
|
|||||||
if !inputs.glide.is_pressed() {
|
if !inputs.glide.is_pressed() {
|
||||||
character.movement = Fall;
|
character.movement = Fall;
|
||||||
} else if let Some(_wall_dir) = physics.on_wall {
|
} else if let Some(_wall_dir) = physics.on_wall {
|
||||||
character.movement = Fall;
|
character.movement = Climb;
|
||||||
}
|
}
|
||||||
|
|
||||||
if physics.on_ground {
|
if physics.on_ground {
|
||||||
|
Reference in New Issue
Block a user