pub struct World { /* private fields */ }Expand description
A collection of resources and systems.
The World is the executor of your systems and async computations.
Contains Entities and Components as resources, by default.
Implementations
sourceimpl World
impl World
pub fn with_default_resource<T: Default + IsResource>(
&mut self
) -> Result<&mut Self>
pub fn with_resource<T: IsResource>(&mut self, resource: T) -> Result<&mut Self>
pub fn set_resource<T: IsResource>(&mut self, resource: T) -> Result<Option<T>>
sourcepub fn with_plugin(&mut self, plugin: impl Into<Plugin>) -> Result<&mut Self>
pub fn with_plugin(&mut self, plugin: impl Into<Plugin>) -> Result<&mut Self>
Add a plugin to the world, instantiating any missing resources or systems.
Errs
Errs if the plugin requires resources that cannot be created by default.
pub fn with_data<T: CanFetch>(&mut self) -> Result<&mut Self>
sourcepub fn with_system<T, F>(
&mut self,
name: impl AsRef<str>,
sys_fn: F
) -> Result<&mut Self>where
F: FnMut(T) -> Result<ShouldContinue> + Send + Sync + 'static,
T: CanFetch + 'static,
pub fn with_system<T, F>(
&mut self,
name: impl AsRef<str>,
sys_fn: F
) -> Result<&mut Self>where
F: FnMut(T) -> Result<ShouldContinue> + Send + Sync + 'static,
T: CanFetch + 'static,
sourcepub fn with_system_with_dependencies<T, F>(
&mut self,
name: impl AsRef<str>,
sys_fn: F,
after_deps: &[&str],
before_deps: &[&str]
) -> Result<&mut Self>where
F: FnMut(T) -> Result<ShouldContinue> + Send + Sync + 'static,
T: CanFetch + 'static,
pub fn with_system_with_dependencies<T, F>(
&mut self,
name: impl AsRef<str>,
sys_fn: F,
after_deps: &[&str],
before_deps: &[&str]
) -> Result<&mut Self>where
F: FnMut(T) -> Result<ShouldContinue> + Send + Sync + 'static,
T: CanFetch + 'static,
Add a syncronous system that has a dependency on one or more other syncronous systems.
Errs
Errs if expected resources must first be added to the world.
sourcepub fn with_system_barrier(&mut self) -> &mut Self
pub fn with_system_barrier(&mut self) -> &mut Self
Add a syncronous system barrier.
Any systems added after the barrier will be scheduled after the systems added before the barrier.
pub fn with_parallelism(&mut self, parallelism: Parallelism) -> &mut Self
pub fn with_async_system<F, Fut>(
&mut self,
name: impl AsRef<str>,
make_system_future: F
) -> &mut Selfwhere
F: FnOnce(Facade) -> Fut,
Fut: Future<Output = Result<()>> + Send + Sync + 'static,
pub fn with_async(
&mut self,
future: impl Future<Output = ()> + Send + Sync + 'static
) -> &mut Self
sourcepub fn has_resource<T: IsResource>(&self) -> bool
pub fn has_resource<T: IsResource>(&self) -> bool
Returns whether a resources of the given type exists in the world.
sourcepub fn spawn(&self, future: impl Future<Output = ()> + Send + Sync + 'static)
pub fn spawn(&self, future: impl Future<Output = ()> + Send + Sync + 'static)
Spawn a non-system asynchronous task.
sourcepub fn tick(&mut self)
pub fn tick(&mut self)
Conduct a world tick.
Calls World::tick_async, then World::tick_sync, then
World::tick_lazy.
Panics
Panics if any sub-tick step returns an error
sourcepub fn tick_async(&mut self) -> Result<()>
pub fn tick_async(&mut self) -> Result<()>
Just tick the async futures, including sending resources to async systems.
sourcepub fn tick_lazy(&mut self) -> Result<()>
pub fn tick_lazy(&mut self) -> Result<()>
Applies lazy world updates.
Also runs component entity and archetype upkeep.
sourcepub fn resource<T: IsResource>(&self) -> Result<&T>
pub fn resource<T: IsResource>(&self) -> Result<&T>
Attempt to get a reference to one resource.
sourcepub fn resource_mut<T: IsResource>(&mut self) -> Result<&mut T>
pub fn resource_mut<T: IsResource>(&mut self) -> Result<&mut T>
Attempt to get a mutable reference to one resource.
pub fn fetch<T: CanFetch>(&mut self) -> Result<T>
pub fn entity(&mut self) -> Entity
sourcepub fn run(&mut self) -> &mut Self
pub fn run(&mut self) -> &mut Self
Run all system and non-system futures until they have all finished or one system has erred, whichever comes first.
pub fn get_schedule_description(&self) -> String
sourcepub fn get_sync_schedule_names(&self) -> Vec<Vec<&str>>
pub fn get_sync_schedule_names(&self) -> Vec<Vec<&str>>
Returns the scheduled systems’ names, collated by batch.
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for World
impl Send for World
impl Sync for World
impl Unpin for World
impl !UnwindSafe for World
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more