pub struct AsyncWorld(/* private fields */);
Expand description
Exposes asynchronous access to the Bevy ECS World
.
The easiest way to get an AsyncWorld
is with AsyncWorld::from_world()
.
§Commands
Apply any Command
asynchronously with AsyncWorld::apply_command
.
§Systems
Just like their synchronous variants, asynchronous System
s must be registered
before they can be used. Systems can optionally accept and return values asynchronously
if they are registered with AsyncWorld::register_io_system
.
§Entities
Spawn entities with the AsyncWorld::spawn_*
family.
§Resources
Insert, remove, and wait for resources to exist.
Implementations§
Source§impl AsyncWorld
impl AsyncWorld
Sourcepub fn sender(&self) -> CommandQueueSender
pub fn sender(&self) -> CommandQueueSender
Returns a copy of the underlying CommandQueueSender
.
Sourcepub fn start_queue(&self) -> CommandQueueBuilder
pub fn start_queue(&self) -> CommandQueueBuilder
Starts building a CommandQueue
.
Sourcepub async fn run_system<M>(
self,
system: impl IntoSystem<(), (), M> + Send + 'static,
)
pub async fn run_system<M>( self, system: impl IntoSystem<(), (), M> + Send + 'static, )
Run a System
once.
Sourcepub async fn register_system<M>(
&self,
system: impl IntoSystem<(), (), M> + Send,
) -> AsyncSystem
pub async fn register_system<M>( &self, system: impl IntoSystem<(), (), M> + Send, ) -> AsyncSystem
Registers a System
and returns an AsyncSystem
that can be used to run the system on demand.
Sourcepub async fn register_io_system<I: Send + 'static, O: Send + 'static, M>(
&self,
system: impl IntoSystem<In<I>, O, M> + Send,
) -> AsyncIOSystem<I, O>
pub async fn register_io_system<I: Send + 'static, O: Send + 'static, M>( &self, system: impl IntoSystem<In<I>, O, M> + Send, ) -> AsyncIOSystem<I, O>
Registers a System
and returns an AsyncIOSystem
that can be used to run the system on demand
while supplying an input value and receiving an output value.
Sourcepub fn entity(&self, id: Entity) -> AsyncEntity
pub fn entity(&self, id: Entity) -> AsyncEntity
Constructs an AsyncEntity
for the given Entity
. If the entity does not exist, any operation
performed on it will panic.
Sourcepub async fn spawn_empty(&self) -> AsyncEntity
pub async fn spawn_empty(&self) -> AsyncEntity
Spawns a new Entity
and returns an AsyncEntity
that represents it, which can be used
to further manipulate the entity.
Sourcepub async fn spawn<B: Bundle>(&self, bundle: B) -> AsyncEntity
pub async fn spawn<B: Bundle>(&self, bundle: B) -> AsyncEntity
Spawns a new Entity
with the given Bundle
and returns an AsyncEntity
that represents it,
which can be used to further manipulate the entity.
Sourcepub async fn spawn_named(
&self,
name: impl Into<Cow<'static, str>> + Send,
) -> AsyncEntity
pub async fn spawn_named( &self, name: impl Into<Cow<'static, str>> + Send, ) -> AsyncEntity
Spawns a new Entity
and returns an AsyncEntity
that represents it, which can be used
to further manipulate the entity. This function attaches a bevy Name
component with the given
value.
Sourcepub async fn insert_resource<R: Resource>(&self, resource: R)
pub async fn insert_resource<R: Resource>(&self, resource: R)
Inserts a new resource or updates an existing resource with the given value.
Sourcepub async fn remove_resource<R: Resource>(&self)
pub async fn remove_resource<R: Resource>(&self)
Removes the resource of a given type, if it exists.
Sourcepub async fn start_waiting_for_resource<R: Resource + Clone>(
&self,
) -> AsyncResource<R>
pub async fn start_waiting_for_resource<R: Resource + Clone>( &self, ) -> AsyncResource<R>
Start waiting for the Resource
of a given type. Returns an AsyncResource
which can be further
waited to receive the value of the resource.
AsyncWorld::wait_for_resource().await
is equivalent to
AsyncWorld::start_waiting_for_resource().await.wait().await
.
Sourcepub async fn wait_for_resource<R: Resource + Clone>(&self) -> R
pub async fn wait_for_resource<R: Resource + Clone>(&self) -> R
Wait for the Resource
of a given type. Returns the value of the resource, once it exists.
AsyncWorld::wait_for_resource().await
is equivalent to
AsyncWorld::start_waiting_for_resource().await.wait().await
.
Sourcepub async fn send_event<E: Event>(&self, event: E)
pub async fn send_event<E: Event>(&self, event: E)
Send an Event
to the bevy world.
Sourcepub async fn start_waiting_for_events<E: Event + Clone>(&self) -> AsyncEvents<E>
pub async fn start_waiting_for_events<E: Event + Clone>(&self) -> AsyncEvents<E>
Start listening for Event
s coming from the main bevy world.
Returns an AsyncEvents
which can be further waited to receive these events.
AsyncWorld::wait_for_event().await
is equivalent to
AsyncWorld::start_waiting_for_events().await.wait().await
.
Sourcepub async fn wait_for_event<E: Event + Clone>(&self) -> E
pub async fn wait_for_event<E: Event + Clone>(&self) -> E
Wait for the Event
of a given type. Returns the value of the event, once it is received.
AsyncWorld::wait_for_event().await
is equivalent to
AsyncWorld::start_waiting_for_events().await.wait().await
.
Sourcepub async fn trigger_targets<E: Event, T: TriggerTargets + Send + Sync + 'static>(
&self,
event: E,
targets: T,
)
pub async fn trigger_targets<E: Event, T: TriggerTargets + Send + Sync + 'static>( &self, event: E, targets: T, )
Trait Implementations§
Source§impl Clone for AsyncWorld
impl Clone for AsyncWorld
Source§fn clone(&self) -> AsyncWorld
fn clone(&self) -> AsyncWorld
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for AsyncWorld
impl Debug for AsyncWorld
Source§impl From<CommandQueueSender> for AsyncWorld
impl From<CommandQueueSender> for AsyncWorld
Source§fn from(sender: CommandQueueSender) -> Self
fn from(sender: CommandQueueSender) -> Self
Source§impl FromWorld for AsyncWorld
impl FromWorld for AsyncWorld
Source§fn from_world(world: &mut World) -> Self
fn from_world(world: &mut World) -> Self
Self
using data from the given World
.Auto Trait Implementations§
impl Freeze for AsyncWorld
impl RefUnwindSafe for AsyncWorld
impl Send for AsyncWorld
impl Sync for AsyncWorld
impl Unpin for AsyncWorld
impl UnwindSafe for AsyncWorld
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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.