Hide display name of mount while mounted (at full hp)

This commit is contained in:
ubruntu 2023-04-22 18:13:13 +00:00 committed by Imbris
parent 4b6c5f57e3
commit b53bfd4246

View File

@ -2268,10 +2268,13 @@ impl Hud {
let is_me = entity == me; let is_me = entity == me;
let dist_sqr = pos.distance_squared(player_pos); let dist_sqr = pos.distance_squared(player_pos);
// Determine whether to display nametag and healthbar based on whether the // Determine whether to display nametag and healthbar based on whether the
// entity has been damaged, is targeted/selected, or is in your group // entity is mounted, has been damaged, is targeted/selected, or is in your
// Note: even if this passes the healthbar can be hidden in some cases if it // group
// is at maximum // Note: even if this passes the healthbar can
// be hidden in some cases if it is at maximum
let display_overhead_info = !is_me let display_overhead_info = !is_me
&& (is_mount.is_none()
|| health.map_or(true, overhead::should_show_healthbar))
&& (info.target_entity.map_or(false, |e| e == entity) && (info.target_entity.map_or(false, |e| e == entity)
|| info.selected_entity.map_or(false, |s| s.0 == entity) || info.selected_entity.map_or(false, |s| s.0 == entity)
|| health.map_or(true, overhead::should_show_healthbar) || health.map_or(true, overhead::should_show_healthbar)
@ -2357,14 +2360,20 @@ impl Hud {
if Some(*owner) == client.uid() if Some(*owner) == client.uid()
&& dist_sqr < common::consts::MAX_MOUNT_RANGE.powi(2) => && dist_sqr < common::consts::MAX_MOUNT_RANGE.powi(2) =>
{ {
let mut options = let mut options = Vec::new();
vec![(GameInput::Trade, i18n.get_msg("hud-trade").to_string())]; if is_mount.is_none() {
options.push((
GameInput::Trade,
i18n.get_msg("hud-trade").to_string(),
));
if !client.is_riding() if !client.is_riding()
&& is_mount.is_none()
&& is_mountable(body, bodies.get(client.entity())) && is_mountable(body, bodies.get(client.entity()))
{ {
options options.push((
.push((GameInput::Mount, i18n.get_msg("hud-mount").to_string())) GameInput::Mount,
i18n.get_msg("hud-mount").to_string(),
))
}
} }
options options
}, },