fn select_system(
    mut contributor_selection: ResMut<ContributorSelection>,
    mut text_query: Query<&mut Text, With<ContributorDisplay>>,
    mut timer_query: Query<&mut Timer, With<SelectTimer>>,
    mut query: Query<(&Contributor, &mut Sprite, &mut Transform)>,
    time: Res<Time>,
) {
    let mut timer_fired = false;
    for mut timer in timer_query.iter_mut() {
        if !timer.tick(time.delta()).just_finished() {
            continue;
        }
        timer.reset();
        timer_fired = true;
    }

    if !timer_fired {
        return;
    }

    let prev = contributor_selection.idx;

    if (contributor_selection.idx + 1) < contributor_selection.order.len() {
        contributor_selection.idx += 1;
    } else {
        contributor_selection.idx = 0;
    }

    {
        let (_, entity) = &contributor_selection.order[prev];
        if let Ok((contributor, mut sprite, mut transform)) = query.get_mut(*entity) {
            deselect(&mut sprite, contributor, &mut *transform);
        }
    }

    let (name, entity) = &contributor_selection.order[contributor_selection.idx];

    if let Ok((contributor, mut sprite, mut transform)) = query.get_mut(*entity) {
        if let Some(mut text) = text_query.iter_mut().next() {
            select(&mut sprite, contributor, &mut *transform, &mut *text, name);
        }
    }
}
/// Finds the next contributor to display and selects the entity
Finds the next contributor to display and selects the entity
Finds the next contributor to display and selects the entity
fn select_system(
    mut contributor_selection: ResMut<ContributorSelection>,
    mut text_query: Query<&mut Text, With<ContributorDisplay>>,
    mut timer_query: Query<&mut Timer, With<SelectTimer>>,
    mut query: Query<(&Contributor, &mut Sprite, &mut Transform)>,
    time: Res<Time>,
) {
    let mut timer_fired = false;
    for mut timer in timer_query.iter_mut() {
        if !timer.tick(time.delta()).just_finished() {
            continue;
        }
        timer.reset();
        timer_fired = true;
    }
    if !timer_fired {
        return;
    }
    let prev = contributor_selection.idx;
    if (contributor_selection.idx + 1) < contributor_selection.order.len() {
        contributor_selection.idx += 1;
    } else {
        contributor_selection.idx = 0;
    }
    {
        let (_, entity) = &contributor_selection.order[prev];
        if let Ok((contributor, mut sprite, mut transform)) = query.get_mut(*entity) {
            deselect(&mut sprite, contributor, &mut *transform);
        }
    }
    let (name, entity) = &contributor_selection.order[contributor_selection.idx];
    if let Ok((contributor, mut sprite, mut transform)) = query.get_mut(*entity) {
        if let Some(mut text) = text_query.iter_mut().next() {
            select(&mut sprite, contributor, &mut *transform, &mut *text, name);
        }
    }
}
fn select_system ( mut contributor_selection : ResMut < ContributorSelection > , mut text_query : Query < & mut Text , With < ContributorDisplay > > , mut timer_query : Query < & mut Timer , With < SelectTimer > > , mut query : Query < ( & Contributor , & mut Sprite , & mut Transform ) > , time : Res < Time > , ) { let mut timer_fired = false ; for mut timer in timer_query . iter_mut ( ) { if ! timer . tick ( time . delta ( ) ) . just_finished ( ) { continue ; } timer . reset ( ) ; timer_fired = true ; } if ! timer_fired { return ; } let prev = contributor_selection . idx ; if ( contributor_selection . idx + 1 ) < contributor_selection . order . len ( ) { contributor_selection . idx += 1 ; } else { contributor_selection . idx = 0 ; } { let ( _ , entity ) = & contributor_selection . order [ prev ] ; if let Ok ( ( contributor , mut sprite , mut transform ) ) = query . get_mut ( * entity ) { deselect ( & mut sprite , contributor , & mut * transform ) ; } } let ( name , entity ) = & contributor_selection . order [ contributor_selection . idx ] ; if let Ok ( ( contributor , mut sprite , mut transform ) ) = query . get_mut ( * entity ) { if let Some ( mut text ) = text_query . iter_mut ( ) . next ( ) { select ( & mut sprite , contributor , & mut * transform , & mut * text , name ) ; } } }
Finds the next contributor to display and selects the entity
Finds the next contributor to display and selects the entity
contributor_selection
ResMut<ContributorSelection>
text_query
Query<&mut Text, With<ContributorDisplay>>
timer_query
Query<&mut Timer, With<SelectTimer>>
query
Query<(&Contributor, &mut Sprite, &mut Transform)>
time
Res<Time>
contributor_selection
ResMut<ContributorSelection>
text_query
Query<&mut Text, With<ContributorDisplay>>
timer_query
Query<&mut Timer, With<SelectTimer>>
query
Query<(&Contributor, &mut Sprite, &mut Transform)>
time
Res<Time>