Struct specs::world::EntityBuilder[][src]

#[must_use = "Please call .build() on this to finish building it."]
pub struct EntityBuilder<'a> { pub entity: Entity, pub world: &'a World, // some fields omitted }

The entity builder, allowing to build an entity together with its components.

Examples

use specs::prelude::*;
use specs::storage::HashMapStorage;

struct Health(f32);

impl Component for Health {
    type Storage = HashMapStorage<Self>;
}

struct Pos {
    x: f32,
    y: f32,
}

impl Component for Pos {
    type Storage = DenseVecStorage<Self>;
}

let mut world = World::new();
world.register::<Health>();
world.register::<Pos>();

let entity = world
    .create_entity() // This call returns `EntityBuilder`
    .with(Health(4.0))
    .with(Pos { x: 1.0, y: 3.0 })
    .build(); // Returns the `Entity`

Fields

The (already created) entity for which components will be inserted.

A reference to the World for component insertions.

Trait Implementations

impl<'a> MarkedBuilder for EntityBuilder<'a>
[src]

Add a Marker to the entity by fetching the associated allocator. Read more

impl<'a> Builder for EntityBuilder<'a>
[src]

Appends a component and associates it with the entity. Read more

Finishes the building and returns the entity. As opposed to LazyBuilder, the components are available immediately.

impl<'a> Drop for EntityBuilder<'a>
[src]

Executes the destructor for this type. Read more

Auto Trait Implementations

impl<'a> Send for EntityBuilder<'a>

impl<'a> Sync for EntityBuilder<'a>