Only focus on visible/explorable features.
This commit is contained in:
parent
2ac2566f5d
commit
4a43642957
|
@ -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<Exploring>>,
|
||||
focused: Query<Entity, With<ExplorationFocused>>,
|
||||
explorable: Query<Entity, Or<(With<Visible>, With<Explorable>)>>,
|
||||
parents: Query<&Parent>,
|
||||
names: Query<&Name>,
|
||||
types: Query<&ExplorationType>,
|
||||
mappables: Query<&Mappable>,
|
||||
|
@ -332,7 +338,6 @@ fn exploration_changed_announcement(
|
|||
) -> Result<(), Box<dyn Error>> {
|
||||
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());
|
||||
|
|
Loading…
Reference in New Issue
Block a user