Tweak exploration collision algorithm.

This commit is contained in:
Nolan Darilek 2021-09-27 12:26:24 -05:00
parent 4a43642957
commit 0dc9a49c4e

View File

@ -12,7 +12,7 @@ use crate::{
error::error_handler, error::error_handler,
map::Map, map::Map,
pathfinding::Destination, pathfinding::Destination,
visibility::{RevealedTiles, Viewshed, VisibleEntities, VisibleTiles}, visibility::{RevealedTiles, Viewshed, Visible, VisibleEntities, VisibleTiles},
}; };
#[derive(Clone, Copy, Debug, Default, PartialEq, Reflect)] #[derive(Clone, Copy, Debug, Default, PartialEq, Reflect)]
@ -329,7 +329,6 @@ fn exploration_changed_announcement(
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>)>>, 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>,
@ -359,22 +358,14 @@ fn exploration_changed_announcement(
InteractionGroups::all(), InteractionGroups::all(),
Some(&|v| explorable.get(v.entity()).is_ok()), Some(&|v| explorable.get(v.entity()).is_ok()),
|handle| { |handle| {
let mut entity = handle.entity(); let entity = handle.entity();
if names.get(entity).is_err() { println!("Initial: {:?}, {:?}", entity, names.get(entity),);
if let Ok(parent) = parents.get(entity) {
if names.get(**parent).is_ok() {
entity = **parent;
}
}
}
println!( println!(
"Exploration collided with {:?}, {:?}", "Exploration collided with {:?}, {:?}",
entity, entity,
parents.get(entity) names.get(entity).map(|v| v.to_string())
); );
commands commands.entity(entity).insert(ExplorationFocused);
.entity(entity)
.insert(ExplorationFocused::default());
if visible || mappables.get(entity).is_ok() { if visible || mappables.get(entity).is_ok() {
if let Ok(name) = names.get(entity) { if let Ok(name) = names.get(entity) {
tokens.push(name.as_str()); tokens.push(name.as_str());
@ -396,16 +387,21 @@ fn exploration_changed_announcement(
"floor".to_string() "floor".to_string()
} }
} else { } else {
println!("Pre: {:?}", tokens);
tokens.join(": ") tokens.join(": ")
} }
} else { } else {
"Unknown".to_string() "Unknown".to_string()
}; };
let mut tokens: Vec<String> = vec![coordinates.direction_and_distance(exploring, None)]; let mut tokens: Vec<String> = vec![
description,
coordinates.direction_and_distance(exploring, None),
];
if fog_of_war { if fog_of_war {
tokens.push("in the fog of war".into()); tokens.push("in the fog of war".into());
} }
tts.speak(format!("{}: {}", description, tokens.join(", ")), true)?; println!("{:?}", tokens);
tts.speak(format!("{}", tokens.join(", ")), true)?;
} }
} }
Ok(()) Ok(())