Trait System

Source
pub trait System: 'static + Sized {
    // Provided methods
    fn prestep(&mut self, engine: &EntitiesAndComponentsThreadSafe<'_>) { ... }
    fn implements_prestep(&self) -> bool { ... }
    fn single_entity_step(&self, single_entity: &mut SingleMutEntity<'_>) { ... }
    fn implements_single_entity_step(&self) -> bool { ... }
    fn run(&mut self, engine: &mut EntitiesAndComponents) { ... }
    fn as_any(&self) -> &dyn Any { ... }
    fn as_any_mut(&mut self) -> &mut dyn Any { ... }
}
Expand description

Systems access and change components on objects Be careful to implement get_allow_entity_based_multithreading as true if you want to use the single_entity_step function If you don’t it will still work but, it will be slower (in most cases)

Provided Methods§

Source

fn prestep(&mut self, engine: &EntitiesAndComponentsThreadSafe<'_>)

This function can collect data that will be used in the single_entity_step function This allows both functions to be called in parallel, without a data race If you implement this function, make sure to implement implements_prestep as true

Source

fn implements_prestep(&self) -> bool

Should just return true or false based on whether or not the system implements the prestep function

Source

fn single_entity_step(&self, single_entity: &mut SingleMutEntity<'_>)

If you implement this function, it will be called for each entity in parallel, but make sure to implement get_allow_single_entity_step as true

Source

fn implements_single_entity_step(&self) -> bool

Should just return true or false based on whether or not the system implements the single_entity_step function

Source

fn run(&mut self, engine: &mut EntitiesAndComponents)

This function is called after the single_entity_step function is called for all entities

Source

fn as_any(&self) -> &dyn Any

This function is used to downcast the system to an Any trait object Should be automatically implemented

Source

fn as_any_mut(&mut self) -> &mut dyn Any

This function is used to downcast the system to an Any trait object Should be automatically implemented

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§