pub struct QueryState<Q, F = ()>{ /* private fields */ }
Expand description
Provides scoped access to a World
state according to a given WorldQuery
and query filter.
Implementations§
Source§impl<Q, F> QueryState<Q, F>
impl<Q, F> QueryState<Q, F>
Sourcepub fn new(world: &mut World) -> QueryState<Q, F>
pub fn new(world: &mut World) -> QueryState<Q, F>
Creates a new QueryState
from a given World
and inherits the result of world.id()
.
Sourcepub fn is_empty(
&self,
world: &World,
last_change_tick: u32,
change_tick: u32,
) -> bool
pub fn is_empty( &self, world: &World, last_change_tick: u32, change_tick: u32, ) -> bool
Checks if the query is empty for the given World
, where the last change and current tick are given.
Sourcepub fn update_archetypes(&mut self, world: &World)
pub fn update_archetypes(&mut self, world: &World)
Takes a query for the given World
, checks if the given world is the same as the query, and
generates new archetypes for the given world.
§Panics
Panics if the world.id()
does not equal the current QueryState
internal id.
pub fn validate_world(&self, world: &World)
Sourcepub fn new_archetype(&mut self, archetype: &Archetype)
pub fn new_archetype(&mut self, archetype: &Archetype)
Creates a new Archetype
.
Sourcepub fn get<'w, 's>(
&'s mut self,
world: &'w World,
entity: Entity,
) -> Result<<<Q as WorldQuery>::ReadOnlyFetch as Fetch<'w, 's>>::Item, QueryEntityError>
pub fn get<'w, 's>( &'s mut self, world: &'w World, entity: Entity, ) -> Result<<<Q as WorldQuery>::ReadOnlyFetch as Fetch<'w, 's>>::Item, QueryEntityError>
Gets the query result for the given World
and Entity
.
This can only be called for read-only queries, see Self::get_mut
for write-queries.
Sourcepub fn get_mut<'w, 's>(
&'s mut self,
world: &'w mut World,
entity: Entity,
) -> Result<<<Q as WorldQuery>::Fetch as Fetch<'w, 's>>::Item, QueryEntityError>
pub fn get_mut<'w, 's>( &'s mut self, world: &'w mut World, entity: Entity, ) -> Result<<<Q as WorldQuery>::Fetch as Fetch<'w, 's>>::Item, QueryEntityError>
pub fn get_manual<'w, 's>( &'s self, world: &'w World, entity: Entity, ) -> Result<<<Q as WorldQuery>::ReadOnlyFetch as Fetch<'w, 's>>::Item, QueryEntityError>
Sourcepub unsafe fn get_unchecked<'w, 's>(
&'s mut self,
world: &'w World,
entity: Entity,
) -> Result<<<Q as WorldQuery>::Fetch as Fetch<'w, 's>>::Item, QueryEntityError>
pub unsafe fn get_unchecked<'w, 's>( &'s mut self, world: &'w World, entity: Entity, ) -> Result<<<Q as WorldQuery>::Fetch as Fetch<'w, 's>>::Item, QueryEntityError>
Sourcepub fn iter<'w, 's>(
&'s mut self,
world: &'w World,
) -> QueryIter<'w, 's, Q, <Q as WorldQuery>::ReadOnlyFetch, F>
pub fn iter<'w, 's>( &'s mut self, world: &'w World, ) -> QueryIter<'w, 's, Q, <Q as WorldQuery>::ReadOnlyFetch, F>
Returns an Iterator
over the query results for the given World
.
This can only be called for read-only queries, see Self::iter_mut
for write-queries.
Sourcepub fn iter_mut<'w, 's>(
&'s mut self,
world: &'w mut World,
) -> QueryIter<'w, 's, Q, <Q as WorldQuery>::Fetch, F>
pub fn iter_mut<'w, 's>( &'s mut self, world: &'w mut World, ) -> QueryIter<'w, 's, Q, <Q as WorldQuery>::Fetch, F>
Sourcepub fn iter_manual<'w, 's>(
&'s self,
world: &'w World,
) -> QueryIter<'w, 's, Q, <Q as WorldQuery>::ReadOnlyFetch, F>
pub fn iter_manual<'w, 's>( &'s self, world: &'w World, ) -> QueryIter<'w, 's, Q, <Q as WorldQuery>::ReadOnlyFetch, F>
Returns an Iterator
over all possible combinations of K
query results without repetition.
This can only be called for read-only queries.
For permutations of size K of query returning N results, you will get:
- if K == N: one permutation of all query results
- if K < N: all possible K-sized combinations of query results, without repetition
- if K > N: empty set (no K-sized combinations exist)
This can only be called for read-only queries, see Self::iter_combinations_mut
for
write-queries.
Sourcepub fn iter_combinations<'w, 's, const K: usize>(
&'s mut self,
world: &'w World,
) -> QueryCombinationIter<'w, 's, Q, <Q as WorldQuery>::ReadOnlyFetch, F, K>
pub fn iter_combinations<'w, 's, const K: usize>( &'s mut self, world: &'w World, ) -> QueryCombinationIter<'w, 's, Q, <Q as WorldQuery>::ReadOnlyFetch, F, K>
Returns an Iterator
over all possible combinations of K
query results without repetition.
This can only be called for read-only queries.
For permutations of size K of query returning N results, you will get:
- if K == N: one permutation of all query results
- if K < N: all possible K-sized combinations of query results, without repetition
- if K > N: empty set (no K-sized combinations exist)
This can only be called for read-only queries, see Self::iter_combinations_mut
for
write-queries.
Sourcepub fn iter_combinations_mut<'w, 's, const K: usize>(
&'s mut self,
world: &'w mut World,
) -> QueryCombinationIter<'w, 's, Q, <Q as WorldQuery>::Fetch, F, K>
pub fn iter_combinations_mut<'w, 's, const K: usize>( &'s mut self, world: &'w mut World, ) -> QueryCombinationIter<'w, 's, Q, <Q as WorldQuery>::Fetch, F, K>
Iterates over all possible combinations of K
query results for the given World
without repetition.
For permutations of size K of query returning N results, you will get:
- if K == N: one permutation of all query results
- if K < N: all possible K-sized combinations of query results, without repetition
- if K > N: empty set (no K-sized combinations exist)
Sourcepub unsafe fn iter_unchecked<'w, 's>(
&'s mut self,
world: &'w World,
) -> QueryIter<'w, 's, Q, <Q as WorldQuery>::Fetch, F>
pub unsafe fn iter_unchecked<'w, 's>( &'s mut self, world: &'w World, ) -> QueryIter<'w, 's, Q, <Q as WorldQuery>::Fetch, F>
Sourcepub unsafe fn iter_combinations_unchecked<'w, 's, const K: usize>(
&'s mut self,
world: &'w World,
) -> QueryCombinationIter<'w, 's, Q, <Q as WorldQuery>::Fetch, F, K>
pub unsafe fn iter_combinations_unchecked<'w, 's, const K: usize>( &'s mut self, world: &'w World, ) -> QueryCombinationIter<'w, 's, Q, <Q as WorldQuery>::Fetch, F, K>
Returns an Iterator
over all possible combinations of K
query results for the
given World
without repetition.
This can only be called for read-only queries.
§Safety
This does not check for mutable query correctness. To be safe, make sure mutable queries have unique access to the components they query.
Sourcepub fn for_each<'w, 's, FN>(&'s mut self, world: &'w World, func: FN)
pub fn for_each<'w, 's, FN>(&'s mut self, world: &'w World, func: FN)
Runs func
on each query result for the given World
. This is faster than the equivalent
iter() method, but cannot be chained like a normal Iterator
.
This can only be called for read-only queries, see Self::for_each_mut
for write-queries.
Sourcepub fn for_each_mut<'w, 's, FN>(&'s mut self, world: &'w mut World, func: FN)
pub fn for_each_mut<'w, 's, FN>(&'s mut self, world: &'w mut World, func: FN)
Sourcepub unsafe fn for_each_unchecked<'w, 's, FN>(
&'s mut self,
world: &'w World,
func: FN,
)
pub unsafe fn for_each_unchecked<'w, 's, FN>( &'s mut self, world: &'w World, func: FN, )
Runs func
on each query result for the given World
. This is faster than the equivalent
iter() method, but cannot be chained like a normal Iterator
.
This can only be called for read-only queries.
§Safety
This does not check for mutable query correctness. To be safe, make sure mutable queries have unique access to the components they query.
Sourcepub fn par_for_each<'w, 's, FN>(
&'s mut self,
world: &'w World,
task_pool: &TaskPool,
batch_size: usize,
func: FN,
)
pub fn par_for_each<'w, 's, FN>( &'s mut self, world: &'w World, task_pool: &TaskPool, batch_size: usize, func: FN, )
Runs func
on each query result in parallel using the given task_pool
.
This can only be called for read-only queries, see Self::par_for_each_mut
for
write-queries.
Sourcepub fn par_for_each_mut<'w, 's, FN>(
&'s mut self,
world: &'w mut World,
task_pool: &TaskPool,
batch_size: usize,
func: FN,
)
pub fn par_for_each_mut<'w, 's, FN>( &'s mut self, world: &'w mut World, task_pool: &TaskPool, batch_size: usize, func: FN, )
Runs func
on each query result in parallel using the given task_pool
.
Sourcepub unsafe fn par_for_each_unchecked<'w, 's, FN>(
&'s mut self,
world: &'w World,
task_pool: &TaskPool,
batch_size: usize,
func: FN,
)
pub unsafe fn par_for_each_unchecked<'w, 's, FN>( &'s mut self, world: &'w World, task_pool: &TaskPool, batch_size: usize, func: FN, )
Runs func
on each query result in parallel using the given task_pool
.
This can only be called for read-only queries.
§Safety
This does not check for mutable query correctness. To be safe, make sure mutable queries have unique access to the components they query.
Trait Implementations§
Source§impl<'w, 's, Q, F> SystemParamFetch<'w, 's> for QueryState<Q, F>
impl<'w, 's, Q, F> SystemParamFetch<'w, 's> for QueryState<Q, F>
type Item = Query<'w, 's, Q, F>
Source§unsafe fn get_param(
state: &'s mut QueryState<Q, F>,
system_meta: &SystemMeta,
world: &'w World,
change_tick: u32,
) -> <QueryState<Q, F> as SystemParamFetch<'w, 's>>::Item
unsafe fn get_param( state: &'s mut QueryState<Q, F>, system_meta: &SystemMeta, world: &'w World, change_tick: u32, ) -> <QueryState<Q, F> as SystemParamFetch<'w, 's>>::Item
Source§impl<Q, F> SystemParamState for QueryState<Q, F>
impl<Q, F> SystemParamState for QueryState<Q, F>
Source§type Config = ()
type Config = ()
Plugin
to a System
, or to control the
behavior of the System
. Read morefn init( world: &mut World, system_meta: &mut SystemMeta, _config: <QueryState<Q, F> as SystemParamState>::Config, ) -> QueryState<Q, F>
fn new_archetype(&mut self, archetype: &Archetype, system_meta: &mut SystemMeta)
fn default_config()
fn apply(&mut self, _world: &mut World)
impl<Q, F> ReadOnlySystemParamFetch for QueryState<Q, F>where
Q: WorldQuery,
F: WorldQuery,
<Q as WorldQuery>::Fetch: ReadOnlyFetch,
<F as WorldQuery>::Fetch: FilterFetch,
Auto Trait Implementations§
impl<Q, F> Freeze for QueryState<Q, F>where
<F as WorldQuery>::Fetch: for<'w, 's> Sized,
<Q as WorldQuery>::State: Freeze,
<F as WorldQuery>::State: Freeze,
impl<Q, F> RefUnwindSafe for QueryState<Q, F>where
<F as WorldQuery>::Fetch: for<'w, 's> Sized,
<Q as WorldQuery>::State: RefUnwindSafe,
<F as WorldQuery>::State: RefUnwindSafe,
impl<Q, F> Send for QueryState<Q, F>
impl<Q, F> Sync for QueryState<Q, F>
impl<Q, F> Unpin for QueryState<Q, F>where
<F as WorldQuery>::Fetch: for<'w, 's> Sized,
<Q as WorldQuery>::State: Unpin,
<F as WorldQuery>::State: Unpin,
impl<Q, F> UnwindSafe for QueryState<Q, F>where
<F as WorldQuery>::Fetch: for<'w, 's> Sized,
<Q as WorldQuery>::State: UnwindSafe,
<F as WorldQuery>::State: 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
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.