fix ui not blocking spawning cells, works now

main
Elijah Voigt 4 hours ago
parent f83b79bda5
commit 7ea43de4fc

@ -13,6 +13,7 @@
// Only because of FromTemplat macros unfortunately... // Only because of FromTemplat macros unfortunately...
#![allow(dead_code)] #![allow(dead_code)]
use bevy::picking::hover::HoverMap;
use engine::*; use engine::*;
mod actions; mod actions;
@ -786,8 +787,11 @@ fn de_spawn_cells(
} }
/// Run condition if the UI is the active element on the screen /// Run condition if the UI is the active element on the screen
fn is_ui_hovered(hovered: Query<&Hovered>) -> bool { fn is_ui_hovered(hover_map: Res<HoverMap>, ui: Query<(), With<Node>>) -> bool {
hovered.iter().any(|Hovered(h)| *h) hover_map
.values() // one EntityHashMap<HitData> per pointer
.flat_map(|hits| hits.keys()) // every hovered entity
.any(|e| ui.contains(*e)) // is any of them a UI node?
} }
#[cfg(debug_assertions)] #[cfg(debug_assertions)]

Loading…
Cancel
Save