Struct With
pub struct With<T>(/* private fields */);Expand description
Filter that selects entities with a component T.
This can be used in a Query if entities are required to have the
component T but you don’t actually care about components value.
This is the negation of Without.
§Examples
fn compliment_entity_system(query: Query<&Name, With<IsBeautiful>>) {
for name in &query {
println!("{} is looking lovely today!", name.name);
}
}Trait Implementations§
§impl<T> QueryFilter for With<T>where
T: Component,
impl<T> QueryFilter for With<T>where
T: Component,
§const IS_ARCHETYPAL: bool = true
const IS_ARCHETYPAL: bool = true
Returns true if (and only if) this Filter relies strictly on archetypes to limit which
components are accessed by the Query. Read more
§impl<T> WorldQuery for With<T>where
T: Component,
impl<T> WorldQuery for With<T>where
T: Component,
§const IS_DENSE: bool
const IS_DENSE: bool
Returns true if (and only if) every table of every archetype matched by this fetch contains
all of the matched components. Read more
§type Fetch<'w> = ()
type Fetch<'w> = ()
Per archetype/table state retrieved by this [
WorldQuery] to compute Self::Item for each entity.§type State = ComponentId
type State = ComponentId
State used to construct a
Self::Fetch. This will be cached inside QueryState,
so it is best to move as much data / computation here as possible to reduce the cost of
constructing Self::Fetch.§fn shrink_fetch<'wlong, 'wshort>(
_: <With<T> as WorldQuery>::Fetch<'wlong>,
) -> <With<T> as WorldQuery>::Fetch<'wshort>where
'wlong: 'wshort,
fn shrink_fetch<'wlong, 'wshort>(
_: <With<T> as WorldQuery>::Fetch<'wlong>,
) -> <With<T> as WorldQuery>::Fetch<'wshort>where
'wlong: 'wshort,
This function manually implements subtyping for the query fetches.
§unsafe fn init_fetch(
_world: UnsafeWorldCell<'_>,
_state: &ComponentId,
_last_run: Tick,
_this_run: Tick,
)
unsafe fn init_fetch( _world: UnsafeWorldCell<'_>, _state: &ComponentId, _last_run: Tick, _this_run: Tick, )
Creates a new instance of
Self::Fetch,
by combining data from the World with the cached Self::State.
Readonly accesses resources registered in [WorldQuery::update_component_access]. Read more§unsafe fn set_archetype(
_fetch: &mut (),
_state: &ComponentId,
_archetype: &Archetype,
_table: &Table,
)
unsafe fn set_archetype( _fetch: &mut (), _state: &ComponentId, _archetype: &Archetype, _table: &Table, )
Adjusts internal state to account for the next [
Archetype]. This will always be called on
archetypes that match this [WorldQuery]. Read more§unsafe fn set_table(_fetch: &mut (), _state: &ComponentId, _table: &Table)
unsafe fn set_table(_fetch: &mut (), _state: &ComponentId, _table: &Table)
Adjusts internal state to account for the next [
Table]. This will always be called on tables
that match this [WorldQuery]. Read more§fn update_component_access(_: &ComponentId, access: &mut FilteredAccess)
fn update_component_access(_: &ComponentId, access: &mut FilteredAccess)
§fn init_state(world: &mut World) -> ComponentId
fn init_state(world: &mut World) -> ComponentId
Creates and initializes a
State for this [WorldQuery] type.§fn matches_component_set(
_: &ComponentId,
set_contains_id: &impl Fn(ComponentId) -> bool,
) -> bool
fn matches_component_set( _: &ComponentId, set_contains_id: &impl Fn(ComponentId) -> bool, ) -> bool
§fn init_nested_access(
_state: &Self::State,
_system_name: Option<&str>,
_component_access_set: &mut FilteredAccessSet,
_world: UnsafeWorldCell<'_>,
)
fn init_nested_access( _state: &Self::State, _system_name: Option<&str>, _component_access_set: &mut FilteredAccessSet, _world: UnsafeWorldCell<'_>, )
Adds any component accesses to other entities used by this [
WorldQuery]. Read more§fn update_archetypes(_state: &mut Self::State, _world: UnsafeWorldCell<'_>)
fn update_archetypes(_state: &mut Self::State, _world: UnsafeWorldCell<'_>)
Called when the query state is updating its archetype cache.
This can be used by nested queries to update their internal archetype caches.
impl<T> ArchetypeFilter for With<T>where
T: Component,
Auto Trait Implementations§
impl<T> Freeze for With<T>
impl<T> RefUnwindSafe for With<T>where
T: RefUnwindSafe,
impl<T> Send for With<T>where
T: Send,
impl<T> Sync for With<T>where
T: Sync,
impl<T> Unpin for With<T>where
T: Unpin,
impl<T> UnsafeUnpin for With<T>
impl<T> UnwindSafe for With<T>where
T: 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
Mutably borrows from an owned value. Read more
§impl<T> IntoResult<T> for T
impl<T> IntoResult<T> for T
§fn into_result(self) -> Result<T, RunSystemError>
fn into_result(self) -> Result<T, RunSystemError>
Converts this type into the system output type.