diff --git a/src/exploration.rs b/src/exploration.rs index 92cfef1..5dfb930 100644 --- a/src/exploration.rs +++ b/src/exploration.rs @@ -15,6 +15,10 @@ use crate::{ visibility::{RevealedTiles, Viewshed, VisibleEntities, VisibleTiles}, }; +#[derive(Clone, Copy, Debug, Default, PartialEq, Reflect)] +#[reflect(Component)] +pub struct Explorable; + #[derive(Clone, Copy, Debug, Default, PartialEq, Reflect)] #[reflect(Component)] pub struct ExplorationFocused; @@ -324,6 +328,8 @@ fn exploration_changed_announcement( map: Query<(&Map, &RevealedTiles, &VisibleTiles)>, explorer: Query<(&Coordinates, &Exploring), Changed>, focused: Query>, + explorable: Query, With)>>, + parents: Query<&Parent>, names: Query<&Name>, types: Query<&ExplorationType>, mappables: Query<&Mappable>, @@ -332,7 +338,6 @@ fn exploration_changed_announcement( ) -> Result<(), Box> { if let Ok((coordinates, exploring)) = explorer.single() { let collider_set = QueryPipelineColliderComponentsSet(&collider_query); - let coordinates = **coordinates; let coordinates = (coordinates.x().floor(), coordinates.y().floor()); for (map, revealed_tiles, visible_tiles) in map.iter() { let point = **exploring; @@ -352,9 +357,21 @@ fn exploration_changed_announcement( &shape_pos.into(), &shape, InteractionGroups::all(), - None, + Some(&|v| explorable.get(v.entity()).is_ok()), |handle| { - let entity = handle.entity(); + let mut entity = handle.entity(); + if names.get(entity).is_err() { + if let Ok(parent) = parents.get(entity) { + if names.get(**parent).is_ok() { + entity = **parent; + } + } + } + println!( + "Exploration collided with {:?}, {:?}", + entity, + parents.get(entity) + ); commands .entity(entity) .insert(ExplorationFocused::default());