From 7eba16a2d764744717fc9150dd5186c8fc845c41 Mon Sep 17 00:00:00 2001 From: Isse Date: Wed, 8 Feb 2023 21:35:49 +0100 Subject: [PATCH] use mount key --- client/src/lib.rs | 3 ++- voxygen/src/hud/mod.rs | 2 +- voxygen/src/session/mod.rs | 14 +++++++++++--- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/client/src/lib.rs b/client/src/lib.rs index 9bada06935..ef7f87c9ca 100644 --- a/client/src/lib.rs +++ b/client/src/lib.rs @@ -1539,7 +1539,7 @@ impl Client { } } - pub fn stand_if_mounted(&mut self) { + pub fn stand_if_mounted(&mut self) -> bool { let is_sitting = self .state .ecs() @@ -1552,6 +1552,7 @@ impl Client { Some(false) => {}, None => warn!("Can't stand, client entity doesn't have a `CharacterState`"), } + is_sitting.unwrap_or(false) } pub fn toggle_dance(&mut self) { diff --git a/voxygen/src/hud/mod.rs b/voxygen/src/hud/mod.rs index 6318b623b4..1387af642f 100644 --- a/voxygen/src/hud/mod.rs +++ b/voxygen/src/hud/mod.rs @@ -2128,7 +2128,7 @@ impl Hud { overitem_properties, self.pulse, &global_state.window.key_layout, - vec![(Some(GameInput::Interact), i18n.get_msg("hud-sit").to_string())], + vec![(Some(GameInput::Mount), i18n.get_msg("hud-sit").to_string())], ) .x_y(0.0, 100.0) .position_ingame(over_pos) diff --git a/voxygen/src/session/mod.rs b/voxygen/src/session/mod.rs index bffafd5652..6e76761562 100644 --- a/voxygen/src/session/mod.rs +++ b/voxygen/src/session/mod.rs @@ -887,7 +887,17 @@ impl PlayState for SessionState { let mut client = self.client.borrow_mut(); if client.is_riding() { client.unmount(); - } else { + } else if client.stand_if_mounted() { } else { + if let Some(interactable) = &self.interactable { + match interactable { + Interactable::Block(_, pos, interaction) => { + if matches!(interaction, BlockInteraction::Mount(_)) { + client.mount_sprite(*pos) + } + } + Interactable::Entity(entity) => client.mount(*entity), + } + } let player_pos = client .state() .read_storage::() @@ -969,8 +979,6 @@ impl PlayState for SessionState { } }, } - } else { - client.stand_if_mounted() } } },