pub struct EntityBuilder<'a, TS = (), CS = ()> { /* private fields */ }
Expand description
A builder type which can be retrieved from the command buffer. This is the ideal use case for
inserted complex entities with multiple components and tags from a command buffer. Although
add_component
will perform a new move operation on every addition, this allows the construction
of a single insert
command for an entity, but without using the actual insert
command
provided by the CommandBuffer
§Examples
Inserting an entity using the EntityBuilder
:
let mut command_buffer = CommandBuffer::new(&world);
command_buffer.start_entity()
.with_component(Position(123.0))
.with_component(Rotation(456.0))
.build();
command_buffer.write(&mut world);
Implementations§
Source§impl<'a, TS, CS> EntityBuilder<'a, TS, CS>
impl<'a, TS, CS> EntityBuilder<'a, TS, CS>
Sourcepub fn with_component<C: Component>(
self,
component: C,
) -> EntityBuilder<'a, TS, <CS as ConsAppend<C>>::Output>
pub fn with_component<C: Component>( self, component: C, ) -> EntityBuilder<'a, TS, <CS as ConsAppend<C>>::Output>
Adds a component to this builder, returning a new builder type containing that component type and its data.
Sourcepub fn with_tag<T: Tag>(
self,
tag: T,
) -> EntityBuilder<'a, <TS as ConsAppend<T>>::Output, CS>
pub fn with_tag<T: Tag>( self, tag: T, ) -> EntityBuilder<'a, <TS as ConsAppend<T>>::Output, CS>
Adds a tag to this builder, returning a new builder type containing that component type and its data.
Sourcepub fn build(self) -> Entitywhere
<TS as ConsFlatten>::Output: TagSet + TagLayout + for<'b> Filter<ChunksetFilterData<'b>>,
ComponentTupleSet<<CS as ConsFlatten>::Output, Once<<CS as ConsFlatten>::Output>>: ComponentSource,
pub fn build(self) -> Entitywhere
<TS as ConsFlatten>::Output: TagSet + TagLayout + for<'b> Filter<ChunksetFilterData<'b>>,
ComponentTupleSet<<CS as ConsFlatten>::Output, Once<<CS as ConsFlatten>::Output>>: ComponentSource,
Finalizes this builder type and submits it to the CommandBuffer
.
Auto Trait Implementations§
impl<'a, TS, CS> Freeze for EntityBuilder<'a, TS, CS>
impl<'a, TS = (), CS = ()> !RefUnwindSafe for EntityBuilder<'a, TS, CS>
impl<'a, TS, CS> Send for EntityBuilder<'a, TS, CS>
impl<'a, TS, CS> Sync for EntityBuilder<'a, TS, CS>
impl<'a, TS, CS> Unpin for EntityBuilder<'a, TS, CS>
impl<'a, TS = (), CS = ()> !UnwindSafe for EntityBuilder<'a, TS, CS>
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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