Struct shipyard::EntitiesView [−][src]
pub struct EntitiesView<'a> { /* fields omitted */ }
Expand description
Shared view over Entities
storage.
Methods from Deref<Target = Entities>
Returns true if entity
matches a living entity.
pub fn try_add_component<C, S: AddComponent<C>>(
&self,
storages: S,
component: C,
entity: EntityId
) -> Result<(), AddComponent>
pub fn try_add_component<C, S: AddComponent<C>>(
&self,
storages: S,
component: C,
entity: EntityId
) -> Result<(), AddComponent>
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();
});
pub fn add_component<C, S: AddComponent<C>>(
&self,
storages: S,
component: C,
entity: EntityId
)
pub fn add_component<C, S: AddComponent<C>>(
&self,
storages: S,
component: C,
entity: EntityId
)
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);
});
Trait Implementations
type Error = GetStorage
type Error = GetStorage
The type returned in the event of a conversion error.
Performs the conversion.