Struct ambient_api::ecs::ChangeQuery
source · pub struct ChangeQuery<Components>(/* private fields */)
where
Components: ComponentsTuple + Copy + Clone + 'static;
Expand description
A partially-built ECS query that calls a callback when entities containing components marked with Self::track_change have those components change.
This cannot be constructed without first going through UntrackedChangeQuery or change_query.
Implementations§
source§impl<Components> ChangeQuery<Components>
impl<Components> ChangeQuery<Components>
sourcepub fn requires(self, requires: impl ComponentsTuple) -> ChangeQuery<Components>
pub fn requires(self, requires: impl ComponentsTuple) -> ChangeQuery<Components>
The entities must include the components in requires
.
sourcepub fn excludes(self, excludes: impl ComponentsTuple) -> ChangeQuery<Components>
pub fn excludes(self, excludes: impl ComponentsTuple) -> ChangeQuery<Components>
The entities must not include the components in exclude
.
sourcepub fn track_change(
self,
changes: impl ComponentsTuple
) -> ChangeQuery<Components>
pub fn track_change( self, changes: impl ComponentsTuple ) -> ChangeQuery<Components>
The query will return results when these components change values.
Note that this does not implicitly requires the components; this allows you to track changes for entities that do not have all of the tracked components.
sourcepub fn bind<R>(
self,
callback: impl FnMut(Vec<(EntityId, <Components as ComponentsTuple>::Data)>) -> R + 'static
) -> Listenerwhere
R: CallbackReturn,
pub fn bind<R>(
self,
callback: impl FnMut(Vec<(EntityId, <Components as ComponentsTuple>::Data)>) -> R + 'static
) -> Listenerwhere
R: CallbackReturn,
Each time the components marked by Self::track_change change,
the callback
(fn
) is called with the result of the query.
Auto Trait Implementations§
impl<Components> RefUnwindSafe for ChangeQuery<Components>where
Components: RefUnwindSafe,
impl<Components> Send for ChangeQuery<Components>where
Components: Send,
impl<Components> Sync for ChangeQuery<Components>where
Components: Sync,
impl<Components> Unpin for ChangeQuery<Components>where
Components: Unpin,
impl<Components> UnwindSafe for ChangeQuery<Components>where
Components: UnwindSafe,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> Downcast for T
impl<T> Downcast for T
source§impl<T> ElementComponentName for T
impl<T> ElementComponentName for T
source§fn element_component_name(&self) -> &'static str
fn element_component_name(&self) -> &'static str
Returns the name of the type implementing ElementComponent.