Struct bevy_internal::ecs::prelude::QueryState
source · [−]#[repr(C)]pub struct QueryState<Q, F = ()> where
Q: WorldQuery,
F: WorldQuery, { /* private fields */ }Expand description
Provides scoped access to a World state according to a given WorldQuery and query filter.
Implementations
sourceimpl<Q, F> QueryState<Q, F> where
Q: WorldQuery,
F: WorldQuery,
impl<Q, F> QueryState<Q, F> where
Q: WorldQuery,
F: WorldQuery,
sourcepub fn as_readonly(
&self
) -> &QueryState<<Q as WorldQuery>::ReadOnly, <F as WorldQuery>::ReadOnly>
pub fn as_readonly(
&self
) -> &QueryState<<Q as WorldQuery>::ReadOnly, <F as WorldQuery>::ReadOnly>
Converts this QueryState reference to a QueryState that does not access anything mutably.
sourcepub fn as_nop(&self) -> &QueryState<NopWorldQuery<Q>, F>
pub fn as_nop(&self) -> &QueryState<NopWorldQuery<Q>, F>
Converts this QueryState reference to a QueryState that does not return any data
which can be faster.
This doesn’t use NopWorldQuery as it loses filter functionality, for example
NopWorldQuery<Changed<T>> is functionally equivalent to With<T>.
sourceimpl<Q, F> QueryState<Q, F> where
Q: WorldQuery,
F: WorldQuery,
impl<Q, F> QueryState<Q, F> where
Q: WorldQuery,
F: WorldQuery,
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(
&mut self,
world: &'w World,
entity: Entity
) -> Result<<<<Q as WorldQuery>::ReadOnly as WorldQueryGats<'w>>::Fetch as Fetch<'w>>::Item, QueryEntityError>
pub fn get(
&mut self,
world: &'w World,
entity: Entity
) -> Result<<<<Q as WorldQuery>::ReadOnly as WorldQueryGats<'w>>::Fetch as Fetch<'w>>::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_many<const N: usize>(
&mut self,
world: &'w World,
entities: [Entity; N]
) -> Result<[<<<Q as WorldQuery>::ReadOnly as WorldQueryGats<'w>>::Fetch as Fetch<'w>>::Item; N], QueryEntityError>
pub fn get_many<const N: usize>(
&mut self,
world: &'w World,
entities: [Entity; N]
) -> Result<[<<<Q as WorldQuery>::ReadOnly as WorldQueryGats<'w>>::Fetch as Fetch<'w>>::Item; N], QueryEntityError>
Returns the read-only query results for the given array of Entity.
In case of a nonexisting entity or mismatched component, a QueryEntityError is
returned instead.
Note that the unlike QueryState::get_many_mut, the entities passed in do not need to be unique.
Examples
use bevy_ecs::prelude::*;
use bevy_ecs::query::QueryEntityError;
#[derive(Component, PartialEq, Debug)]
struct A(usize);
let mut world = World::new();
let entity_vec: Vec<Entity> = (0..3).map(|i|world.spawn().insert(A(i)).id()).collect();
let entities: [Entity; 3] = entity_vec.try_into().unwrap();
world.spawn().insert(A(73));
let mut query_state = world.query::<&A>();
let component_values = query_state.get_many(&world, entities).unwrap();
assert_eq!(component_values, [&A(0), &A(1), &A(2)]);
let wrong_entity = Entity::from_raw(365);
assert_eq!(query_state.get_many(&world, [wrong_entity]), Err(QueryEntityError::NoSuchEntity(wrong_entity)));sourcepub fn get_mut(
&mut self,
world: &'w mut World,
entity: Entity
) -> Result<<<Q as WorldQueryGats<'w>>::Fetch as Fetch<'w>>::Item, QueryEntityError>
pub fn get_mut(
&mut self,
world: &'w mut World,
entity: Entity
) -> Result<<<Q as WorldQueryGats<'w>>::Fetch as Fetch<'w>>::Item, QueryEntityError>
sourcepub fn get_many_mut<const N: usize>(
&mut self,
world: &'w mut World,
entities: [Entity; N]
) -> Result<[<<Q as WorldQueryGats<'w>>::Fetch as Fetch<'w>>::Item; N], QueryEntityError>
pub fn get_many_mut<const N: usize>(
&mut self,
world: &'w mut World,
entities: [Entity; N]
) -> Result<[<<Q as WorldQueryGats<'w>>::Fetch as Fetch<'w>>::Item; N], QueryEntityError>
Returns the query results for the given array of Entity.
In case of a nonexisting entity or mismatched component, a QueryEntityError is
returned instead.
use bevy_ecs::prelude::*;
use bevy_ecs::query::QueryEntityError;
#[derive(Component, PartialEq, Debug)]
struct A(usize);
let mut world = World::new();
let entities: Vec<Entity> = (0..3).map(|i|world.spawn().insert(A(i)).id()).collect();
let entities: [Entity; 3] = entities.try_into().unwrap();
world.spawn().insert(A(73));
let mut query_state = world.query::<&mut A>();
let mut mutable_component_values = query_state.get_many_mut(&mut world, entities).unwrap();
for mut a in &mut mutable_component_values {
a.0 += 5;
}
let component_values = query_state.get_many(&world, entities).unwrap();
assert_eq!(component_values, [&A(5), &A(6), &A(7)]);
let wrong_entity = Entity::from_raw(57);
let invalid_entity = world.spawn().id();
assert_eq!(query_state.get_many_mut(&mut world, [wrong_entity]).unwrap_err(), QueryEntityError::NoSuchEntity(wrong_entity));
assert_eq!(query_state.get_many_mut(&mut world, [invalid_entity]).unwrap_err(), QueryEntityError::QueryDoesNotMatch(invalid_entity));
assert_eq!(query_state.get_many_mut(&mut world, [entities[0], entities[0]]).unwrap_err(), QueryEntityError::AliasedMutability(entities[0]));pub fn get_manual(
&self,
world: &'w World,
entity: Entity
) -> Result<<<<Q as WorldQuery>::ReadOnly as WorldQueryGats<'w>>::Fetch as Fetch<'w>>::Item, QueryEntityError>
sourcepub unsafe fn get_unchecked(
&mut self,
world: &'w World,
entity: Entity
) -> Result<<<Q as WorldQueryGats<'w>>::Fetch as Fetch<'w>>::Item, QueryEntityError>
pub unsafe fn get_unchecked(
&mut self,
world: &'w World,
entity: Entity
) -> Result<<<Q as WorldQueryGats<'w>>::Fetch as Fetch<'w>>::Item, QueryEntityError>
sourcepub fn iter(
&'s mut self,
world: &'w World
) -> QueryIter<'w, 's, <Q as WorldQuery>::ReadOnly, <F as WorldQuery>::ReadOnly>ⓘNotable traits for QueryIter<'w, 's, Q, F>impl<'w, 's, Q, F> Iterator for QueryIter<'w, 's, Q, F> where
Q: WorldQuery,
F: WorldQuery, type Item = <<Q as WorldQueryGats<'w>>::Fetch as Fetch<'w>>::Item;
pub fn iter(
&'s mut self,
world: &'w World
) -> QueryIter<'w, 's, <Q as WorldQuery>::ReadOnly, <F as WorldQuery>::ReadOnly>ⓘNotable traits for QueryIter<'w, 's, Q, F>impl<'w, 's, Q, F> Iterator for QueryIter<'w, 's, Q, F> where
Q: WorldQuery,
F: WorldQuery, type Item = <<Q as WorldQueryGats<'w>>::Fetch as Fetch<'w>>::Item;
Q: WorldQuery,
F: WorldQuery, type Item = <<Q as WorldQueryGats<'w>>::Fetch as Fetch<'w>>::Item;
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(&'s mut self, world: &'w mut World) -> QueryIter<'w, 's, Q, F>ⓘNotable traits for QueryIter<'w, 's, Q, F>impl<'w, 's, Q, F> Iterator for QueryIter<'w, 's, Q, F> where
Q: WorldQuery,
F: WorldQuery, type Item = <<Q as WorldQueryGats<'w>>::Fetch as Fetch<'w>>::Item;
pub fn iter_mut(&'s mut self, world: &'w mut World) -> QueryIter<'w, 's, Q, F>ⓘNotable traits for QueryIter<'w, 's, Q, F>impl<'w, 's, Q, F> Iterator for QueryIter<'w, 's, Q, F> where
Q: WorldQuery,
F: WorldQuery, type Item = <<Q as WorldQueryGats<'w>>::Fetch as Fetch<'w>>::Item;
Q: WorldQuery,
F: WorldQuery, type Item = <<Q as WorldQueryGats<'w>>::Fetch as Fetch<'w>>::Item;
sourcepub fn iter_manual(
&'s self,
world: &'w World
) -> QueryIter<'w, 's, <Q as WorldQuery>::ReadOnly, <F as WorldQuery>::ReadOnly>ⓘNotable traits for QueryIter<'w, 's, Q, F>impl<'w, 's, Q, F> Iterator for QueryIter<'w, 's, Q, F> where
Q: WorldQuery,
F: WorldQuery, type Item = <<Q as WorldQueryGats<'w>>::Fetch as Fetch<'w>>::Item;
pub fn iter_manual(
&'s self,
world: &'w World
) -> QueryIter<'w, 's, <Q as WorldQuery>::ReadOnly, <F as WorldQuery>::ReadOnly>ⓘNotable traits for QueryIter<'w, 's, Q, F>impl<'w, 's, Q, F> Iterator for QueryIter<'w, 's, Q, F> where
Q: WorldQuery,
F: WorldQuery, type Item = <<Q as WorldQueryGats<'w>>::Fetch as Fetch<'w>>::Item;
Q: WorldQuery,
F: WorldQuery, type Item = <<Q as WorldQueryGats<'w>>::Fetch as Fetch<'w>>::Item;
Returns an Iterator over the query results for the given World without updating the query’s archetypes.
Archetypes must be manually updated before by using Self::update_archetypes.
This can only be called for read-only queries.
sourcepub fn iter_combinations<const K: usize>(
&'s mut self,
world: &'w World
) -> QueryCombinationIter<'w, 's, <Q as WorldQuery>::ReadOnly, <F as WorldQuery>::ReadOnly, K>ⓘNotable traits for QueryCombinationIter<'w, 's, Q, F, K>impl<'w, 's, Q, F, const K: usize> Iterator for QueryCombinationIter<'w, 's, Q, F, K> where
Q: ReadOnlyWorldQuery,
F: ReadOnlyWorldQuery,
<Q as WorldQueryGats<'w>>::Fetch: Clone,
<F as WorldQueryGats<'w>>::Fetch: Clone, type Item = [<<Q as WorldQueryGats<'w>>::Fetch as Fetch<'w>>::Item; K];
pub fn iter_combinations<const K: usize>(
&'s mut self,
world: &'w World
) -> QueryCombinationIter<'w, 's, <Q as WorldQuery>::ReadOnly, <F as WorldQuery>::ReadOnly, K>ⓘNotable traits for QueryCombinationIter<'w, 's, Q, F, K>impl<'w, 's, Q, F, const K: usize> Iterator for QueryCombinationIter<'w, 's, Q, F, K> where
Q: ReadOnlyWorldQuery,
F: ReadOnlyWorldQuery,
<Q as WorldQueryGats<'w>>::Fetch: Clone,
<F as WorldQueryGats<'w>>::Fetch: Clone, type Item = [<<Q as WorldQueryGats<'w>>::Fetch as Fetch<'w>>::Item; K];
Q: ReadOnlyWorldQuery,
F: ReadOnlyWorldQuery,
<Q as WorldQueryGats<'w>>::Fetch: Clone,
<F as WorldQueryGats<'w>>::Fetch: Clone, type Item = [<<Q as WorldQueryGats<'w>>::Fetch as Fetch<'w>>::Item; 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 possibleK-sized combinations of query results, without repetition - if
K > N: empty set (noK-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<const K: usize>(
&'s mut self,
world: &'w mut World
) -> QueryCombinationIter<'w, 's, Q, F, K>ⓘNotable traits for QueryCombinationIter<'w, 's, Q, F, K>impl<'w, 's, Q, F, const K: usize> Iterator for QueryCombinationIter<'w, 's, Q, F, K> where
Q: ReadOnlyWorldQuery,
F: ReadOnlyWorldQuery,
<Q as WorldQueryGats<'w>>::Fetch: Clone,
<F as WorldQueryGats<'w>>::Fetch: Clone, type Item = [<<Q as WorldQueryGats<'w>>::Fetch as Fetch<'w>>::Item; K];
pub fn iter_combinations_mut<const K: usize>(
&'s mut self,
world: &'w mut World
) -> QueryCombinationIter<'w, 's, Q, F, K>ⓘNotable traits for QueryCombinationIter<'w, 's, Q, F, K>impl<'w, 's, Q, F, const K: usize> Iterator for QueryCombinationIter<'w, 's, Q, F, K> where
Q: ReadOnlyWorldQuery,
F: ReadOnlyWorldQuery,
<Q as WorldQueryGats<'w>>::Fetch: Clone,
<F as WorldQueryGats<'w>>::Fetch: Clone, type Item = [<<Q as WorldQueryGats<'w>>::Fetch as Fetch<'w>>::Item; K];
Q: ReadOnlyWorldQuery,
F: ReadOnlyWorldQuery,
<Q as WorldQueryGats<'w>>::Fetch: Clone,
<F as WorldQueryGats<'w>>::Fetch: Clone, type Item = [<<Q as WorldQueryGats<'w>>::Fetch as Fetch<'w>>::Item; 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 possibleK-sized combinations of query results, without repetition - if
K > N: empty set (noK-sized combinations exist)
sourcepub fn iter_many<EntityList>(
&'s mut self,
world: &'w World,
entities: EntityList
) -> QueryManyIter<'w, 's, <Q as WorldQuery>::ReadOnly, <F as WorldQuery>::ReadOnly, <EntityList as IntoIterator>::IntoIter>ⓘNotable traits for QueryManyIter<'w, 's, Q, F, I>impl<'w, 's, Q, F, I> Iterator for QueryManyIter<'w, 's, Q, F, I> where
Q: ReadOnlyWorldQuery,
F: ReadOnlyWorldQuery,
I: Iterator,
<I as Iterator>::Item: Borrow<Entity>, type Item = <<Q as WorldQueryGats<'w>>::Fetch as Fetch<'w>>::Item; where
EntityList: IntoIterator,
<EntityList as IntoIterator>::Item: Borrow<Entity>,
pub fn iter_many<EntityList>(
&'s mut self,
world: &'w World,
entities: EntityList
) -> QueryManyIter<'w, 's, <Q as WorldQuery>::ReadOnly, <F as WorldQuery>::ReadOnly, <EntityList as IntoIterator>::IntoIter>ⓘNotable traits for QueryManyIter<'w, 's, Q, F, I>impl<'w, 's, Q, F, I> Iterator for QueryManyIter<'w, 's, Q, F, I> where
Q: ReadOnlyWorldQuery,
F: ReadOnlyWorldQuery,
I: Iterator,
<I as Iterator>::Item: Borrow<Entity>, type Item = <<Q as WorldQueryGats<'w>>::Fetch as Fetch<'w>>::Item; where
EntityList: IntoIterator,
<EntityList as IntoIterator>::Item: Borrow<Entity>,
Q: ReadOnlyWorldQuery,
F: ReadOnlyWorldQuery,
I: Iterator,
<I as Iterator>::Item: Borrow<Entity>, type Item = <<Q as WorldQueryGats<'w>>::Fetch as Fetch<'w>>::Item;
Returns an Iterator over the query results of a list of Entity’s.
This can only return immutable data (mutable data will be cast to an immutable form).
See Self::iter_many_mut for queries that contain at least one mutable component.
sourcepub fn iter_many_mut<EntityList>(
&'s mut self,
world: &'w mut World,
entities: EntityList
) -> QueryManyIter<'w, 's, Q, F, <EntityList as IntoIterator>::IntoIter>ⓘNotable traits for QueryManyIter<'w, 's, Q, F, I>impl<'w, 's, Q, F, I> Iterator for QueryManyIter<'w, 's, Q, F, I> where
Q: ReadOnlyWorldQuery,
F: ReadOnlyWorldQuery,
I: Iterator,
<I as Iterator>::Item: Borrow<Entity>, type Item = <<Q as WorldQueryGats<'w>>::Fetch as Fetch<'w>>::Item; where
EntityList: IntoIterator,
<EntityList as IntoIterator>::Item: Borrow<Entity>,
pub fn iter_many_mut<EntityList>(
&'s mut self,
world: &'w mut World,
entities: EntityList
) -> QueryManyIter<'w, 's, Q, F, <EntityList as IntoIterator>::IntoIter>ⓘNotable traits for QueryManyIter<'w, 's, Q, F, I>impl<'w, 's, Q, F, I> Iterator for QueryManyIter<'w, 's, Q, F, I> where
Q: ReadOnlyWorldQuery,
F: ReadOnlyWorldQuery,
I: Iterator,
<I as Iterator>::Item: Borrow<Entity>, type Item = <<Q as WorldQueryGats<'w>>::Fetch as Fetch<'w>>::Item; where
EntityList: IntoIterator,
<EntityList as IntoIterator>::Item: Borrow<Entity>,
Q: ReadOnlyWorldQuery,
F: ReadOnlyWorldQuery,
I: Iterator,
<I as Iterator>::Item: Borrow<Entity>, type Item = <<Q as WorldQueryGats<'w>>::Fetch as Fetch<'w>>::Item;
Returns an iterator over the query results of a list of Entity’s.
sourcepub unsafe fn iter_unchecked(
&'s mut self,
world: &'w World
) -> QueryIter<'w, 's, Q, F>ⓘNotable traits for QueryIter<'w, 's, Q, F>impl<'w, 's, Q, F> Iterator for QueryIter<'w, 's, Q, F> where
Q: WorldQuery,
F: WorldQuery, type Item = <<Q as WorldQueryGats<'w>>::Fetch as Fetch<'w>>::Item;
pub unsafe fn iter_unchecked(
&'s mut self,
world: &'w World
) -> QueryIter<'w, 's, Q, F>ⓘNotable traits for QueryIter<'w, 's, Q, F>impl<'w, 's, Q, F> Iterator for QueryIter<'w, 's, Q, F> where
Q: WorldQuery,
F: WorldQuery, type Item = <<Q as WorldQueryGats<'w>>::Fetch as Fetch<'w>>::Item;
Q: WorldQuery,
F: WorldQuery, type Item = <<Q as WorldQueryGats<'w>>::Fetch as Fetch<'w>>::Item;
sourcepub unsafe fn iter_combinations_unchecked<const K: usize>(
&'s mut self,
world: &'w World
) -> QueryCombinationIter<'w, 's, Q, F, K>ⓘNotable traits for QueryCombinationIter<'w, 's, Q, F, K>impl<'w, 's, Q, F, const K: usize> Iterator for QueryCombinationIter<'w, 's, Q, F, K> where
Q: ReadOnlyWorldQuery,
F: ReadOnlyWorldQuery,
<Q as WorldQueryGats<'w>>::Fetch: Clone,
<F as WorldQueryGats<'w>>::Fetch: Clone, type Item = [<<Q as WorldQueryGats<'w>>::Fetch as Fetch<'w>>::Item; K];
pub unsafe fn iter_combinations_unchecked<const K: usize>(
&'s mut self,
world: &'w World
) -> QueryCombinationIter<'w, 's, Q, F, K>ⓘNotable traits for QueryCombinationIter<'w, 's, Q, F, K>impl<'w, 's, Q, F, const K: usize> Iterator for QueryCombinationIter<'w, 's, Q, F, K> where
Q: ReadOnlyWorldQuery,
F: ReadOnlyWorldQuery,
<Q as WorldQueryGats<'w>>::Fetch: Clone,
<F as WorldQueryGats<'w>>::Fetch: Clone, type Item = [<<Q as WorldQueryGats<'w>>::Fetch as Fetch<'w>>::Item; K];
Q: ReadOnlyWorldQuery,
F: ReadOnlyWorldQuery,
<Q as WorldQueryGats<'w>>::Fetch: Clone,
<F as WorldQueryGats<'w>>::Fetch: Clone, type Item = [<<Q as WorldQueryGats<'w>>::Fetch as Fetch<'w>>::Item; 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, FN>(&mut self, world: &'w World, func: FN) where
FN: FnMut(<<<Q as WorldQuery>::ReadOnly as WorldQueryGats<'w>>::Fetch as Fetch<'w>>::Item),
pub fn for_each<'w, FN>(&mut self, world: &'w World, func: FN) where
FN: FnMut(<<<Q as WorldQuery>::ReadOnly as WorldQueryGats<'w>>::Fetch as Fetch<'w>>::Item),
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, FN>(&mut self, world: &'w mut World, func: FN) where
FN: FnMut(<<Q as WorldQueryGats<'w>>::Fetch as Fetch<'w>>::Item),
pub fn for_each_mut<'w, FN>(&mut self, world: &'w mut World, func: FN) where
FN: FnMut(<<Q as WorldQueryGats<'w>>::Fetch as Fetch<'w>>::Item),
sourcepub unsafe fn for_each_unchecked<'w, FN>(&mut self, world: &'w World, func: FN) where
FN: FnMut(<<Q as WorldQueryGats<'w>>::Fetch as Fetch<'w>>::Item),
pub unsafe fn for_each_unchecked<'w, FN>(&mut self, world: &'w World, func: FN) where
FN: FnMut(<<Q as WorldQueryGats<'w>>::Fetch as Fetch<'w>>::Item),
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, FN>(
&mut self,
world: &'w World,
batch_size: usize,
func: FN
) where
FN: Fn(<<<Q as WorldQuery>::ReadOnly as WorldQueryGats<'w>>::Fetch as Fetch<'w>>::Item) + Send + Sync + Clone,
pub fn par_for_each<'w, FN>(
&mut self,
world: &'w World,
batch_size: usize,
func: FN
) where
FN: Fn(<<<Q as WorldQuery>::ReadOnly as WorldQueryGats<'w>>::Fetch as Fetch<'w>>::Item) + Send + Sync + Clone,
Runs func on each query result in parallel.
This can only be called for read-only queries, see Self::par_for_each_mut for
write-queries.
Panics
The ComputeTaskPool is not initialized. If using this from a query that is being
initialized and run from the ECS scheduler, this should never panic.
sourcepub fn par_for_each_mut<'w, FN>(
&mut self,
world: &'w mut World,
batch_size: usize,
func: FN
) where
FN: Fn(<<Q as WorldQueryGats<'w>>::Fetch as Fetch<'w>>::Item) + Send + Sync + Clone,
pub fn par_for_each_mut<'w, FN>(
&mut self,
world: &'w mut World,
batch_size: usize,
func: FN
) where
FN: Fn(<<Q as WorldQueryGats<'w>>::Fetch as Fetch<'w>>::Item) + Send + Sync + Clone,
Runs func on each query result in parallel.
Panics
The ComputeTaskPool is not initialized. If using this from a query that is being
initialized and run from the ECS scheduler, this should never panic.
sourcepub unsafe fn par_for_each_unchecked<'w, FN>(
&mut self,
world: &'w World,
batch_size: usize,
func: FN
) where
FN: Fn(<<Q as WorldQueryGats<'w>>::Fetch as Fetch<'w>>::Item) + Send + Sync + Clone,
pub unsafe fn par_for_each_unchecked<'w, FN>(
&mut self,
world: &'w World,
batch_size: usize,
func: FN
) where
FN: Fn(<<Q as WorldQueryGats<'w>>::Fetch as Fetch<'w>>::Item) + Send + Sync + Clone,
Runs func on each query result in parallel.
This can only be called for read-only queries.
Panics
The ComputeTaskPool is not initialized. If using this from a query that is being
initialized and run from the ECS scheduler, this should never panic.
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 single(
&mut self,
world: &'w World
) -> <<<Q as WorldQuery>::ReadOnly as WorldQueryGats<'w>>::Fetch as Fetch<'w>>::Item
pub fn single(
&mut self,
world: &'w World
) -> <<<Q as WorldQuery>::ReadOnly as WorldQueryGats<'w>>::Fetch as Fetch<'w>>::Item
Returns a single immutable query result when there is exactly one entity matching the query.
This can only be called for read-only queries,
see single_mut for write-queries.
Panics
Panics if the number of query results is not exactly one. Use
get_single to return a Result instead of panicking.
sourcepub fn get_single(
&mut self,
world: &'w World
) -> Result<<<<Q as WorldQuery>::ReadOnly as WorldQueryGats<'w>>::Fetch as Fetch<'w>>::Item, QuerySingleError>
pub fn get_single(
&mut self,
world: &'w World
) -> Result<<<<Q as WorldQuery>::ReadOnly as WorldQueryGats<'w>>::Fetch as Fetch<'w>>::Item, QuerySingleError>
Returns a single immutable query result when there is exactly one entity matching the query.
This can only be called for read-only queries,
see get_single_mut for write-queries.
If the number of query results is not exactly one, a QuerySingleError is returned
instead.
sourcepub fn single_mut(
&mut self,
world: &'w mut World
) -> <<Q as WorldQueryGats<'w>>::Fetch as Fetch<'w>>::Item
pub fn single_mut(
&mut self,
world: &'w mut World
) -> <<Q as WorldQueryGats<'w>>::Fetch as Fetch<'w>>::Item
Returns a single mutable query result when there is exactly one entity matching the query.
Panics
Panics if the number of query results is not exactly one. Use
get_single_mut to return a Result instead of panicking.
sourcepub fn get_single_mut(
&mut self,
world: &'w mut World
) -> Result<<<Q as WorldQueryGats<'w>>::Fetch as Fetch<'w>>::Item, QuerySingleError>
pub fn get_single_mut(
&mut self,
world: &'w mut World
) -> Result<<<Q as WorldQueryGats<'w>>::Fetch as Fetch<'w>>::Item, QuerySingleError>
Returns a single mutable query result when there is exactly one entity matching the query.
If the number of query results is not exactly one, a QuerySingleError is returned
instead.
sourcepub unsafe fn get_single_unchecked(
&mut self,
world: &'w World
) -> Result<<<Q as WorldQueryGats<'w>>::Fetch as Fetch<'w>>::Item, QuerySingleError>
pub unsafe fn get_single_unchecked(
&mut self,
world: &'w World
) -> Result<<<Q as WorldQueryGats<'w>>::Fetch as Fetch<'w>>::Item, QuerySingleError>
Returns a query result when there is exactly one entity matching the query.
If the number of query results is not exactly one, a QuerySingleError is returned
instead.
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 unsafe fn get_single_unchecked_manual(
&self,
world: &'w World,
last_change_tick: u32,
change_tick: u32
) -> Result<<<Q as WorldQueryGats<'w>>::Fetch as Fetch<'w>>::Item, QuerySingleError>
pub unsafe fn get_single_unchecked_manual(
&self,
world: &'w World,
last_change_tick: u32,
change_tick: u32
) -> Result<<<Q as WorldQueryGats<'w>>::Fetch as Fetch<'w>>::Item, QuerySingleError>
Returns a query result when there is exactly one entity matching the query, where the last change and the current change tick are given.
If the number of query results is not exactly one, a QuerySingleError is returned
instead.
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
sourceimpl<Q, F> FromWorld for QueryState<Q, F> where
Q: WorldQuery,
F: WorldQuery,
impl<Q, F> FromWorld for QueryState<Q, F> where
Q: WorldQuery,
F: WorldQuery,
sourcefn from_world(world: &mut World) -> QueryState<Q, F>
fn from_world(world: &mut World) -> QueryState<Q, F>
Creates Self using data from the given World
sourceimpl<'w, 's, Q, F> SystemParamFetch<'w, 's> for QueryState<Q, F> where
Q: 'static + WorldQuery,
F: 'static + WorldQuery,
impl<'w, 's, Q, F> SystemParamFetch<'w, 's> for QueryState<Q, F> where
Q: 'static + WorldQuery,
F: 'static + WorldQuery,
type Item = Query<'w, 's, Q, F>
sourceunsafe 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
Safety Read more
sourceimpl<Q, F> SystemParamState for QueryState<Q, F> where
Q: 'static + WorldQuery,
F: 'static + WorldQuery,
impl<Q, F> SystemParamState for QueryState<Q, F> where
Q: 'static + WorldQuery,
F: 'static + WorldQuery,
fn init(world: &mut World, system_meta: &mut SystemMeta) -> QueryState<Q, F>
fn new_archetype(&mut self, archetype: &Archetype, system_meta: &mut SystemMeta)
fn apply(&mut self, _world: &mut World)
impl<Q, F> ReadOnlySystemParamFetch for QueryState<Q, F> where
Q: ReadOnlyWorldQuery,
F: WorldQuery,
Auto Trait Implementations
impl<Q, F> RefUnwindSafe for QueryState<Q, F> where
<F as WorldQuery>::State: RefUnwindSafe,
<Q 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>::State: Unpin,
<Q as WorldQuery>::State: Unpin,
impl<Q, F> UnwindSafe for QueryState<Q, F> where
<F as WorldQuery>::State: UnwindSafe,
<Q as WorldQuery>::State: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<T> Downcast for T where
T: Any,
impl<T> Downcast for T where
T: Any,
fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
Convert 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. Read more
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait. Read more
fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s. Read more
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>ⓘNotable traits for Instrumented<T>impl<T> Future for Instrumented<T> where
T: Future, type Output = <T as Future>::Output;
fn instrument(self, span: Span) -> Instrumented<Self>ⓘNotable traits for Instrumented<T>impl<T> Future for Instrumented<T> where
T: Future, type Output = <T as Future>::Output;
T: Future, type Output = <T as Future>::Output;
sourcefn in_current_span(self) -> Instrumented<Self>ⓘNotable traits for Instrumented<T>impl<T> Future for Instrumented<T> where
T: Future, type Output = <T as Future>::Output;
fn in_current_span(self) -> Instrumented<Self>ⓘNotable traits for Instrumented<T>impl<T> Future for Instrumented<T> where
T: Future, type Output = <T as Future>::Output;
T: Future, type Output = <T as Future>::Output;
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>ⓘNotable traits for WithDispatch<T>impl<T> Future for WithDispatch<T> where
T: Future, type Output = <T as Future>::Output; where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>ⓘNotable traits for WithDispatch<T>impl<T> Future for WithDispatch<T> where
T: Future, type Output = <T as Future>::Output; where
S: Into<Dispatch>,
T: Future, type Output = <T as Future>::Output;
Attaches the provided Subscriber to this type, returning a
WithDispatch wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>ⓘNotable traits for WithDispatch<T>impl<T> Future for WithDispatch<T> where
T: Future, type Output = <T as Future>::Output;
fn with_current_subscriber(self) -> WithDispatch<Self>ⓘNotable traits for WithDispatch<T>impl<T> Future for WithDispatch<T> where
T: Future, type Output = <T as Future>::Output;
T: Future, type Output = <T as Future>::Output;
Attaches the current default Subscriber to this type, returning a
WithDispatch wrapper. Read more