pub struct World {
    pub resources: Resources,
    pub components: ComponentStores,
}Expand description
The World is simply a collection of Resources, and ComponentStores.
Also stored in the world is the Entities, but it is stored as a resource.
World is designed to be trivially Cloneed to allow for snapshotting the world state. The
is especially useful in the context of rollback networking, which requires the ability to
snapshot and restore state.
Fields§
§resources: ResourcesStores the world resources.
components: ComponentStoresStores the world components.
Implementations§
§impl World
 
impl World
pub fn with_entities(entities: AtomicResource<Entities>) -> World
pub fn with_entities(entities: AtomicResource<Entities>) -> World
Create a new world that uses the provided entities resource.
This allows multiple worlds to avoid allocating the same entity IDs.
pub fn maintain(&self)
pub fn maintain(&self)
Remove the component info for dead entities.
This should be called every game frame to cleanup entities that have been killed.
This will remove the component storage for all killed entities, and allow their slots to be re-used for any new entities.
pub fn run_system<'system, R, In, Out, S>(&self, system: S, input: In) -> Outwhere
    In: 'system,
    Out: 'system,
    S: IntoSystem<R, In, Out>,
    <S as IntoSystem<R, In, Out>>::Sys: 'system,
pub fn run_system<'system, R, In, Out, S>(&self, system: S, input: In) -> Outwhere
    In: 'system,
    Out: 'system,
    S: IntoSystem<R, In, Out>,
    <S as IntoSystem<R, In, Out>>::Sys: 'system,
Run a system once.
This is good for initializing the world with setup systems.
pub fn entity_components<Q>(
    &self,
    entity: Entity,
    query: Q,
) -> <<Q as QueryItem>::Iter as Iterator>::Itemwhere
    Q: QueryItem,
pub fn entity_components<Q>(
    &self,
    entity: Entity,
    query: Q,
) -> <<Q as QueryItem>::Iter as Iterator>::Itemwhere
    Q: QueryItem,
Get an entity’s components.
§Panics
Panics if the entity does not have the required components from the query.
pub fn get_entity_components<Q>(
    &self,
    entity: Entity,
    query: Q,
) -> Option<<<Q as QueryItem>::Iter as Iterator>::Item>where
    Q: QueryItem,
pub fn get_entity_components<Q>(
    &self,
    entity: Entity,
    query: Q,
) -> Option<<<Q as QueryItem>::Iter as Iterator>::Item>where
    Q: QueryItem,
Get an entity’s components.
pub fn init_resource<R>(&mut self) -> RefMut<'_, R>
pub fn init_resource<R>(&mut self) -> RefMut<'_, R>
Initialize a resource of type T by inserting it’s default value.
pub fn insert_resource<R>(&mut self, resource: R) -> Option<R>where
    R: HasSchema,
pub fn insert_resource<R>(&mut self, resource: R) -> Option<R>where
    R: HasSchema,
Insert a resource.
pub fn resource_mut<T>(&self) -> RefMut<'_, T>where
    T: HasSchema,
pub fn resource_mut<T>(&self) -> RefMut<'_, T>where
    T: HasSchema,
pub fn get_resource<T>(&self) -> Option<Ref<'_, T>>where
    T: HasSchema,
pub fn get_resource<T>(&self) -> Option<Ref<'_, T>>where
    T: HasSchema,
Borrow a resource from the world, if it exists.
pub fn get_resource_mut<T>(&self) -> Option<RefMut<'_, T>>where
    T: HasSchema,
pub fn get_resource_mut<T>(&self) -> Option<RefMut<'_, T>>where
    T: HasSchema,
Borrow a resource from the world, if it exists.
pub fn component<T>(&self) -> Ref<'_, ComponentStore<T>>where
    T: HasSchema,
pub fn component<T>(&self) -> Ref<'_, ComponentStore<T>>where
    T: HasSchema,
Borrow a component store from the world.
§Panics
Panics if the component store does not exist in the world.
pub fn component_mut<T>(&self) -> RefMut<'_, ComponentStore<T>>where
    T: HasSchema,
pub fn component_mut<T>(&self) -> RefMut<'_, ComponentStore<T>>where
    T: HasSchema,
Mutably borrow a component store from the world.
§Panics
Panics if the component store does not exist in the world.
pub fn load_snapshot(&mut self, snapshot: World)
pub fn load_snapshot(&mut self, snapshot: World)
Load snapshot of World into self.
Trait Implementations§
§impl SystemParam for &World
 
impl SystemParam for &World
§type Param<'s> = &'s World
 
type Param<'s> = &'s World
§fn get_state(_world: &World) -> <&World as SystemParam>::State
 
fn get_state(_world: &World) -> <&World as SystemParam>::State
§fn borrow<'s>(
    world: &'s World,
    _state: &'s mut <&World as SystemParam>::State,
) -> <&World as SystemParam>::Param<'s>
 
fn borrow<'s>( world: &'s World, _state: &'s mut <&World as SystemParam>::State, ) -> <&World as SystemParam>::Param<'s>
source§impl WorldExt for World
 
impl WorldExt for World
source§fn handle_world_reset(&mut self, stages: &mut SystemStages)
 
fn handle_world_reset(&mut self, stages: &mut SystemStages)
SessionRunner before or after SystemStages::run to allow triggering reset
of world with the ResetWorld resource. Read moresource§fn reset_triggered(&self) -> bool
 
fn reset_triggered(&self) -> bool
ResetWorld resource. If SessionRunner needs to do anything special
for a world reset (preserve managed resources, etc) - can check this before calling handle_world_reset to see
if a rese will occur.source§fn reset_internals(&mut self, stages: &mut SystemStages)
 
fn reset_internals(&mut self, stages: &mut SystemStages)
Auto Trait Implementations§
impl Freeze for World
impl !RefUnwindSafe for World
impl Send for World
impl Sync for World
impl Unpin for World
impl !UnwindSafe for World
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§default unsafe fn clone_to_uninit(&self, dst: *mut T)
 
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit)§impl<T> FromWorld for Twhere
    T: Default,
 
impl<T> FromWorld for Twhere
    T: Default,
§fn from_world(_world: &World) -> T
 
fn from_world(_world: &World) -> T
Self using data from the given World.