Trait shipyard::AddComponent

source ·
pub trait AddComponent {
    type Component;

    // Required method
    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§

source

fn add_component_unchecked( &mut self, entity: EntityId, component: Self::Component, )

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§

source§

impl AddComponent for ()

source§

impl<ViewA: AddComponent> AddComponent for (ViewA,)

§

type Component = (<ViewA as AddComponent>::Component,)

source§

fn add_component_unchecked( &mut self, entity: EntityId, component: Self::Component, )

source§

impl<ViewA: AddComponent, ViewB: AddComponent> AddComponent for (ViewA, ViewB)

§

type Component = (<ViewA as AddComponent>::Component, <ViewB as AddComponent>::Component)

source§

fn add_component_unchecked( &mut self, entity: EntityId, component: Self::Component, )

source§

impl<ViewA: AddComponent, ViewB: AddComponent, ViewC: AddComponent> AddComponent for (ViewA, ViewB, ViewC)

§

type Component = (<ViewA as AddComponent>::Component, <ViewB as AddComponent>::Component, <ViewC as AddComponent>::Component)

source§

fn add_component_unchecked( &mut self, entity: EntityId, component: Self::Component, )

source§

impl<ViewA: AddComponent, ViewB: AddComponent, ViewC: AddComponent, ViewD: AddComponent> AddComponent for (ViewA, ViewB, ViewC, ViewD)

§

type Component = (<ViewA as AddComponent>::Component, <ViewB as AddComponent>::Component, <ViewC as AddComponent>::Component, <ViewD as AddComponent>::Component)

source§

fn add_component_unchecked( &mut self, entity: EntityId, component: Self::Component, )

source§

impl<ViewA: AddComponent, ViewB: AddComponent, ViewC: AddComponent, ViewD: AddComponent, ViewE: AddComponent> AddComponent for (ViewA, ViewB, ViewC, ViewD, ViewE)

§

type Component = (<ViewA as AddComponent>::Component, <ViewB as AddComponent>::Component, <ViewC as AddComponent>::Component, <ViewD as AddComponent>::Component, <ViewE as AddComponent>::Component)

source§

fn add_component_unchecked( &mut self, entity: EntityId, component: Self::Component, )

source§

impl<ViewA: AddComponent, ViewB: AddComponent, ViewC: AddComponent, ViewD: AddComponent, ViewE: AddComponent, ViewF: AddComponent> AddComponent for (ViewA, ViewB, ViewC, ViewD, ViewE, ViewF)

§

type Component = (<ViewA as AddComponent>::Component, <ViewB as AddComponent>::Component, <ViewC as AddComponent>::Component, <ViewD as AddComponent>::Component, <ViewE as AddComponent>::Component, <ViewF as AddComponent>::Component)

source§

fn add_component_unchecked( &mut self, entity: EntityId, component: Self::Component, )

source§

impl<ViewA: AddComponent, ViewB: AddComponent, ViewC: AddComponent, ViewD: AddComponent, ViewE: AddComponent, ViewF: AddComponent, ViewG: AddComponent> AddComponent for (ViewA, ViewB, ViewC, ViewD, ViewE, ViewF, ViewG)

§

type Component = (<ViewA as AddComponent>::Component, <ViewB as AddComponent>::Component, <ViewC as AddComponent>::Component, <ViewD as AddComponent>::Component, <ViewE as AddComponent>::Component, <ViewF as AddComponent>::Component, <ViewG as AddComponent>::Component)

source§

fn add_component_unchecked( &mut self, entity: EntityId, component: Self::Component, )

source§

impl<ViewA: AddComponent, ViewB: AddComponent, ViewC: AddComponent, ViewD: AddComponent, ViewE: AddComponent, ViewF: AddComponent, ViewG: AddComponent, ViewH: AddComponent> AddComponent for (ViewA, ViewB, ViewC, ViewD, ViewE, ViewF, ViewG, ViewH)

§

type Component = (<ViewA as AddComponent>::Component, <ViewB as AddComponent>::Component, <ViewC as AddComponent>::Component, <ViewD as AddComponent>::Component, <ViewE as AddComponent>::Component, <ViewF as AddComponent>::Component, <ViewG as AddComponent>::Component, <ViewH as AddComponent>::Component)

source§

fn add_component_unchecked( &mut self, entity: EntityId, component: Self::Component, )

source§

impl<ViewA: AddComponent, ViewB: AddComponent, ViewC: AddComponent, ViewD: AddComponent, ViewE: AddComponent, ViewF: AddComponent, ViewG: AddComponent, ViewH: AddComponent, ViewI: AddComponent> AddComponent for (ViewA, ViewB, ViewC, ViewD, ViewE, ViewF, ViewG, ViewH, ViewI)

§

type Component = (<ViewA as AddComponent>::Component, <ViewB as AddComponent>::Component, <ViewC as AddComponent>::Component, <ViewD as AddComponent>::Component, <ViewE as AddComponent>::Component, <ViewF as AddComponent>::Component, <ViewG as AddComponent>::Component, <ViewH as AddComponent>::Component, <ViewI as AddComponent>::Component)

source§

fn add_component_unchecked( &mut self, entity: EntityId, component: Self::Component, )

source§

impl<ViewA: AddComponent, ViewB: AddComponent, ViewC: AddComponent, ViewD: AddComponent, ViewE: AddComponent, ViewF: AddComponent, ViewG: AddComponent, ViewH: AddComponent, ViewI: AddComponent, ViewJ: AddComponent> AddComponent for (ViewA, ViewB, ViewC, ViewD, ViewE, ViewF, ViewG, ViewH, ViewI, ViewJ)

§

type Component = (<ViewA as AddComponent>::Component, <ViewB as AddComponent>::Component, <ViewC as AddComponent>::Component, <ViewD as AddComponent>::Component, <ViewE as AddComponent>::Component, <ViewF as AddComponent>::Component, <ViewG as AddComponent>::Component, <ViewH as AddComponent>::Component, <ViewI as AddComponent>::Component, <ViewJ as AddComponent>::Component)

source§

fn add_component_unchecked( &mut self, entity: EntityId, component: Self::Component, )

Implementors§

source§

impl<T: Component> AddComponent for &mut ViewMut<'_, T>

§

type Component = T

source§

impl<T: Component> AddComponent for ViewMut<'_, T>

§

type Component = T