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