Struct ambient_api::ecs::EventQuery
source · pub struct EventQuery<Components>(/* private fields */)
where
Components: ComponentsTuple + Copy + Clone + 'static;
Expand description
An ECS query that calls a callback when its associated event occurs.
Implementations§
source§impl<Components> EventQuery<Components>
impl<Components> EventQuery<Components>
sourcepub fn create(
event: QueryEvent,
components: Components
) -> EventQuery<Components>
pub fn create( event: QueryEvent, components: Components ) -> EventQuery<Components>
Creates a new EventQuery that will find entities that have the specified components
that will call its bound function when the event
occurs.
sourcepub fn requires(self, requires: impl ComponentsTuple) -> EventQuery<Components>
pub fn requires(self, requires: impl ComponentsTuple) -> EventQuery<Components>
The entities must include the components in requires
.
sourcepub fn excludes(self, excludes: impl ComponentsTuple) -> EventQuery<Components>
pub fn excludes(self, excludes: impl ComponentsTuple) -> EventQuery<Components>
The entities must not include the components in excludes
.
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 entity associated with components
experiences the event,
the callback
(fn
) is called with the result of the query.
Auto Trait Implementations§
impl<Components> RefUnwindSafe for EventQuery<Components>where
Components: RefUnwindSafe,
impl<Components> Send for EventQuery<Components>where
Components: Send,
impl<Components> Sync for EventQuery<Components>where
Components: Sync,
impl<Components> Unpin for EventQuery<Components>where
Components: Unpin,
impl<Components> UnwindSafe for EventQuery<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.