pub struct Schedule { /* private fields */ }Expand description
An ordered list of systems, run together — one Schedule backs each
SystemStage. Deferred Commands
(entity spawns, resource inserts/removes, triggers) are flushed after
each system, not just once at the end — so a system ordered
.after(...) another can rely on seeing its Commands effects, even
within the same stage.
Systems normally run in the order they were added. Call .after(...)/
.before(...) directly on a system (see
IntoSystemConfig) to
constrain it relative to another system known to the schedule — added
earlier or later, registration order doesn’t matter, only the
constraint does. .priority(...) breaks ties between systems with no
after/before relationship to each other — higher runs first — but
never overrides an explicit constraint. .chain() on a tuple of systems
(see Chain, registered with
add_systems) forces them to run in that exact
relative order, and can itself be given .after(...)/.before(...)/
.priority(...), applied to the whole chain:
schedule
.add_system(spawn_enemies)
.add_system(move_enemies.after(spawn_enemies))
.add_system(render.after(move_enemies))
.add_system(hud.priority(10))
.add_systems((physics_step, resolve_collisions).chain().before(render));Implementations§
Source§impl Schedule
impl Schedule
Sourcepub fn add_system<S, Params>(
&mut self,
system: impl Into<SystemConfig<S, Params>>,
) -> &mut Selfwhere
Params: 'static,
S: IntoSystem<Params> + 'static,
pub fn add_system<S, Params>(
&mut self,
system: impl Into<SystemConfig<S, Params>>,
) -> &mut Selfwhere
Params: 'static,
S: IntoSystem<Params> + 'static,
Appends system to the end of this schedule. system may be a bare
system, or one wrapped with .after(...)/.before(...)/.priority(...)
— see IntoSystemConfig.
Sourcepub fn add_systems(&mut self, chain: SystemChain) -> &mut Self
pub fn add_systems(&mut self, chain: SystemChain) -> &mut Self
Appends every system in chain (built with .chain() on a tuple of
systems — see Chain) to the end
of this schedule.
Sourcepub fn run(&mut self, world: &mut World, resources: &mut Resources)
pub fn run(&mut self, world: &mut World, resources: &mut Resources)
Runs every system in order, flushing deferred entity spawns, resource
commands, and triggered observers after each system — not once at
the end of the whole schedule. This is what lets a system that reads
a resource another system just inserted via Commands::insert_resource
see it immediately, as long as it’s ordered .after(...) the system
that queued it — the two don’t need to be in different stages.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Schedule
impl !Send for Schedule
impl !Sync for Schedule
impl !UnwindSafe for Schedule
impl Freeze for Schedule
impl Unpin for Schedule
impl UnsafeUnpin for Schedule
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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.Source§impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
Source§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> 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> ⓘ
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> ⓘ
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().