Trait specs::saveload::MarkedBuilder
source · Expand description
A common trait for EntityBuilder
and LazyBuilder
with a marker function, allowing either to be used.
Required Methods
sourcefn marked<M: Marker>(self) -> Self
fn marked<M: Marker>(self) -> Self
Add a Marker
to the entity by fetching the associated allocator.
Examples
use specs::prelude::*;
use specs::saveload::{MarkedBuilder, U64Marker, U64MarkerAllocator};
fn MarkEntity<M: Builder + MarkedBuilder>(markable: M) -> Entity {
markable
/* .with(Component1) */
.marked::<U64Marker>()
.build()
}
let mut world = World::new();
world.register::<U64Marker>();
world.add_resource(U64MarkerAllocator::new());
MarkEntity(world.create_entity());