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},
|
visibility::{RevealedTiles, Viewshed, VisibleEntities, VisibleTiles},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#[derive(Clone, Copy, Debug, Default, PartialEq, Reflect)]
|
||||||
|
#[reflect(Component)]
|
||||||
|
pub struct Explorable;
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, Default, PartialEq, Reflect)]
|
#[derive(Clone, Copy, Debug, Default, PartialEq, Reflect)]
|
||||||
#[reflect(Component)]
|
#[reflect(Component)]
|
||||||
pub struct ExplorationFocused;
|
pub struct ExplorationFocused;
|
||||||
|
@ -324,6 +328,8 @@ fn exploration_changed_announcement(
|
||||||
map: Query<(&Map, &RevealedTiles, &VisibleTiles)>,
|
map: Query<(&Map, &RevealedTiles, &VisibleTiles)>,
|
||||||
explorer: Query<(&Coordinates, &Exploring), Changed<Exploring>>,
|
explorer: Query<(&Coordinates, &Exploring), Changed<Exploring>>,
|
||||||
focused: Query<Entity, With<ExplorationFocused>>,
|
focused: Query<Entity, With<ExplorationFocused>>,
|
||||||
|
explorable: Query<Entity, Or<(With<Visible>, With<Explorable>)>>,
|
||||||
|
parents: Query<&Parent>,
|
||||||
names: Query<&Name>,
|
names: Query<&Name>,
|
||||||
types: Query<&ExplorationType>,
|
types: Query<&ExplorationType>,
|
||||||
mappables: Query<&Mappable>,
|
mappables: Query<&Mappable>,
|
||||||
|
@ -332,7 +338,6 @@ fn exploration_changed_announcement(
|
||||||
) -> Result<(), Box<dyn Error>> {
|
) -> Result<(), Box<dyn Error>> {
|
||||||
if let Ok((coordinates, exploring)) = explorer.single() {
|
if let Ok((coordinates, exploring)) = explorer.single() {
|
||||||
let collider_set = QueryPipelineColliderComponentsSet(&collider_query);
|
let collider_set = QueryPipelineColliderComponentsSet(&collider_query);
|
||||||
let coordinates = **coordinates;
|
|
||||||
let coordinates = (coordinates.x().floor(), coordinates.y().floor());
|
let coordinates = (coordinates.x().floor(), coordinates.y().floor());
|
||||||
for (map, revealed_tiles, visible_tiles) in map.iter() {
|
for (map, revealed_tiles, visible_tiles) in map.iter() {
|
||||||
let point = **exploring;
|
let point = **exploring;
|
||||||
|
@ -352,9 +357,21 @@ fn exploration_changed_announcement(
|
||||||
&shape_pos.into(),
|
&shape_pos.into(),
|
||||||
&shape,
|
&shape,
|
||||||
InteractionGroups::all(),
|
InteractionGroups::all(),
|
||||||
None,
|
Some(&|v| explorable.get(v.entity()).is_ok()),
|
||||||
|handle| {
|
|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
|
commands
|
||||||
.entity(entity)
|
.entity(entity)
|
||||||
.insert(ExplorationFocused::default());
|
.insert(ExplorationFocused::default());
|
||||||
|
|
Loading…
Reference in New Issue
Block a user