Struct amethyst::ecs::prelude::EntityBuilder [−]
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
entity: Entity
The (already created) entity for which components will be inserted.
world: &'a World
A reference to the World for component insertions.
Methods
impl<'a> EntityBuilder<'a>
impl<'a> EntityBuilder<'a>pub fn with<T>(self, c: T) -> EntityBuilder<'a> where
T: Component,
pub fn with<T>(self, c: T) -> EntityBuilder<'a> where
T: Component, Appends a component and associates it with the entity.
Panics
Panics if the component hasn't been register()ed in the
World.
pub fn build(self) -> Entity
pub fn build(self) -> EntityFinishes the building and returns the entity.
Trait Implementations
impl<'a> Drop for EntityBuilder<'a>
impl<'a> Drop for EntityBuilder<'a>Auto Trait Implementations
impl<'a> Send for EntityBuilder<'a>
impl<'a> Send for EntityBuilder<'a>impl<'a> Sync for EntityBuilder<'a>
impl<'a> Sync for EntityBuilder<'a>