pub struct EntityBuilder { /* private fields */ }
Expand description
Build entities when exact set of components is not known at compile time.
Components can be added to EntityBuilder
at runtime using EntityBuilder::add
or EntityBuilder::with
.
EntityBuilder
then can be used to insert components into entity or spawn a new entity.
Implementations§
Source§impl EntityBuilder
impl EntityBuilder
Sourcepub fn with<T>(self, value: T) -> Self
pub fn with<T>(self, value: T) -> Self
Adds component to the builder. If builder already had this component, old value is replaced.
Sourcepub fn add<T>(&mut self, value: T) -> &mut Self
pub fn add<T>(&mut self, value: T) -> &mut Self
Adds component to the builder. If builder already had this component, old value is replaced.
Sourcepub fn get<T>(&self) -> Option<&T>where
T: 'static,
pub fn get<T>(&self) -> Option<&T>where
T: 'static,
Returns reference to component from builder.
Sourcepub fn get_mut<T>(&mut self) -> Option<&mut T>where
T: 'static,
pub fn get_mut<T>(&mut self) -> Option<&mut T>where
T: 'static,
Returns mutable reference to component from builder.
Sourcepub fn component_types(&self) -> impl Iterator<Item = &ComponentInfo>
pub fn component_types(&self) -> impl Iterator<Item = &ComponentInfo>
Returns iterator over component types in this builder.
Trait Implementations§
Source§impl Debug for EntityBuilder
impl Debug for EntityBuilder
Source§impl Drop for EntityBuilder
impl Drop for EntityBuilder
Source§impl DynamicBundle for EntityBuilder
impl DynamicBundle for EntityBuilder
Source§fn contains_id(&self, ty: TypeId) -> bool
fn contains_id(&self, ty: TypeId) -> bool
Returns true if bundle has specified type id.
Source§fn with_ids<R>(&self, f: impl FnOnce(&[TypeId]) -> R) -> R
fn with_ids<R>(&self, f: impl FnOnce(&[TypeId]) -> R) -> R
Calls provided closure with slice of ids of types that this bundle contains.
Source§impl DynamicComponentBundle for EntityBuilder
impl DynamicComponentBundle for EntityBuilder
Source§fn with_components<R>(&self, f: impl FnOnce(&[ComponentInfo]) -> R) -> R
fn with_components<R>(&self, f: impl FnOnce(&[ComponentInfo]) -> R) -> R
Calls provided closure with slice of component infos of types that this bundle contains.
impl Send for EntityBuilder
Auto Trait Implementations§
impl Freeze for EntityBuilder
impl !RefUnwindSafe for EntityBuilder
impl !Sync for EntityBuilder
impl Unpin for EntityBuilder
impl !UnwindSafe for EntityBuilder
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