Trait aery::operations::Track

source ·
pub trait Track {
    type Out<Item>;

    // Required method
    fn track<Item>(self, item: Item) -> Self::Out<Item>
       where Item: for<'a> Trackable<'a, 1>;
}
Expand description

Track the last seen item from a query when traversing an edge. This is useful in scenarios where you mightn’t have a component on every entity in a hierarchy. For instance it might not make sense for a component to be on every entity or even an immediate ancestor meaning spam propogation isn’t viable. Scroll areas in UI are one example of this.

§Example

use bevy::prelude::*;
use aery::prelude::*;

#[derive(Component)]
struct Node {
    // ..
}

#[derive(Component)]
struct ScrollArea {
    // ..
}

#[derive(Relation)]
struct Ui;

fn draw_node_graph(
    mut scroll_areas: Query<&mut ScrollArea>,
    tree: Query<(Option<&Node>, Relations<Ui>)>,
    roots: Query<Entity, Root<Ui>>
) {
    tree.traverse::<Ui>(roots.iter())
        .track(&mut scroll_areas)
        .for_each(|scroll_area, node, _| {
            if let Some(node) = node {
                // draw node to scroll area
            }
        });
}

Required Associated Types§

source

type Out<Item>

Required Methods§

source

fn track<Item>(self, item: Item) -> Self::Out<Item>
where Item: for<'a> Trackable<'a, 1>,

Object Safety§

This trait is not object safe.

Implementors§

source§

impl<Control, Edge, Starts, Tracked> Track for TraverseAnd<Control, Edge, Starts, Tracked>
where Tracked: Append,

§

type Out<Item> = TraverseAnd<Control, Edge, Starts, <Tracked as Append>::Out<Item>>