disable clicking on stars in map - accidental clicks too annoying
This commit is contained in:
parent
c27b43b51d
commit
9de72a0cfc
2 changed files with 9 additions and 2 deletions
10
src/hud.rs
10
src/hud.rs
|
@ -265,6 +265,7 @@ pub struct IsClickable {
|
|||
pub name: Option<String>,
|
||||
pub pronoun: Option<String>,
|
||||
pub distance: Option<f64>,
|
||||
pub disable_in_map: bool,
|
||||
}
|
||||
impl Default for IsClickable {
|
||||
fn default() -> Self {
|
||||
|
@ -272,6 +273,7 @@ impl Default for IsClickable {
|
|||
name: None,
|
||||
pronoun: None,
|
||||
distance: None,
|
||||
disable_in_map: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1162,7 +1164,7 @@ fn handle_input(
|
|||
mut ew_target: EventWriter<TargetEvent>,
|
||||
mut ew_game: EventWriter<GameEvent>,
|
||||
q_objects: Query<
|
||||
(Entity, &Transform),
|
||||
(Entity, &Transform, &IsClickable),
|
||||
(
|
||||
With<IsClickable>,
|
||||
Without<IsTargeted>,
|
||||
|
@ -1178,7 +1180,11 @@ fn handle_input(
|
|||
}
|
||||
if settings.hud_active && mouse_input.just_pressed(settings.key_selectobject) {
|
||||
if let Ok(camtrans) = q_camera.get_single() {
|
||||
let objects: Vec<(Entity, &Transform)> = q_objects.iter().collect();
|
||||
let objects: Vec<(Entity, &Transform)> = q_objects
|
||||
.iter()
|
||||
.filter(|(_, _, clickable)| !settings.map_active || !clickable.disable_in_map)
|
||||
.map(|(entity, trans, _)| (entity, trans))
|
||||
.collect();
|
||||
if let (Some(new_target), _dist) =
|
||||
camera::find_closest_target::<Entity>(objects, camtrans)
|
||||
{
|
||||
|
|
|
@ -149,6 +149,7 @@ pub fn setup(
|
|||
hud::IsClickable {
|
||||
name: Some(name),
|
||||
distance,
|
||||
disable_in_map: true,
|
||||
..default()
|
||||
},
|
||||
PbrBundle {
|
||||
|
|
Loading…
Add table
Reference in a new issue