Trait sai::ComponentRegistry[][src]

pub trait ComponentRegistry {
    fn get(type_id: TypeId) -> Option<ComponentMeta<Box<dyn Component>>>;
fn all() -> Vec<TypeId>;
fn new() -> Self; }
Expand description

ComponentRegistry is a data structure for system to find a meta information for component. It’s required for a system to have a ComponentRegistry.

Normaly, you don’t need to manually implement this trait.

To define a component registry, you just need to specify the name and a list of Component identifiers.

use sai::{Component};

#[derive(Component)]
struct A {};
#[derive(Component)]
struct B {};

component_registry!(ExampleRegistry, [
    A, B
]);

Note that A, B above are not values, they are the identifiers.

In big project, uou can also composite multiple component registires into one. Check out here.

Required methods

Getting a

All the TypeIds that’s in this registry

Implementors