Trait bevy::prelude::IntoSystemConfigs
pub trait IntoSystemConfigs<Marker>: Sized {
// Required method
fn into_configs(
self
) -> NodeConfigs<Box<dyn System<In = (), Out = ()>, Global>>;
// Provided methods
fn in_set(
self,
set: impl SystemSet
) -> NodeConfigs<Box<dyn System<In = (), Out = ()>, Global>> { ... }
fn before<M>(
self,
set: impl IntoSystemSet<M>
) -> NodeConfigs<Box<dyn System<In = (), Out = ()>, Global>> { ... }
fn after<M>(
self,
set: impl IntoSystemSet<M>
) -> NodeConfigs<Box<dyn System<In = (), Out = ()>, Global>> { ... }
fn distributive_run_if<M>(
self,
condition: impl Condition<M, ()> + Clone
) -> NodeConfigs<Box<dyn System<In = (), Out = ()>, Global>> { ... }
fn run_if<M>(
self,
condition: impl Condition<M, ()>
) -> NodeConfigs<Box<dyn System<In = (), Out = ()>, Global>> { ... }
fn ambiguous_with<M>(
self,
set: impl IntoSystemSet<M>
) -> NodeConfigs<Box<dyn System<In = (), Out = ()>, Global>> { ... }
fn ambiguous_with_all(
self
) -> NodeConfigs<Box<dyn System<In = (), Out = ()>, Global>> { ... }
fn chain(self) -> NodeConfigs<Box<dyn System<In = (), Out = ()>, Global>> { ... }
}
Expand description
Types that can convert into a SystemConfigs
.
This trait is implemented for “systems” (functions whose arguments all implement
SystemParam
), or tuples thereof.
It is a common entry point for system configurations.
Examples
fn handle_input() {}
fn update_camera() {}
fn update_character() {}
app.add_systems(
Update,
(
handle_input,
(update_camera, update_character).after(handle_input)
)
);
Required Methods§
fn into_configs(self) -> NodeConfigs<Box<dyn System<In = (), Out = ()>, Global>>
fn into_configs(self) -> NodeConfigs<Box<dyn System<In = (), Out = ()>, Global>>
Convert into a SystemConfigs
.
Provided Methods§
fn in_set(
self,
set: impl SystemSet
) -> NodeConfigs<Box<dyn System<In = (), Out = ()>, Global>>
fn in_set( self, set: impl SystemSet ) -> NodeConfigs<Box<dyn System<In = (), Out = ()>, Global>>
Add these systems to the provided set
.
fn before<M>(
self,
set: impl IntoSystemSet<M>
) -> NodeConfigs<Box<dyn System<In = (), Out = ()>, Global>>
fn before<M>( self, set: impl IntoSystemSet<M> ) -> NodeConfigs<Box<dyn System<In = (), Out = ()>, Global>>
Run before all systems in set
.
Note: The given set is not implicitly added to the schedule when this system set is added. It is safe, but no dependencies will be created.
fn after<M>(
self,
set: impl IntoSystemSet<M>
) -> NodeConfigs<Box<dyn System<In = (), Out = ()>, Global>>
fn after<M>( self, set: impl IntoSystemSet<M> ) -> NodeConfigs<Box<dyn System<In = (), Out = ()>, Global>>
Run after all systems in set
.
Note: The given set is not implicitly added to the schedule when this system set is added. It is safe, but no dependencies will be created.
fn distributive_run_if<M>(
self,
condition: impl Condition<M, ()> + Clone
) -> NodeConfigs<Box<dyn System<In = (), Out = ()>, Global>>
fn distributive_run_if<M>( self, condition: impl Condition<M, ()> + Clone ) -> NodeConfigs<Box<dyn System<In = (), Out = ()>, Global>>
Add a run condition to each contained system.
Each system will receive its own clone of the Condition
and will only run
if the Condition
is true.
Each individual condition will be evaluated at most once (per schedule run), right before the corresponding system prepares to run.
This is equivalent to calling run_if
on each individual
system, as shown below:
schedule.add_systems((a, b).distributive_run_if(condition));
schedule.add_systems((a.run_if(condition), b.run_if(condition)));
Note
Because the conditions are evaluated separately for each system, there is no guarantee that all evaluations in a single schedule run will yield the same result. If another system is run inbetween two evaluations it could cause the result of the condition to change.
Use run_if
on a SystemSet
if you want to make sure
that either all or none of the systems are run, or you don’t want to evaluate the run
condition for each contained system separately.
fn run_if<M>(
self,
condition: impl Condition<M, ()>
) -> NodeConfigs<Box<dyn System<In = (), Out = ()>, Global>>
fn run_if<M>( self, condition: impl Condition<M, ()> ) -> NodeConfigs<Box<dyn System<In = (), Out = ()>, Global>>
Run the systems only if the Condition
is true
.
The Condition
will be evaluated at most once (per schedule run),
the first time a system in this set prepares to run.
If this set contains more than one system, calling run_if
is equivalent to adding each
system to a common set and configuring the run condition on that set, as shown below:
Examples
schedule.add_systems((a, b).run_if(condition));
schedule.add_systems((a, b).in_set(C)).configure_sets(C.run_if(condition));
Note
Because the condition will only be evaluated once, there is no guarantee that the condition is upheld after the first system has run. You need to make sure that no other systems that could invalidate the condition are scheduled inbetween the first and last run system.
Use distributive_run_if
if you want the
condition to be evaluated for each individual system, right before one is run.
fn ambiguous_with<M>(
self,
set: impl IntoSystemSet<M>
) -> NodeConfigs<Box<dyn System<In = (), Out = ()>, Global>>
fn ambiguous_with<M>( self, set: impl IntoSystemSet<M> ) -> NodeConfigs<Box<dyn System<In = (), Out = ()>, Global>>
Suppress warnings and errors that would result from these systems having ambiguities
(conflicting access but indeterminate order) with systems in set
.
fn ambiguous_with_all(
self
) -> NodeConfigs<Box<dyn System<In = (), Out = ()>, Global>>
fn ambiguous_with_all( self ) -> NodeConfigs<Box<dyn System<In = (), Out = ()>, Global>>
Suppress warnings and errors that would result from these systems having ambiguities (conflicting access but indeterminate order) with any other system.