Trait bevy_ecs::query::WorldQuery[][src]

pub trait WorldQuery {
    type Fetch: for<'world, 'state> Fetch<'world, 'state, State = Self::State>;
    type State: FetchState;
    type ReadOnlyFetch: for<'world, 'state> Fetch<'world, 'state, State = Self::State> + ReadOnlyFetch;
}
Expand description

Types that can be queried from a World.

Notable types that implement this trait are &T and &mut T where T implements Component, allowing you to query for components immutably and mutably accordingly.

See Query for a primer on queries.

Basic WorldQuery’s

Here is a small list of the most important world queries to know about where C stands for a Component and WQ stands for a WorldQuery:

  • &C: Queries immutably for the component C
  • &mut C: Queries mutably for the component C
  • Option<WQ>: Queries the inner WorldQuery WQ but instead of discarding the entity if the world query fails it returns None. See Query.
  • (WQ1, WQ2, ...): Queries all contained world queries allowing to query for more than one thing. This is the And operator for filters. See Or.
  • ChangeTrackers<C>: See the docs of ChangeTrackers.
  • Entity: Using the entity type as a world query will grant access to the entity that is being queried for. See Entity.

Bevy also offers a few filters like Added, Changed, With, Without and Or. For more information on these consult the item’s corresponding documentation.

Associated Types

Implementations on Foreign Types

Implementors