[][src]Struct bevy_hecs::EntityBuilder

pub struct EntityBuilder { /* fields omitted */ }

Helper for incrementally constructing a bundle of components with dynamic component types

Prefer reusing the same builder over creating new ones repeatedly.

let mut world = World::new();
let mut builder = EntityBuilder::new();
builder.add(123).add("abc");
let e = world.spawn(builder.build()); // builder can now be reused
assert_eq!(*world.get::<i32>(e).unwrap(), 123);
assert_eq!(*world.get::<&str>(e).unwrap(), "abc");

Implementations

impl EntityBuilder[src]

pub fn new() -> Self[src]

Create a builder representing an entity with no components

pub fn add<T: Component>(&mut self, component: T) -> &mut Self[src]

Add component to the entity

pub fn build(&mut self) -> BuiltEntity<'_>[src]

Construct a Bundle suitable for spawning

pub fn clear(&mut self)[src]

Drop previously added components

The builder is cleared implicitly when an entity is built, so this doesn't usually need to be called.

Trait Implementations

impl Default for EntityBuilder[src]

impl Drop for EntityBuilder[src]

impl Send for EntityBuilder[src]

impl Sync for EntityBuilder[src]

Auto Trait Implementations

Blanket Implementations

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

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

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

impl<T> From<T> for T[src]

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

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

type Error = Infallible

The type returned in the event of a conversion error.

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

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.