pub trait AddComponent {
    type Component;

    fn add_component_unchecked(
        &mut self,
        entity: EntityId,
        component: Self::Component
    ); }
Expand description

Defines how components are added to an existing entity.

Required Associated Types

Required Methods

Adds component to entity, multiple components can be added at the same time using a tuple.
This function does not check entity is alive. It’s possible to add components to removed entities.
Use Entities::add_component if you’re unsure.

Example
use shipyard::{AddComponent, Component, EntitiesViewMut, ViewMut, World};

#[derive(Component)]
struct U32(u32);

let world = World::new();

let (mut entities, mut u32s) = world.borrow::<(EntitiesViewMut, ViewMut<U32>)>().unwrap();
let entity = entities.add_entity((), ());

u32s.add_component_unchecked(entity, U32(0));

Implementations on Foreign Types

Implementors