Struct Extract
pub struct Extract<'w, 's, P>where
P: ReadOnlySystemParam + 'static,{ /* private fields */ }Expand description
A helper for accessing MainWorld content using a system parameter.
A [SystemParam] adapter which applies the contained SystemParam to the [World]
contained in MainWorld. This parameter only works for systems run
during the ExtractSchedule.
This requires that the contained [SystemParam] does not mutate the world, as it
uses a read-only reference to MainWorld internally.
§Context
ExtractSchedule is used to extract (move) data from the simulation world (MainWorld) to the
sub world.
This design is used to allow performing calculations related to a prior frame at the same
time as the next frame is simulated, which increases throughput (FPS).
Extract is used to get data from the main world during ExtractSchedule.
§Examples
use bevy_ecs::prelude::*;
use bevy_extract::Extract;
use bevy_extract::sync_world::SubEntity;
use bevy_derive::AppLabel;
// Do make sure to sync the cloud entities before extracting them.
fn extract_clouds(mut commands: Commands, clouds: Extract<Query<SubEntity<ExtractApp>, With<Cloud>>>) {
for cloud in &clouds {
commands.entity(cloud).insert(Cloud);
}
}Trait Implementations§
§impl<'a, 'w, 's, P> IntoIterator for &'a Extract<'w, 's, P>where
P: ReadOnlySystemParam,
&'a <P as SystemParam>::Item<'w, 's>: IntoIterator,
impl<'a, 'w, 's, P> IntoIterator for &'a Extract<'w, 's, P>where
P: ReadOnlySystemParam,
&'a <P as SystemParam>::Item<'w, 's>: IntoIterator,
§type Item = <&'a <P as SystemParam>::Item<'w, 's> as IntoIterator>::Item
type Item = <&'a <P as SystemParam>::Item<'w, 's> as IntoIterator>::Item
The type of the elements being iterated over.
§type IntoIter = <&'a <P as SystemParam>::Item<'w, 's> as IntoIterator>::IntoIter
type IntoIter = <&'a <P as SystemParam>::Item<'w, 's> as IntoIterator>::IntoIter
Which kind of iterator are we turning this into?
impl<P> ReadOnlySystemParam for Extract<'_, '_, P>where
P: ReadOnlySystemParam,
§impl<P> SystemParam for Extract<'_, '_, P>where
P: ReadOnlySystemParam,
impl<P> SystemParam for Extract<'_, '_, P>where
P: ReadOnlySystemParam,
§type Item<'w, 's> = Extract<'w, 's, P>
type Item<'w, 's> = Extract<'w, 's, P>
The item type returned when constructing this system param.
The value of this associated type should be
Self, instantiated with new lifetimes. Read more§fn init_state(world: &mut World) -> <Extract<'_, '_, P> as SystemParam>::State
fn init_state(world: &mut World) -> <Extract<'_, '_, P> as SystemParam>::State
Creates a new instance of this param’s
State.§fn init_access(
state: &<Extract<'_, '_, P> as SystemParam>::State,
system_meta: &mut SystemMeta,
system_access: &mut SystemAccess,
world: &mut World,
)
fn init_access( state: &<Extract<'_, '_, P> as SystemParam>::State, system_meta: &mut SystemMeta, system_access: &mut SystemAccess, world: &mut World, )
§unsafe fn get_param<'w, 's>(
state: &'s mut <Extract<'_, '_, P> as SystemParam>::State,
system_meta: &SystemMeta,
world: UnsafeWorldCell<'w>,
change_tick: Tick,
) -> Result<<Extract<'_, '_, P> as SystemParam>::Item<'w, 's>, SystemParamValidationError>
unsafe fn get_param<'w, 's>( state: &'s mut <Extract<'_, '_, P> as SystemParam>::State, system_meta: &SystemMeta, world: UnsafeWorldCell<'w>, change_tick: Tick, ) -> Result<<Extract<'_, '_, P> as SystemParam>::Item<'w, 's>, SystemParamValidationError>
Creates a parameter to be passed into a
SystemParamFunction. Read more§fn apply(state: &mut Self::State, system_meta: &SystemMeta, world: &mut World)
fn apply(state: &mut Self::State, system_meta: &SystemMeta, world: &mut World)
Applies any deferred mutations stored in this [
SystemParam]’s state.
This is used to apply Commands during ApplyDeferred.§fn queue(
state: &mut Self::State,
system_meta: &SystemMeta,
world: DeferredWorld<'_>,
)
fn queue( state: &mut Self::State, system_meta: &SystemMeta, world: DeferredWorld<'_>, )
Queues any deferred mutations to be applied at the next
ApplyDeferred.Auto Trait Implementations§
impl<'w, 's, P> Freeze for Extract<'w, 's, P>where
<P as SystemParam>::Item<'w, 's>: Freeze,
impl<'w, 's, P> RefUnwindSafe for Extract<'w, 's, P>where
<P as SystemParam>::Item<'w, 's>: RefUnwindSafe,
impl<'w, 's, P> Send for Extract<'w, 's, P>where
<P as SystemParam>::Item<'w, 's>: Send,
impl<'w, 's, P> Sync for Extract<'w, 's, P>where
<P as SystemParam>::Item<'w, 's>: Sync,
impl<'w, 's, P> Unpin for Extract<'w, 's, P>where
<P as SystemParam>::Item<'w, 's>: Unpin,
impl<'w, 's, P> UnsafeUnpin for Extract<'w, 's, P>where
<P as SystemParam>::Item<'w, 's>: UnsafeUnpin,
impl<'w, 's, P> UnwindSafe for Extract<'w, 's, P>where
<P as SystemParam>::Item<'w, 's>: 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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<T> ConditionalSend for Twhere
T: Send,
impl<R> CryptoRng for R
§impl<T, C, D> Curve<T> for D
impl<T, C, D> Curve<T> for D
§fn sample_unchecked(&self, t: f32) -> T
fn sample_unchecked(&self, t: f32) -> T
Sample a point on this curve at the parameter value
t, extracting the associated value.
This is the unchecked version of sampling, which should only be used if the sample time t
is already known to lie within the curve’s domain. Read more§fn sample(&self, t: f32) -> Option<T>
fn sample(&self, t: f32) -> Option<T>
Sample a point on this curve at the parameter value
t, returning None if the point is
outside of the curve’s domain.§fn sample_clamped(&self, t: f32) -> T
fn sample_clamped(&self, t: f32) -> T
Sample a point on this curve at the parameter value
t, clamping t to lie inside the
domain of the curve.§impl<C, T> CurveExt<T> for Cwhere
C: Curve<T>,
impl<C, T> CurveExt<T> for Cwhere
C: Curve<T>,
§fn sample_iter(
&self,
iter: impl IntoIterator<Item = f32>,
) -> impl Iterator<Item = Option<T>>
fn sample_iter( &self, iter: impl IntoIterator<Item = f32>, ) -> impl Iterator<Item = Option<T>>
Sample a collection of
n >= 0 points on this curve at the parameter values t_n,
returning None if the point is outside of the curve’s domain. Read more§fn sample_iter_unchecked(
&self,
iter: impl IntoIterator<Item = f32>,
) -> impl Iterator<Item = T>
fn sample_iter_unchecked( &self, iter: impl IntoIterator<Item = f32>, ) -> impl Iterator<Item = T>
Sample a collection of
n >= 0 points on this curve at the parameter values t_n,
extracting the associated values. This is the unchecked version of sampling, which should
only be used if the sample times t_n are already known to lie within the curve’s domain. Read more§fn sample_iter_clamped(
&self,
iter: impl IntoIterator<Item = f32>,
) -> impl Iterator<Item = T>
fn sample_iter_clamped( &self, iter: impl IntoIterator<Item = f32>, ) -> impl Iterator<Item = T>
Sample a collection of
n >= 0 points on this curve at the parameter values t_n,
clamping t_n to lie inside the domain of the curve. Read more§fn map<S, F>(self, f: F) -> MapCurve<T, S, Self, F>where
F: Fn(T) -> S,
fn map<S, F>(self, f: F) -> MapCurve<T, S, Self, F>where
F: Fn(T) -> S,
Create a new curve by mapping the values of this curve via a function
f; i.e., if the
sample at time t for this curve is x, the value at time t on the new curve will be
f(x).§fn reparametrize<F>(self, domain: Interval, f: F) -> ReparamCurve<T, Self, F>
fn reparametrize<F>(self, domain: Interval, f: F) -> ReparamCurve<T, Self, F>
Create a new [
Curve] whose parameter space is related to the parameter space of this curve
by f. For each time t, the sample from the new curve at time t is the sample from
this curve at time f(t). The given domain will be the domain of the new curve. The
function f is expected to take domain into self.domain(). Read more§fn reparametrize_linear(
self,
domain: Interval,
) -> Result<LinearReparamCurve<T, Self>, LinearReparamError>
fn reparametrize_linear( self, domain: Interval, ) -> Result<LinearReparamCurve<T, Self>, LinearReparamError>
Linearly reparametrize this [
Curve], producing a new curve whose domain is the given
domain instead of the current one. This operation is only valid for curves with bounded
domains. Read more§fn reparametrize_by_curve<C>(self, other: C) -> CurveReparamCurve<T, Self, C>where
C: Curve<f32>,
fn reparametrize_by_curve<C>(self, other: C) -> CurveReparamCurve<T, Self, C>where
C: Curve<f32>,
Reparametrize this [
Curve] by sampling from another curve. Read more§fn graph(self) -> GraphCurve<T, Self>
fn graph(self) -> GraphCurve<T, Self>
Create a new [
Curve] which is the graph of this one; that is, its output echoes the sample
time as part of a tuple. Read more§fn zip<S, C>(
self,
other: C,
) -> Result<ZipCurve<T, S, Self, C>, InvalidIntervalError>where
C: Curve<S>,
fn zip<S, C>(
self,
other: C,
) -> Result<ZipCurve<T, S, Self, C>, InvalidIntervalError>where
C: Curve<S>,
Create a new [
Curve] by zipping this curve together with another. Read more§fn chain<C>(self, other: C) -> Result<ChainCurve<T, Self, C>, ChainError>where
C: Curve<T>,
fn chain<C>(self, other: C) -> Result<ChainCurve<T, Self, C>, ChainError>where
C: Curve<T>,
Create a new [
Curve] by composing this curve end-to-start with another, producing another curve
with outputs of the same type. The domain of the other curve is translated so that its start
coincides with where this curve ends. Read more§fn reverse(self) -> Result<ReverseCurve<T, Self>, ReverseError>
fn reverse(self) -> Result<ReverseCurve<T, Self>, ReverseError>
Create a new [
Curve] inverting this curve on the x-axis, producing another curve with
outputs of the same type, effectively playing backwards starting at self.domain().end()
and transitioning over to self.domain().start(). The domain of the new curve is still the
same. Read more§fn repeat(self, count: usize) -> Result<RepeatCurve<T, Self>, RepeatError>
fn repeat(self, count: usize) -> Result<RepeatCurve<T, Self>, RepeatError>
Create a new [
Curve] repeating this curve N times, producing another curve with outputs
of the same type. The domain of the new curve will be bigger by a factor of n + 1. Read more§fn forever(self) -> Result<ForeverCurve<T, Self>, RepeatError>
fn forever(self) -> Result<ForeverCurve<T, Self>, RepeatError>
Create a new [
Curve] repeating this curve forever, producing another curve with
outputs of the same type. The domain of the new curve will be unbounded. Read more§fn ping_pong(self) -> Result<PingPongCurve<T, Self>, PingPongError>
fn ping_pong(self) -> Result<PingPongCurve<T, Self>, PingPongError>
Create a new [
Curve] chaining the original curve with its inverse, producing
another curve with outputs of the same type. The domain of the new curve will be twice as
long. The transition point is guaranteed to not make any jumps. Read more§fn chain_continue<C>(
self,
other: C,
) -> Result<ContinuationCurve<T, Self, C>, ChainError>where
T: VectorSpace,
C: Curve<T>,
fn chain_continue<C>(
self,
other: C,
) -> Result<ContinuationCurve<T, Self, C>, ChainError>where
T: VectorSpace,
C: Curve<T>,
Create a new [
Curve] by composing this curve end-to-start with another, producing another
curve with outputs of the same type. The domain of the other curve is translated so that
its start coincides with where this curve ends. Read more§fn samples(
&self,
samples: usize,
) -> Result<impl Iterator<Item = T>, ResamplingError>
fn samples( &self, samples: usize, ) -> Result<impl Iterator<Item = T>, ResamplingError>
Extract an iterator over evenly-spaced samples from this curve. Read more
§impl<C, T> CurveResampleExt<T> for Cwhere
C: Curve<T> + ?Sized,
impl<C, T> CurveResampleExt<T> for Cwhere
C: Curve<T> + ?Sized,
§fn resample<I>(
&self,
segments: usize,
interpolation: I,
) -> Result<SampleCurve<T, I>, ResamplingError>
fn resample<I>( &self, segments: usize, interpolation: I, ) -> Result<SampleCurve<T, I>, ResamplingError>
Resample this [
Curve] to produce a new one that is defined by interpolation over equally
spaced sample values, using the provided interpolation to interpolate between adjacent samples.
The curve is interpolated on segments segments between samples. For example, if segments is 1,
only the start and end points of the curve are used as samples; if segments is 2, a sample at
the midpoint is taken as well, and so on. Read more§fn resample_auto(
&self,
segments: usize,
) -> Result<SampleAutoCurve<T>, ResamplingError>where
T: StableInterpolate,
fn resample_auto(
&self,
segments: usize,
) -> Result<SampleAutoCurve<T>, ResamplingError>where
T: StableInterpolate,
Resample this [
Curve] to produce a new one that is defined by interpolation over equally
spaced sample values, using automatic interpolation to interpolate between adjacent samples.
The curve is interpolated on segments segments between samples. For example, if segments is 1,
only the start and end points of the curve are used as samples; if segments is 2, a sample at
the midpoint is taken as well, and so on. Read more§fn resample_uneven<I>(
&self,
sample_times: impl IntoIterator<Item = f32>,
interpolation: I,
) -> Result<UnevenSampleCurve<T, I>, ResamplingError>
fn resample_uneven<I>( &self, sample_times: impl IntoIterator<Item = f32>, interpolation: I, ) -> Result<UnevenSampleCurve<T, I>, ResamplingError>
Resample this [
Curve] to produce a new one that is defined by interpolation over samples
taken at a given set of times. The given interpolation is used to interpolate adjacent
samples, and the sample_times are expected to contain at least two valid times within the
curve’s domain interval. Read more§fn resample_uneven_auto(
&self,
sample_times: impl IntoIterator<Item = f32>,
) -> Result<UnevenSampleAutoCurve<T>, ResamplingError>where
T: StableInterpolate,
fn resample_uneven_auto(
&self,
sample_times: impl IntoIterator<Item = f32>,
) -> Result<UnevenSampleAutoCurve<T>, ResamplingError>where
T: StableInterpolate,
Resample this [
Curve] to produce a new one that is defined by automatic interpolation over
samples taken at the given set of times. The given sample_times are expected to contain at least
two valid times within the curve’s domain interval. Read more§impl<T, C> CurveWithDerivative<T> for Cwhere
T: HasTangent,
C: SampleDerivative<T>,
impl<T, C> CurveWithDerivative<T> for Cwhere
T: HasTangent,
C: SampleDerivative<T>,
§fn with_derivative(self) -> SampleDerivativeWrapper<C>
fn with_derivative(self) -> SampleDerivativeWrapper<C>
This curve, but with its first derivative included in sampling. Read more
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Converts
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Converts
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Converts
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Converts
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§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.§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.§impl<T> DowncastSend for T
impl<T> DowncastSend for T
§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> DowncastSync for T
impl<T> DowncastSync for T
impl<T> Formattable for T
§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. 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.
impl<T> Parsable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
§impl<R> Rng for R
impl<R> Rng for R
impl<R> RngCore for Rwhere
R: Rng,
§impl<R> RngExt for Rwhere
R: Rng + ?Sized,
impl<R> RngExt for Rwhere
R: Rng + ?Sized,
§fn random<T>(&mut self) -> Twhere
StandardUniform: Distribution<T>,
fn random<T>(&mut self) -> Twhere
StandardUniform: Distribution<T>,
Return a random value via the
StandardUniform distribution. Read more§fn random_iter<T>(self) -> Iter<StandardUniform, Self, T> ⓘwhere
Self: Sized,
StandardUniform: Distribution<T>,
fn random_iter<T>(self) -> Iter<StandardUniform, Self, T> ⓘwhere
Self: Sized,
StandardUniform: Distribution<T>,
§fn random_range<T, R>(&mut self, range: R) -> Twhere
T: SampleUniform,
R: SampleRange<T>,
fn random_range<T, R>(&mut self, range: R) -> Twhere
T: SampleUniform,
R: SampleRange<T>,
Generate a random value in the given range. Read more
§fn random_bool(&mut self, p: f64) -> bool
fn random_bool(&mut self, p: f64) -> bool
Return a bool with a probability
p of being true. Read more§fn random_ratio(&mut self, numerator: u32, denominator: u32) -> bool
fn random_ratio(&mut self, numerator: u32, denominator: u32) -> bool
Return a bool with a probability of
numerator/denominator of being
true. Read more§fn sample<T, D>(&mut self, distr: D) -> Twhere
D: Distribution<T>,
fn sample<T, D>(&mut self, distr: D) -> Twhere
D: Distribution<T>,
Sample a new value, using the given distribution. Read more
§fn sample_iter<T, D>(self, distr: D) -> Iter<D, Self, T> ⓘwhere
D: Distribution<T>,
Self: Sized,
fn sample_iter<T, D>(self, distr: D) -> Iter<D, Self, T> ⓘwhere
D: Distribution<T>,
Self: Sized,
Create an iterator that generates values using the given distribution. Read more
§impl<T, C, D> SampleDerivative<T> for D
impl<T, C, D> SampleDerivative<T> for D
§fn sample_with_derivative_unchecked(&self, t: f32) -> WithDerivative<T>
fn sample_with_derivative_unchecked(&self, t: f32) -> WithDerivative<T>
Sample this curve at the parameter value
t, extracting the associated value
in addition to its derivative. This is the unchecked version of sampling, which
should only be used if the sample time t is already known to lie within the
curve’s domain. Read more§fn sample_with_derivative(&self, t: f32) -> Option<WithDerivative<T>>
fn sample_with_derivative(&self, t: f32) -> Option<WithDerivative<T>>
Sample this curve’s value and derivative at the parameter value
t, returning
None if the point is outside of the curve’s domain.§fn sample_with_derivative_clamped(&self, t: f32) -> WithDerivative<T>
fn sample_with_derivative_clamped(&self, t: f32) -> WithDerivative<T>
Sample this curve’s value and derivative at the parameter value
t, clamping t
to lie inside the domain of the curve.impl<T> Settings for T
impl<R> TryCryptoRng for R
§impl<R> TryRng for R
impl<R> TryRng for R
§type Error = <<R as Deref>::Target as TryRng>::Error
type Error = <<R as Deref>::Target as TryRng>::Error
The type returned in the event of a RNG error. Read more
§fn try_next_u32(&mut self) -> Result<u32, <R as TryRng>::Error>
fn try_next_u32(&mut self) -> Result<u32, <R as TryRng>::Error>
Return the next random
u32.§fn try_next_u64(&mut self) -> Result<u64, <R as TryRng>::Error>
fn try_next_u64(&mut self) -> Result<u64, <R as TryRng>::Error>
Return the next random
u64.§fn try_fill_bytes(&mut self, dst: &mut [u8]) -> Result<(), <R as TryRng>::Error>
fn try_fill_bytes(&mut self, dst: &mut [u8]) -> Result<(), <R as TryRng>::Error>
Fill
dst entirely with random data.