Struct ambient_api_core::ecs::ChangeQuery
source · pub struct ChangeQuery<Components: ComponentsTuple + Copy + Clone + 'static>(/* private fields */);
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: ComponentsTuple + Copy + Clone + 'static> ChangeQuery<Components>
impl<Components: ComponentsTuple + Copy + Clone + 'static> ChangeQuery<Components>
sourcepub fn requires(self, requires: impl ComponentsTuple) -> Self
pub fn requires(self, requires: impl ComponentsTuple) -> Self
The entities must include the components in requires
.
sourcepub fn excludes(self, excludes: impl ComponentsTuple) -> Self
pub fn excludes(self, excludes: impl ComponentsTuple) -> Self
The entities must not include the components in exclude
.
sourcepub fn track_change(self, changes: impl ComponentsTuple) -> Self
pub fn track_change(self, changes: impl ComponentsTuple) -> Self
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: CallbackReturn>(
self,
callback: impl FnMut(Vec<(EntityId, Components::Data)>) -> R + 'static
) -> Listener
pub fn bind<R: CallbackReturn>( self, callback: impl FnMut(Vec<(EntityId, Components::Data)>) -> R + 'static ) -> Listener
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