Module bevy::ecs::system [−]
Expand description
Tools for controlling behavior in an ECS application.
Systems define how an ECS based application behaves. They have to be registered to a
SystemStage
to be able to run. A system is usually
written as a normal function that will be automatically converted into a system.
System functions can have parameters, through which one can query and mutate Bevy ECS state.
Only types that implement SystemParam
can be used, automatically fetching data from
the World
.
System functions often look like this:
fn update_score_system(
mut query: Query<(&Player, &mut Score)>,
mut round: ResMut<Round>,
) {
for (player, mut score) in query.iter_mut() {
if player.alive {
score.0 += round.0;
}
}
round.0 += 1;
}
System ordering
While the execution of systems is usually parallel and not deterministic, there are two ways to determine a certain degree of execution order:
- System Stages: They determine hard execution synchronization boundaries inside of which systems run in parallel by default.
- Labeling: First, systems are labeled upon creation by calling
.label()
. Then, methods such as.before()
and.after()
are appended to systems to determine execution order in respect to other systems.
System parameter list
Following is the complete list of accepted types as system parameters:
Query
Res
andOption<Res>
ResMut
andOption<ResMut>
Commands
Local
EventReader
EventWriter
NonSend
andOption<NonSend>
NonSendMut
andOption<NonSendMut>
RemovedComponents
SystemChangeTick
Archetypes
(Provides Archetype metadata)Bundles
(Provides Bundles metadata)Components
(Provides Components metadata)Entities
(Provides Entities metadata)- All tuples between 1 to 16 elements where each element implements
SystemParam
()
(unit primitive type)
Modules
Structs
The SystemParamState
of Bundles
.
A System
that chains two systems together, creating a new system that routes the output of
the first system into the input of the second system, yielding the output of the second system.
A queue of Command
s
A list of commands that modify a World
, running at the end of the stage where they
have been invoked.
A list of commands that will be run to modify an entity.
The System
counter part of an ordinary function.
Wrapper type to mark a SystemParam
as an input.
A system local SystemParam
.
The SystemParamState
of Local<T>
.
Unique borrow of a non-Send
resource.
The SystemParamState
of Option<ResMut<T>>
.
See: ResMut<T>
The SystemParamState
of Option<Res<T>>
.
See: Res<T>
A SystemParam
that grants access to the entities that had their T
Component
removed.
Shared borrow of a resource.
Unique mutable borrow of a resource.
The SystemParamState
of ResMut<T>
.
The SystemParamState
of Res<T>
.
The metadata of a System
.
Holds on to persistent state required to drive SystemParam
for a System
.
Enums
An error that occurs when evaluating a Query
as a single expected resulted via
Query::single
or Query::single_mut
.
Traits
Provides my_system.config(...)
API.
An extension trait providing the IntoChainSystem::chain
method for convenient System
chaining.
Conversion trait to turn something into a System
.
A SystemParamFetch
that only reads a given World
.
A trait for defining systems with a SystemParam
associated type.
A parameter that can be used in a System
.
A trait implemented for all functions that can be used as System
s.
The state of a SystemParam
.
Type Definitions
A convenience type alias for a boxed System
trait object.
Derive Macros
Implement SystemParam
to use a struct as a parameter in a system