honeycomb_render/render/
picking.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
use crate::gui::UiState;
use bevy::prelude::*;
use bevy_mod_outline::OutlineVolume;
use bevy_mod_picking::prelude::PickSelection;

/// Picking update routine.
pub fn update_picking(
    mut targets: Query<(Entity, &PickSelection, &mut OutlineVolume)>,
    mut ui_state: ResMut<UiState>,
) {
    let selection = &mut ui_state.selected_entities;

    for (entity, pick_interaction, mut outline) in &mut targets {
        if pick_interaction.is_selected {
            outline.visible = true;
            let _ = selection.insert(entity);
        } else {
            outline.visible = false;
            let _ = selection.remove(&entity);
        }
    }
}