[][src]Struct bevy_ecs::Query

pub struct Query<'a, Q: WorldQuery, F: QueryFilter = ()> { /* fields omitted */ }

Provides scoped access to a World according to a given [HecsQuery]

Implementations

impl<'a, Q: WorldQuery, F: QueryFilter> Query<'a, Q, F>[src]

pub fn iter(&self) -> QueryIter<'_, Q, F>

Notable traits for QueryIter<'w, Q, F>

impl<'w, Q: WorldQuery, F: QueryFilter> Iterator for QueryIter<'w, Q, F> type Item = <Q::Fetch as Fetch<'w>>::Item;
where
    Q::Fetch: ReadOnlyFetch
[src]

Iterates over the query results. This can only be called for read-only queries

pub fn iter_mut(&mut self) -> QueryIter<'_, Q, F>

Notable traits for QueryIter<'w, Q, F>

impl<'w, Q: WorldQuery, F: QueryFilter> Iterator for QueryIter<'w, Q, F> type Item = <Q::Fetch as Fetch<'w>>::Item;
[src]

Iterates over the query results

pub unsafe fn iter_unsafe(&self) -> QueryIter<'_, Q, F>

Notable traits for QueryIter<'w, Q, F>

impl<'w, Q: WorldQuery, F: QueryFilter> Iterator for QueryIter<'w, Q, F> type Item = <Q::Fetch as Fetch<'w>>::Item;
[src]

Iterates over the query results

Safety

This allows aliased mutability. You must make sure this call does not result in multiple mutable references to the same component

pub fn par_iter(&self, batch_size: usize) -> ParIter<'_, Q, F> where
    Q::Fetch: ReadOnlyFetch
[src]

pub fn par_iter_mut(&mut self, batch_size: usize) -> ParIter<'_, Q, F>[src]

pub fn get(
    &self,
    entity: Entity
) -> Result<<Q::Fetch as Fetch<'_>>::Item, QueryError> where
    Q::Fetch: ReadOnlyFetch
[src]

Gets the query result for the given entity

pub fn get_mut(
    &mut self,
    entity: Entity
) -> Result<<Q::Fetch as Fetch<'_>>::Item, QueryError>
[src]

Gets the query result for the given entity

pub unsafe fn get_unsafe(
    &self,
    entity: Entity
) -> Result<<Q::Fetch as Fetch<'_>>::Item, QueryError>
[src]

Gets the query result for the given entity

Safety

This allows aliased mutability. You must make sure this call does not result in multiple mutable references to the same component

pub fn get_component<T: Component>(
    &self,
    entity: Entity
) -> Result<&T, QueryError>
[src]

Gets a reference to the entity's component of the given type. This will fail if the entity does not have the given component type or if the given component type does not match this query.

pub fn get_component_mut<T: Component>(
    &mut self,
    entity: Entity
) -> Result<Mut<'_, T>, QueryError>
[src]

Gets a mutable reference to the entity's component of the given type. This will fail if the entity does not have the given component type or if the given component type does not match this query.

pub unsafe fn get_component_unsafe<T: Component>(
    &self,
    entity: Entity
) -> Result<Mut<'_, T>, QueryError>
[src]

Gets a mutable reference to the entity's component of the given type. This will fail if the entity does not have the given component type

Safety

This allows aliased mutability. You must make sure this call does not result in multiple mutable references to the same component

pub fn removed<C: Component>(&self) -> &[Entity][src]

Returns an array containing the Entitys in this Query that had the given Component removed in this update.

removed::<C>() only returns entities whose components were removed before the current system started.

Regular systems do not apply Commands until the end of their stage. This means component removals in a regular system won't be accessible through removed::<C>() in the same stage, because the removal hasn't actually occurred yet. This can be solved by executing removed::<C>() in a later stage. AppBuilder::add_system_to_stage() can be used to control at what stage a system runs.

Thread local systems manipulate the world directly, so removes are applied immediately. This means any system that runs after a thread local system in the same update will pick up removals that happened in the thread local system, regardless of stages.

pub fn set<T: Component>(
    &mut self,
    entity: Entity,
    component: T
) -> Result<(), QueryError>
[src]

Sets the entity's component to the given value. This will fail if the entity does not already have the given component type or if the given component type does not match this query.

Trait Implementations

impl<'a, Q: Debug + WorldQuery, F: Debug + QueryFilter> Debug for Query<'a, Q, F>[src]

impl<'a, Q: WorldQuery, F: QueryFilter> SystemParam for Query<'a, Q, F>[src]

type Fetch = FetchQuery<Q, F>

Auto Trait Implementations

impl<'a, Q, F = ()> !RefUnwindSafe for Query<'a, Q, F>[src]

impl<'a, Q, F> Send for Query<'a, Q, F> where
    F: Send,
    Q: Send
[src]

impl<'a, Q, F> Sync for Query<'a, Q, F> where
    F: Sync,
    Q: Sync
[src]

impl<'a, Q, F> Unpin for Query<'a, Q, F> where
    F: Unpin,
    Q: Unpin
[src]

impl<'a, Q, F = ()> !UnwindSafe for Query<'a, Q, F>[src]

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Downcast for T where
    T: Any
[src]

impl<T> DowncastSync for T where
    T: Send + Sync + Any
[src]

impl<T> From<T> for T[src]

impl<T> Instrument for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,