Skip to content

Commit

Permalink
Check if entity exists on clearing highlighting
Browse files Browse the repository at this point in the history
  • Loading branch information
Shatur committed Dec 12, 2024
1 parent 06448b7 commit 8b3e926
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions base/src/game_world/highlighting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ impl Plugin for HighlightingPlugin {
app.init_resource::<LastHighlighted>()
.observe(Self::enable)
.observe(Self::disable)
.observe(Self::pick)
.observe(Self::clear)
.add_systems(
SpawnScene,
Self::init_scene
Expand Down Expand Up @@ -66,18 +66,17 @@ impl HighlightingPlugin {
}
}

fn pick(
fn clear(
_trigger: Trigger<OnRemove, Picked>,
mut last_hovered: ResMut<LastHighlighted>,
mut volumes: Query<&mut OutlineVolume>,
) {
if let Some(entity) = **last_hovered {
debug!("clearing highlighting for `{entity}`");
let mut outline = volumes
.get_mut(entity)
.expect("all hovered entities have outline");
outline.visible = true;
**last_hovered = Some(entity);
if let Ok(mut outline) = volumes.get_mut(entity) {
debug!("clearing highlighting for `{entity}`");
outline.visible = true;
**last_hovered = Some(entity);
}
}
}
}
Expand Down

0 comments on commit 8b3e926

Please sign in to comment.