Struct legion::systems::SystemBuilder[][src]

pub struct SystemBuilder<Q = (), R = ()> { /* fields omitted */ }
Expand description

A low level builder for constructing systems.

#[derive(Copy, Clone, Debug, PartialEq)]
struct Static;
#[derive(Debug)]
struct TestResource {}

let mut system_one = SystemBuilder::new("TestSystem")
    .read_resource::<TestResource>()
    .with_query(
        <(Entity, Read<Position>, Read<Model>)>::query()
            .filter(!component::<Static>() | maybe_changed::<Position>()),
    )
    .build(
        move |commands, world, resource, queries| {
            for (entity, pos, model) in queries.iter_mut(world) {}
        },
    );

Implementations

Create a new system builder to construct a new system.

Please note, the name argument for this method is just for debugging and visualization purposes and is not logically used anywhere.

Provides a name to the system being built.

Defines a query to provide this system for its execution. Multiple queries can be provided, and queries are cached internally for efficiency for filtering and archetype ID handling.

It is best practice to define your queries here, to allow for the caching to take place. These queries are then provided to the executing closure as a tuple of queries.

Flag this resource type as being read by this system.

This will inform the dispatcher to not allow any writes access to this resource while this system is running. Parralel reads still occur during execution.

Flag this resource type as being written by this system.

This will inform the dispatcher to not allow any parallel access to this resource while this system is running.

This performs a soft resource block on the component for writing. The dispatcher will generally handle dispatching read and writes on components based on archetype, allowing for more granular access and more parallelization of systems.

Using this method will mark the entire component as read by this system, blocking writing systems from accessing any archetypes which contain this component for the duration of its execution.

This type of access with SubWorld is provided for cases where sparse component access is required and searching entire query spaces for entities is inefficient.

This performs a exclusive resource block on the component for writing. The dispatcher will generally handle dispatching read and writes on components based on archetype, allowing for more granular access and more parallelization of systems.

Using this method will mark the entire component as written by this system, blocking other systems from accessing any archetypes which contain this component for the duration of its execution.

This type of access with SubWorld is provided for cases where sparse component access is required and searching entire query spaces for entities is inefficient.

Builds a system which is not Schedulable, as it is not thread safe (!Send and !Sync), but still implements all the calling infrastructure of the Runnable trait. This provides a way for legion consumers to leverage the System construction and type-handling of this build for thread local systems which cannot leave the main initializing thread.

Trait Implementations

Returns the “default value” for a type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Convert 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. Read more

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait. Read more

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s. Read more

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s. Read more

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.