Trait bevy::ecs::system::System

pub trait System: Send + Sync + 'static {
    type In;
    type Out;

Show 15 methods // Required methods fn name(&self) -> Cow<'static, str>; fn type_id(&self) -> TypeId; fn component_access(&self) -> &Access<ComponentId>; fn archetype_component_access(&self) -> &Access<ArchetypeComponentId>; fn is_send(&self) -> bool; fn is_exclusive(&self) -> bool; unsafe fn run_unsafe(&mut self, input: Self::In, world: &World) -> Self::Out; fn apply_buffers(&mut self, world: &mut World); fn initialize(&mut self, _world: &mut World); fn update_archetype_component_access(&mut self, world: &World); fn check_change_tick(&mut self, change_tick: u32); fn get_last_change_tick(&self) -> u32; fn set_last_change_tick(&mut self, last_change_tick: u32); // Provided methods fn run(&mut self, input: Self::In, world: &mut World) -> Self::Out { ... } fn default_system_sets( &self ) -> Vec<Box<dyn SystemSet + 'static, Global>, Global> { ... }
}
Expand description

An ECS system that can be added to a Schedule

Systems are functions with all arguments implementing SystemParam.

Systems are added to an application using App::add_system(my_system) or similar methods, and will generally run once per pass of the main loop.

Systems are executed in parallel, in opportunistic order; data access is managed automatically. It’s possible to specify explicit execution order between specific systems, see IntoSystemConfig.

Required Associated Types§

type In

The system’s input. See In for FunctionSystems.

type Out

The system’s output.

Required Methods§

fn name(&self) -> Cow<'static, str>

Returns the system’s name.

fn type_id(&self) -> TypeId

Returns the TypeId of the underlying system type.

fn component_access(&self) -> &Access<ComponentId>

Returns the system’s component Access.

fn archetype_component_access(&self) -> &Access<ArchetypeComponentId>

Returns the system’s archetype component Access.

fn is_send(&self) -> bool

Returns true if the system is Send.

fn is_exclusive(&self) -> bool

Returns true if the system must be run exclusively.

unsafe fn run_unsafe(&mut self, input: Self::In, world: &World) -> Self::Out

Runs the system with the given input in the world. Unlike System::run, this function takes a shared reference to World and may therefore break Rust’s aliasing rules, making it unsafe to call.

Safety

This might access world and resources in an unsafe manner. This should only be called in one of the following contexts: 1. This system is the only system running on the given world across all threads. 2. This system only runs in parallel with other systems that do not conflict with the System::archetype_component_access().

fn apply_buffers(&mut self, world: &mut World)

fn initialize(&mut self, _world: &mut World)

Initialize the system.

fn update_archetype_component_access(&mut self, world: &World)

Update the system’s archetype component Access.

fn check_change_tick(&mut self, change_tick: u32)

fn get_last_change_tick(&self) -> u32

Gets the system’s last change tick

fn set_last_change_tick(&mut self, last_change_tick: u32)

Sets the system’s last change tick

Warning

This is a complex and error-prone operation, that can have unexpected consequences on any system relying on this code. However, it can be an essential escape hatch when, for example, you are trying to synchronize representations using change detection and need to avoid infinite recursion.

Provided Methods§

fn run(&mut self, input: Self::In, world: &mut World) -> Self::Out

Runs the system with the given input in the world.

fn default_system_sets( &self ) -> Vec<Box<dyn SystemSet + 'static, Global>, Global>

Returns the system’s default system sets.

Trait Implementations§

§

impl Debug for dyn System<Out = (), In = ()> + 'static

§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
§

impl IntoSystemConfig<(), SystemConfig> for Box<dyn System<Out = (), In = ()> + 'static, Global>

§

fn in_set(self, set: impl FreeSystemSet) -> Config

Add to set membership.
§

fn in_base_set(self, set: impl BaseSystemSet) -> Config

Add to the provided “base” set. For more information on base sets, see SystemSet::is_base.
§

fn no_default_base_set(self) -> Config

Don’t add this system to the schedules’s default set.
§

fn before<M>(self, set: impl IntoSystemSet<M>) -> Config

Run before all systems in set.
§

fn after<M>(self, set: impl IntoSystemSet<M>) -> Config

Run after all systems in set.
§

fn run_if<M>(self, condition: impl Condition<M>) -> Config

Run only if the Condition is true. Read more
§

fn ambiguous_with<M>(self, set: impl IntoSystemSet<M>) -> Config

Suppress warnings and errors that would result from this system having ambiguities (conflicting access but indeterminate order) with systems in set.
§

fn ambiguous_with_all(self) -> Config

Suppress warnings and errors that would result from this system having ambiguities (conflicting access but indeterminate order) with any other system.

Implementors§

§

impl<A, B, Func> System for CombinatorSystem<Func, A, B>where Func: Combine<A, B> + 'static, A: System, B: System,

§

type In = <Func as Combine<A, B>>::In

§

type Out = <Func as Combine<A, B>>::Out

§

impl<Marker, F> System for ExclusiveFunctionSystem<Marker, F>where Marker: 'static, F: ExclusiveSystemParamFunction<Marker>,

§

type In = <F as ExclusiveSystemParamFunction<Marker>>::In

§

type Out = <F as ExclusiveSystemParamFunction<Marker>>::Out

§

impl<Marker, F> System for FunctionSystem<Marker, F>where Marker: 'static, F: SystemParamFunction<Marker>,

§

type In = <F as SystemParamFunction<Marker>>::In

§

type Out = <F as SystemParamFunction<Marker>>::Out