use bevy::picking::Pickable;
use bevy::prelude::*;

/// Marker for editor/runtime helper entities that are never authored content.
#[derive(Component, Reflect, Default, Debug, Clone, Copy)]
#[reflect(Component, Default, Debug)]
pub struct EditorOnly;

pub struct EditorInfraPlugin;

impl Plugin for EditorInfraPlugin {
    fn build(&self, app: &mut App) {
        app.register_type::<EditorOnly>()
            .add_systems(Update, make_editor_only_non_pickable);
    }
}

fn make_editor_only_non_pickable(
    mut commands: Commands,
    editor_only: Query<Entity, Added<EditorOnly>>,
) {
    for entity in &editor_only {
        commands.entity(entity).insert(Pickable::IGNORE);
    }
}
