logo
pub trait Component: 'static + Send + Sync {
    type Storage: ComponentStorage;
}
Expand description

A component is data associated with an Entity. Each entity can have multiple different types of components, but only one of them per type.

Any type that is Send + Sync + 'static can implement Component using #[derive(Component)].

In order to use foreign types as components, wrap them using a newtype pattern.

use std::time::Duration;
#[derive(Component)]
struct Cooldown(Duration);

Components are added with new entities using Commands::spawn, or to existing entities with EntityCommands::insert, or their World equivalents.

Components can be accessed in systems by using a Query as one of the arguments.

Components can be grouped together into a Bundle.

Required Associated Types

Implementors