Struct specs::world::EntityResBuilder[][src]

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

An entity builder from EntitiesRes. Allows building an entity with its components if you have mutable access to the component storages.

Fields

entity: Entity

The entity being built

entities: &'a EntitiesRes

The active borrow to EntitiesRes, used to delete the entity if the builder is dropped without called build().

Implementations

Add a Marker to the entity with the associated allocator, and component storage.

Examples

use specs::{
    prelude::*,
    saveload::{SimpleMarker, SimpleMarkerAllocator},
};

struct NetworkSync;

let mut world = World::new();
world.register::<SimpleMarker<NetworkSync>>();
world.insert(SimpleMarkerAllocator::<NetworkSync>::new());

let mut storage = world.write_storage::<SimpleMarker<NetworkSync>>();
let mut alloc = world.write_resource::<SimpleMarkerAllocator<NetworkSync>>();

let entities = world.entities();
entities
    .build_entity()
    /* .with(Component1) */
    .marked(&mut storage, &mut alloc)
    .build();

Appends a component and associates it with the entity.

Finishes the building and returns the entity.

Trait Implementations

Executes the destructor for this type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The alignment of pointer.

The type for initializers.

Initializes a with the given initializer. Read more

Dereferences the given pointer. Read more

Mutably dereferences the given pointer. Read more

Drops the object pointed to by the given pointer. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.