use super::*;

/// Scheduling condition for determining if a component has been added
pub fn any_component_added<T: Component>(q: Query<Entity, Added<T>>) -> bool {
    !q.is_empty()
}

/// Scheduling condition for determining if a component has been changed
pub fn any_component_changed<T: Component>(q: Query<Entity, Changed<T>>) -> bool {
    !q.is_empty()
}

/// Scheduling condition to trigger a system when a specific key is pressed
pub fn on_keyboard_press(key: KeyCode) -> impl FnMut(Res<ButtonInput<KeyCode>>) -> bool {
    move |keys: Res<ButtonInput<KeyCode>>| keys.just_pressed(key)
}

/*
/// TODO: Make these work:

use bevy::ecs::query::{ArchetypeFilter, QueryData, QueryFilter};

pub fn filter_contains_exactly<F>(n: usize) -> impl FnMut(Query<Entity, F>) -> bool
where
    F: QueryFilter + ArchetypeFilter
{
    move |q: Query<Entity, F>| q.iter().len() == n
}

pub fn filter_contains_at_least<F>(n: usize) -> impl FnMut(Query<Entity, F>) -> bool
where
    F: QueryFilter + ArchetypeFilter
{
    move |q: Query<Entity, F>| q.iter().len() >= n
}

pub fn filter_contains_at_most<F>(n: usize) -> impl FnMut(Query<Entity, F>) -> bool
where
    F: QueryFilter + ArchetypeFilter
{
    move |q: Query<Entity, F>| q.iter().len() <= n
}

pub fn filter_is_empty<F>() -> impl FnMut(Query<Entity, F>) -> bool
where
    F: QueryFilter + ArchetypeFilter
{
    move |q: Query<Entity, F>| q.iter().len() == 0
}
*/
