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:

Re-exports

pub use crate::change_detection::NonSendMut;
pub use crate::change_detection::ResMut;

Modules

Structs

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 Commands

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.

Shared borrow of a non-Send resource.

Provides scoped access to components in a World.

A SystemParam that grants access to the entities that had their T Component removed.

Shared borrow of a resource.

A helper for using system parameters in generic contexts

The metadata of a System.

Holds on to persistent state required to drive SystemParam for a System.

A SystemLabel that was automatically generated for a system on the basis of its TypeId.

Enums

An error that occurs when retrieving a specific Entity’s component from a Query

An error that occurs when evaluating a Query as a single expected resulted via Query::single or Query::single_mut.

Traits

Used to implicitly convert systems to their default labels. For example, it will convert “system functions” to their SystemTypeIdLabel.

A World mutation.

An extension trait providing the IntoChainSystem::chain method for convenient System chaining.

Conversion trait to turn something into a System.

An ECS system that can be added to a Schedule

A parameter that can be used in a System.

A trait implemented for all functions that can be used as Systems.

Functions

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