pub struct LazyBuilder<'a> {
pub entity: Entity,
pub lazy: &'a LazyUpdate,
}
Expand description
Like EntityBuilder
, but inserts the component
lazily, meaning on maintain
.
If you need those components to exist immediately,
you have to insert them into the storages yourself.
Fields§
§entity: Entity
The entity that we’re inserting components for.
lazy: &'a LazyUpdate
The lazy update reference.
Trait Implementations§
Source§impl<'a> Builder for LazyBuilder<'a>
impl<'a> Builder for LazyBuilder<'a>
Source§fn with<C>(self, component: C) -> Self
fn with<C>(self, component: C) -> Self
Inserts a component using LazyUpdate.
If a component was already associated with the entity, it will overwrite the previous component.
Source§fn build(self) -> Entity
fn build(self) -> Entity
Finishes the building and returns the built entity.
Please note that no component is associated to this
entity until you call World::maintain
.
Source§impl<'a> MarkedBuilder for LazyBuilder<'a>
impl<'a> MarkedBuilder for LazyBuilder<'a>
Source§fn marked<M>(self) -> Selfwhere
M: Marker,
fn marked<M>(self) -> Selfwhere
M: Marker,
Add a Marker
to the entity by fetching the associated allocator.
This will be applied on the next world.maintain()
.
§Examples
use specs::{
prelude::*,
saveload::{MarkedBuilder, SimpleMarker, SimpleMarkerAllocator},
};
struct NetworkSync;
let mut world = World::new();
world.register::<SimpleMarker<NetworkSync>>();
world.insert(SimpleMarkerAllocator::<NetworkSync>::new());
let my_entity = lazy
.create_entity(&entities)
/* .with(Component1) */
.marked::<SimpleMarker<NetworkSync>>()
.build();
§Panics
Panics during world.maintain()
in case there’s no allocator
added to the World
.
Auto Trait Implementations§
impl<'a> Freeze for LazyBuilder<'a>
impl<'a> RefUnwindSafe for LazyBuilder<'a>
impl<'a> Send for LazyBuilder<'a>
impl<'a> Sync for LazyBuilder<'a>
impl<'a> Unpin for LazyBuilder<'a>
impl<'a> UnwindSafe for LazyBuilder<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more