Struct shipyard::EntitiesViewMut[][src]

pub struct EntitiesViewMut<'a> { /* fields omitted */ }
Expand description

Exclusive view over Entities storage.

Methods from Deref<Target = Entities>

Returns true if entity matches a living entity.

Adds component to entity, multiple components can be added at the same time using a tuple.
Entities is only borrowed immutably.

Example

use shipyard::{World, EntitiesViewMut, EntitiesView, ViewMut};

let world = World::new();

let entity = world.borrow::<EntitiesViewMut>().add_entity((), ());

world.run(|entities: EntitiesView, mut u32s: ViewMut<u32>| {
    entities.try_add_component(&mut u32s, 0, entity).unwrap();
});

Adds component to entity, multiple components can be added at the same time using a tuple.
Entities is only borrowed immutably.
Unwraps errors.

Example

use shipyard::{World, EntitiesViewMut, EntitiesView, ViewMut};

let world = World::new();

let entity = world.borrow::<EntitiesViewMut>().add_entity((), ());

world.run(|entities: EntitiesView, mut u32s: ViewMut<u32>| {
    entities.add_component(&mut u32s, 0, entity);
});

Delete an entity, returns true if the entity was alive.
If the entity has components, they will not be deleted and still be accessible using this id.

Stores component in a new entity, the EntityId to this entity is returned.
Multiple components can be added at the same time using a tuple.

Example:

use shipyard::{EntitiesViewMut, Get, ViewMut, World};

let world = World::new();

world.run(
    |mut entities: EntitiesViewMut, mut usizes: ViewMut<usize>, mut u32s: ViewMut<u32>| {
        let entity = entities.add_entity((&mut usizes, &mut u32s), (0, 1));
        assert_eq!(usizes.try_get(entity), Ok(&0));
        assert_eq!(u32s.try_get(entity), Ok(&1));
    },
);

Trait Implementations

The resulting type after dereferencing.

Dereferences the value.

Mutably dereferences the value.

The type returned in the event of a conversion error.

Performs the conversion.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The alignment of pointer.

The type for initializers.

Initializes a with the given initializer. Read more

Dereferences the given pointer. Read more

Mutably dereferences the given pointer. Read more

Drops the object pointed to by the given pointer. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.