pub struct World {
pub job_system: JobPool,
/* private fields */
}Fields§
§job_system: JobPoolImplementations§
Source§impl World
impl World
pub fn new(initial_capacity: u32) -> Self
pub fn reserve_entities(&mut self, additional: u32)
pub fn entity_capacity(&self) -> usize
Sourcepub fn write_entities(&self, w: impl Write) -> Result<()>
pub fn write_entities(&self, w: impl Write) -> Result<()>
Writes entity ids and their archetype hash
pub fn num_entities(&self) -> usize
pub fn is_id_valid(&self, id: EntityId) -> bool
pub fn apply_commands(&mut self) -> Result<(), CommandError>
pub fn insert_entity(&mut self) -> EntityId
pub fn delete_entity(&mut self, id: EntityId) -> WorldResult<()>
pub fn set_bundle<T: Bundle>( &mut self, entity_id: EntityId, bundle: T, ) -> WorldResult<()>
pub fn set_component<T: Component>( &mut self, entity_id: EntityId, component: T, ) -> WorldResult<()>
pub fn get_component<T: Component>(&self, entity_id: EntityId) -> Option<&T>
pub fn get_component_mut<T: Component>( &self, entity_id: EntityId, ) -> Option<&mut T>
pub fn remove_component<T: Component>( &mut self, entity_id: EntityId, ) -> WorldResult<()>
pub fn insert_resource<T: Component>(&mut self, value: T)
pub fn remove_resource<T: 'static>(&mut self) -> Option<Box<T>>
pub fn get_resource<T: 'static>(&self) -> Option<&T>
pub fn get_resource_mut<T: 'static>(&mut self) -> Option<&mut T>
pub fn get_resource_or_default<T: Default + Component>(&mut self) -> &mut T
pub fn get_or_insert_resource<T: Component>( &mut self, init: impl FnOnce() -> T, ) -> &mut T
Sourcepub fn add_stage<'a>(&mut self, stage: impl Into<SystemStage<'a>>)
pub fn add_stage<'a>(&mut self, stage: impl Into<SystemStage<'a>>)
System stages are executed in the order they were added to the World
Sourcepub fn run_stage<'a>(
&mut self,
stage: impl Into<SystemStage<'a>>,
) -> RunStageReturn<'a>
pub fn run_stage<'a>( &mut self, stage: impl Into<SystemStage<'a>>, ) -> RunStageReturn<'a>
Run a single stage withouth adding it to the World
Return the command result and the stage that was ran, so the stage can be reused
Sourcepub fn run_system<'a, S, P, R>(&mut self, system: S) -> Result<R, CommandError>where
S: IntoOnceSystem<'a, P, R>,
pub fn run_system<'a, S, P, R>(&mut self, system: S) -> Result<R, CommandError>where
S: IntoOnceSystem<'a, P, R>,
Run a system and apply any commands before returning
Returns the commands result
Sourcepub fn run_view_system<'a, S, P, R>(&self, system: S) -> Rwhere
S: IntoOnceSystem<'a, P, R>,
pub fn run_view_system<'a, S, P, R>(&self, system: S) -> Rwhere
S: IntoOnceSystem<'a, P, R>,
Run a system that only gets a read-only view of the world. All mutable access is forbidden, including Commands
Panics if the system does not conform to the requirements
pub fn tick(&mut self)
Sourcepub fn ensure_commands(&mut self) -> Commands<'_>
pub fn ensure_commands(&mut self) -> Commands<'_>
Constructs a new crate::commands::Commands instance with initialized buffers in this world
Sourcepub fn get_entity_ty(&self, id: EntityId) -> Option<u128>
pub fn get_entity_ty(&self, id: EntityId) -> Option<u128>
Return the “type” of the Entity. Type itself is an opaque hash.
This function is meant to be used to test successful saving/loading of entities
pub fn get_entity_component_types(&self, id: EntityId) -> Option<Vec<TypeId>>
pub fn get_entity_component_names( &self, id: EntityId, ) -> Option<Vec<&'static str>>
Sourcepub fn checksum(&self) -> u64
pub fn checksum(&self) -> u64
Compute a checksum of the World
Note that only entities and their archetypes are considered, the contents of the components themselves are ignored
Sourcepub fn merge_entities(
&mut self,
lhs: EntityId,
rhs: EntityId,
) -> WorldResult<()>
pub fn merge_entities( &mut self, lhs: EntityId, rhs: EntityId, ) -> WorldResult<()>
Move all components from lhs to rhs, overrinding components rhs already has. Then
delete the lhs entity
Sourcepub fn insert_id(&mut self, id: EntityId) -> Result<(), InsertError>
pub fn insert_id(&mut self, id: EntityId) -> Result<(), InsertError>
Insert a pre-allocated entity id into the world.
Insert is an O(n) operation that walks a linked-list. Prefer [[insert_entity]]
pub fn archetypes(&self) -> &BTreeMap<u128, Pin<Box<EntityTable>>>
pub fn entity_table(&self, id: EntityId) -> Option<&EntityTable>
pub fn clear_deleted(&mut self)
pub fn iter_deleted(&self) -> impl Iterator<Item = EntityId>
Sourcepub fn update_deleted(&mut self)
pub fn update_deleted(&mut self)
Apply pending deleted list additions