[][src]Struct pyro::World

pub struct World<S = SoaStorage> { /* fields omitted */ }

World is the heart of this library. It owns all the Components and Storages. It also manages entities and allows Components to be safely queried.

Methods

impl<S> World<S>
[src]

Creates an empty World.

impl<S> World<S> where
    S: Storage
[src]

Creates an Iterator over every Entity inside World. The entities are not ordered.

Uses Query and Matcher to access the correct components. Read will borrow the component immutable while Write will borrow the component mutable.

This example is not tested
fn update(world: &mut World) {
   world
       .matcher::<All<(Write<Position>, Read<Velocity>)>>()
       .for_each(|(p, v)| {
           p.x += v.dx;
           p.y += v.dy;
       });
}

Same as World::matcher but also returns the corresponding Entity.

This example is not tested
fn update(world: &mut World) {
   world
       .matcher_with_entities::<All<(Write<Position>, Read<Velocity>)>>()
       .for_each(|(entity, (p, v))| {
           p.x += v.dx;
           p.y += v.dy;
       });
}

impl<S> World<S> where
    S: Storage + RegisterComponent
[src]

Appends the components and also creates the necessary Entitys behind the scenes. If you only want to append a single set of components then you can do

This example is not tested
world.append_components(Some((a, b, c)));

Compares the version of the entity with the version in World and returns true if they match. Because version wraps around this is not a hard guarantee.

Returns true if the entity owns the requested component.

Retrieves a component for a specific Entity.

Same as World::get_component but mutable.

Removes the specified entities from World. Those entities are now considered invalid, which can be checked with World::is_entity_valid.

Trait Implementations

impl<S> Default for World<S>
[src]

Auto Trait Implementations

impl<S> Send for World<S> where
    S: Send

impl<S> Sync for World<S> where
    S: Sync

Blanket Implementations

impl<C> Component for C where
    C: 'static + Send
[src]

impl<T> From for T
[src]

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom for T where
    T: From<U>, 
[src]

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Downcast for T where
    T: Any
[src]

impl<T> Erased for T