Trait bevy_ecs::query::WorldQuery
source · [−]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 componentC
&mut C
: Queries mutably for the componentC
Option<WQ>
: Queries the innerWorldQuery
WQ
but instead of discarding the entity if the world query fails it returnsNone
. SeeQuery
.(WQ1, WQ2, ...)
: Queries all contained world queries allowing to query for more than one thing. This is theAnd
operator for filters. SeeOr
.ChangeTrackers<C>
: See the docs ofChangeTrackers
.Entity
: Using the entity type as a world query will grant access to the entity that is being queried for. SeeEntity
.
Bevy also offers a few filters like Added
, Changed
,
With
, Without
and Or
.
For more information on these consult the item’s corresponding documentation.