pub struct AsyncEntity { /* private fields */ }
Expand description
Represents an Entity
that can be manipulated asynchronously.
The easiest way to get an AsyncEntity
is with AsyncWorld::spawn_empty()
.
Dropping the AsyncEntity
WILL NOT despawn the corresponding entity in the synchronous world.
Use AsyncEntity::despawn
to despawn an entity asynchronously.
Implementations§
Source§impl AsyncEntity
impl AsyncEntity
Sourcepub fn sender(&self) -> CommandQueueSender
pub fn sender(&self) -> CommandQueueSender
Returns a copy of the underlying CommandQueueSender
.
Sourcepub async fn insert<B: Bundle>(&self, bundle: B)
pub async fn insert<B: Bundle>(&self, bundle: B)
Adds a Bundle
of components to the entity. This will overwrite any previous value(s) of
the same component type.
Sourcepub async fn start_waiting_for<C: Component + Clone>(&self) -> AsyncComponent<C>
pub async fn start_waiting_for<C: Component + Clone>(&self) -> AsyncComponent<C>
Start waiting for the Component
of a given type. Returns an AsyncComponent
which can be further
waited to receive the value of the component.
AsyncComponent::wait_for().await
is equivalent to
AsyncComponent::start_waiting_for().await.wait().await
.
Sourcepub async fn wait_for<C: Component + Clone>(&self) -> C
pub async fn wait_for<C: Component + Clone>(&self) -> C
Wait for the Component
of a given type. Returns the value of the component, once it exists
on the represented entity.
AsyncComponent::wait_for().await
is equivalent to
AsyncComponent::start_waiting_for().await.wait().await
.
Sourcepub async fn insert_wait_remove<I: Component, WR: Component + Clone>(
&self,
component: I,
) -> WR
pub async fn insert_wait_remove<I: Component, WR: Component + Clone>( &self, component: I, ) -> WR
Insert the given Component
of type I
onto the entity, then immediately wait for a
component of type WR
to be added to the entity. After one is received, this will then
remove the component of type WR
.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for AsyncEntity
impl RefUnwindSafe for AsyncEntity
impl Send for AsyncEntity
impl Sync for AsyncEntity
impl Unpin for AsyncEntity
impl UnwindSafe for AsyncEntity
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
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
, which can then be
downcast
into Box<dyn ConcreteType>
where ConcreteType
implements Trait
.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
, which can then be further
downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.