Function bones_ecs::entities::Optional

source ·
pub fn Optional<'a, T: HasSchema, C, S>(
    component_ref: &'a S
) -> OptionalQueryItem<'a, T, S>where
    C: ComponentIterBitset<'a, T> + 'a,
    S: Deref<Target = C> + 'a,
Expand description

Helper func to construct a OptionalQueryItem wrapping a Comp SystemParam. Used to iterate over enities optionally retrieving components from ComponentStore. Entities iterated over will not be filtered by this QueryItem.

This example filters entities by compC, optionally retrieves compA as mutable, and compB as immutable. (OptionalMut is used for mutation).

entities.iter_with(&mut OptionalMut(&mut compA), &Optional(&compB), &compC)

This will implement QueryItem as long as generic type implements std::ops::Deref for ComponentStore, such as Comp and CompMut.