Crate magma_ecs

source
Expand description

This crate provides the Entity-Component-System of the Magma3D-Engine.

The crate provides a World struct with Resources and Entities. An entity is just an index into the component storage. A resource is like a global component, independant from the Entities.

Example for creating and setting up a World:

use magma_ecs::World;

let world = World::new();
// register a component type
world.register_component::<u32>();
// add a resource
world.add_resource(10_u32);

// create an entity with registered component
// It is recommended to free read/write locks as quickly as possible. Use scopes to do that.
{
    let mut entities = world.entities_write();
    entities.create_entity().with_component(20_u32).unwrap();
}

Modules§

Structs§

  • The World struct holds all the data of our world.