#[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.
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()
.with(Health(4.0))
.with(Pos { x: 1.0, y: 3.0 })
.build();
The (already created) entity for which components will be inserted.
A reference to the World
for component insertions.
Add a Marker
to the entity by fetching the associated allocator. Read more
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.
Executes the destructor for this type. Read more