world

Macro world 

Source
macro_rules! world {
    (
        // the name of the struct being defined
        $struct_name:ident, // the types of entities which can exist in the world
        $( $entity:ty ),* $(,)? // optional trailing comma
        ;// semi colon separator between lists
        // the traits which are query-able over all types in the world
        $( $trait_name:ident ),* $(,)? // optional trailing comma
    ) => { ... };
}
Expand description
entity_trait_system::world!(MyWorld, Enemy, Player; TestTrait, SecondTestTrait);

This defines two structs:

  • the world called MyWorld. It contains an arena for each entity type, and generates query functions based on the supplied traits.
  • the id type MyWorldArenaId. It’s a stable equivalent to TypeId, which serializes to the name of an entity’s type. It can be used as the key when accessing arenas in a type erased way.