/// 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 materials: ResMut<Assets<ColorMaterial>>,
    mut sel: ResMut<ContributorSelection>,
    mut dq: Query<Mut<Text>, With<ContributorDisplay>>,
    mut tq: Query<Mut<Timer>, With<SelectTimer>>,
    mut q: Query<(&Contributor, &Handle<ColorMaterial>, &mut Transform)>,
) {
    let mut timer_fired = false;
    for mut t in tq.iter_mut() {
        if !t.just_finished() {
            continue;
        }
        t.reset();
        timer_fired = true;
    }
    if !timer_fired {
        return;
    }
    let prev = sel.idx;
    if (sel.idx + 1) < sel.order.len() {
        sel.idx += 1;
    } else {
        sel.idx = 0;
    }
    {
        let (_, e) = &sel.order[prev];
        if let Ok((c, handle, mut tr)) = q.get_mut(*e) {
            deselect(&mut *materials, handle.clone(), c, &mut *tr);
        }
    }
    let (name, e) = &sel.order[sel.idx];
    if let Ok((c, handle, mut tr)) = q.get_mut(*e) {
        for mut text in dq.iter_mut() {
            select(
                &mut *materials,
                handle.clone(),
                c,
                &mut *tr,
                &mut *text,
                name,
            );
        }
    }
}
fn select_system ( mut materials : ResMut < Assets < ColorMaterial > > , mut sel : ResMut < ContributorSelection > , mut dq : Query < Mut < Text > , With < ContributorDisplay > > , mut tq : Query < Mut < Timer > , With < SelectTimer > > , mut q : Query < ( & Contributor , & Handle < ColorMaterial > , & mut Transform ) > , ) { let mut timer_fired = false ; for mut t in tq . iter_mut ( ) { if ! t . just_finished ( ) { continue ; } t . reset ( ) ; timer_fired = true ; } if ! timer_fired { return ; } let prev = sel . idx ; if ( sel . idx + 1 ) < sel . order . len ( ) { sel . idx += 1 ; } else { sel . idx = 0 ; } { let ( _ , e ) = & sel . order [ prev ] ; if let Ok ( ( c , handle , mut tr ) ) = q . get_mut ( * e ) { deselect ( & mut * materials , handle . clone ( ) , c , & mut * tr ) ; } } let ( name , e ) = & sel . order [ sel . idx ] ; if let Ok ( ( c , handle , mut tr ) ) = q . get_mut ( * e ) { for mut text in dq . iter_mut ( ) { select ( & mut * materials , handle . clone ( ) , c , & mut * tr , & mut * text , name , ) ; } } }
Finds the next contributor to display and selects the entity
Finds the next contributor to display and selects the entity
materials
ResMut<Assets<ColorMaterial>>
sel
ResMut<ContributorSelection>
dq
Query<Mut<Text>, With<ContributorDisplay>>
tq
Query<Mut<Timer>, With<SelectTimer>>
q
Query<(&Contributor, &Handle<ColorMaterial>, &mut Transform)>