Derive Macro Entity

Source
#[derive(Entity)]
{
    // Attributes available to this derive:
    #[container]
    #[random_state]
}
Expand description

Impelments Entity for the type.

Actually, you don’t have to define entity type explicitly, but by doing so, the crate becomes to be able to provide easy-to-use functions for you.

You can designate which container type you use as well by attributes container and random_state.

container means which container type you use for the entity. You can use your own types or choose one of built-in types shown below.

random_state means a state to make a hasher. std::hash::RandomState is default.

§Examples

use my_ecs::prelude::*;

#[derive(Component)]
struct Ca;

#[derive(Entity)]
struct Ea {
    a: Ca,
}

// Or, you can customize entity container.
#[derive(Entity)]
#[container(ChunkSparseSet)]
#[random_state(std::hash::RandomState)]
struct Eb {
    a: Ca,
}