mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
cancel walking on some inputs
This commit is contained in:
parent
96a70d760c
commit
2097a499c7
@ -686,6 +686,8 @@ impl PlayState for SessionState {
|
|||||||
// Throw out distance info, it will be useful in the future
|
// Throw out distance info, it will be useful in the future
|
||||||
self.target_entity = entity_target.map(|t| t.kind.0);
|
self.target_entity = entity_target.map(|t| t.kind.0);
|
||||||
|
|
||||||
|
let mut stop_walk = false;
|
||||||
|
|
||||||
// Handle window events.
|
// Handle window events.
|
||||||
for event in events {
|
for event in events {
|
||||||
// Pass all events to the ui first.
|
// Pass all events to the ui first.
|
||||||
@ -712,6 +714,7 @@ impl PlayState for SessionState {
|
|||||||
}
|
}
|
||||||
match input {
|
match input {
|
||||||
GameInput::Primary => {
|
GameInput::Primary => {
|
||||||
|
stop_walk = true;
|
||||||
let mut client = self.client.borrow_mut();
|
let mut client = self.client.borrow_mut();
|
||||||
// Mine and build targets can be the same block. make building
|
// Mine and build targets can be the same block. make building
|
||||||
// take precedence.
|
// take precedence.
|
||||||
@ -730,6 +733,7 @@ impl PlayState for SessionState {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
GameInput::Secondary => {
|
GameInput::Secondary => {
|
||||||
|
stop_walk = true;
|
||||||
let mut client = self.client.borrow_mut();
|
let mut client = self.client.borrow_mut();
|
||||||
if let Some(build_target) = build_target.filter(|bt| {
|
if let Some(build_target) = build_target.filter(|bt| {
|
||||||
state && can_build && nearest_block_dist == Some(bt.distance)
|
state && can_build && nearest_block_dist == Some(bt.distance)
|
||||||
@ -749,6 +753,7 @@ impl PlayState for SessionState {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
GameInput::Block => {
|
GameInput::Block => {
|
||||||
|
stop_walk = true;
|
||||||
self.client.borrow_mut().handle_input(
|
self.client.borrow_mut().handle_input(
|
||||||
InputKind::Block,
|
InputKind::Block,
|
||||||
state,
|
state,
|
||||||
@ -757,6 +762,7 @@ impl PlayState for SessionState {
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
GameInput::Roll => {
|
GameInput::Roll => {
|
||||||
|
stop_walk = true;
|
||||||
let mut client = self.client.borrow_mut();
|
let mut client = self.client.borrow_mut();
|
||||||
if can_build {
|
if can_build {
|
||||||
if state {
|
if state {
|
||||||
@ -781,12 +787,14 @@ impl PlayState for SessionState {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
GameInput::Respawn => {
|
GameInput::Respawn => {
|
||||||
|
stop_walk = true;
|
||||||
self.stop_auto_walk();
|
self.stop_auto_walk();
|
||||||
if state {
|
if state {
|
||||||
self.client.borrow_mut().respawn();
|
self.client.borrow_mut().respawn();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
GameInput::Jump => {
|
GameInput::Jump => {
|
||||||
|
stop_walk = true;
|
||||||
self.client.borrow_mut().handle_input(
|
self.client.borrow_mut().handle_input(
|
||||||
InputKind::Jump,
|
InputKind::Jump,
|
||||||
state,
|
state,
|
||||||
@ -849,6 +857,7 @@ impl PlayState for SessionState {
|
|||||||
self.key_state.right = state
|
self.key_state.right = state
|
||||||
},
|
},
|
||||||
GameInput::Glide => {
|
GameInput::Glide => {
|
||||||
|
stop_walk = true;
|
||||||
let is_trading = self.client.borrow().is_trading();
|
let is_trading = self.client.borrow().is_trading();
|
||||||
if state && !is_trading {
|
if state && !is_trading {
|
||||||
if global_state.settings.gameplay.stop_auto_walk_on_input {
|
if global_state.settings.gameplay.stop_auto_walk_on_input {
|
||||||
@ -879,7 +888,11 @@ impl PlayState for SessionState {
|
|||||||
},
|
},
|
||||||
GameInput::ToggleWield => {
|
GameInput::ToggleWield => {
|
||||||
if state {
|
if state {
|
||||||
self.client.borrow_mut().toggle_wield();
|
let mut client = self.client.borrow_mut();
|
||||||
|
if client.is_wielding().is_some_and(|b| !b) {
|
||||||
|
stop_walk = true;
|
||||||
|
}
|
||||||
|
client.toggle_wield();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
GameInput::SwapLoadout => {
|
GameInput::SwapLoadout => {
|
||||||
@ -1441,6 +1454,13 @@ impl PlayState for SessionState {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if stop_walk && self.walking_speed {
|
||||||
|
self.walking_speed = false;
|
||||||
|
self.hud.walking_speed(false);
|
||||||
|
|
||||||
|
self.key_state.speed_mul = 1.0;
|
||||||
|
}
|
||||||
|
|
||||||
// Recompute dependents just in case some input modified the camera
|
// Recompute dependents just in case some input modified the camera
|
||||||
self.scene
|
self.scene
|
||||||
.camera_mut()
|
.camera_mut()
|
||||||
|
Loading…
Reference in New Issue
Block a user