From 0dc9a49c4e804d47197eeea2266ef7c85342a342 Mon Sep 17 00:00:00 2001 From: Nolan Darilek Date: Mon, 27 Sep 2021 12:26:24 -0500 Subject: [PATCH] Tweak exploration collision algorithm. --- src/exploration.rs | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/src/exploration.rs b/src/exploration.rs index 5dfb930..585c039 100644 --- a/src/exploration.rs +++ b/src/exploration.rs @@ -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>, focused: Query>, explorable: Query, With)>>, - 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 = vec![coordinates.direction_and_distance(exploring, None)]; + let mut tokens: Vec = 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(())