pub struct World { /* private fields */ }Expand description
A minimal ECS supporting entity and component insertion/removal, association, and single-type iteration.
Implementations§
Source§impl World
impl World
Sourcepub fn insert_entity(&mut self) -> EntityKey
pub fn insert_entity(&mut self) -> EntityKey
Insert a new entity and return the corresponding entity key.
Sourcepub fn remove_entity(&mut self, entity_key: EntityKey) -> Option<()>
pub fn remove_entity(&mut self, entity_key: EntityKey) -> Option<()>
Remove an entity with the corresponding entity key.
If the entity corresponding to the entity key is not found, return an None.
Otherwise, return an Some(()).
Sourcepub fn contains_entity(&self, entity_key: EntityKey) -> bool
pub fn contains_entity(&self, entity_key: EntityKey) -> bool
Return entity with the corresponding entity key.
If the entity corresponding to the entity key is not found, return an None.
Otherwise, return an Some(()).
Sourcepub fn iter_entity(&self) -> impl Iterator<Item = EntityKey> + '_
pub fn iter_entity(&self) -> impl Iterator<Item = EntityKey> + '_
Return an iterator over all entity keys.
Sourcepub fn insert_component<T>(
&mut self,
entity_key: EntityKey,
component: T,
) -> Option<()>where
T: Component,
pub fn insert_component<T>(
&mut self,
entity_key: EntityKey,
component: T,
) -> Option<()>where
T: Component,
Insert a new component with the corresponding entity key and return the corresponding component key.
If the entity corresponding to the entity key is not found, return an None.
Otherwise, return an Some(CompKey).
Sourcepub fn remove_component<T>(&mut self, entity_key: EntityKey) -> Option<()>where
T: Component,
pub fn remove_component<T>(&mut self, entity_key: EntityKey) -> Option<()>where
T: Component,
Remove a component with the corresponding component key and type, and return the component.
If the component corresponding to the component key and type is not found, return an None.
Otherwise, return an Some(()).
Sourcepub fn get_component<T>(&self, entity_key: EntityKey) -> Option<&T>where
T: Component,
pub fn get_component<T>(&self, entity_key: EntityKey) -> Option<&T>where
T: Component,
Return a component with the corresponding component key and type.
If the component corresponding to the component key and type is not found, return an None.
Otherwise, return an Some(&T).
Sourcepub fn get_component_mut<T>(&mut self, entity_key: EntityKey) -> Option<&mut T>where
T: Component,
pub fn get_component_mut<T>(&mut self, entity_key: EntityKey) -> Option<&mut T>where
T: Component,
Return a mutable component with the corresponding component key and type.
If the component corresponding to the component key and type is not found, return an None.
Otherwise, return an Some(&mut T).
Sourcepub fn iter_component<T>(&self) -> impl Iterator<Item = &T>where
T: Component,
pub fn iter_component<T>(&self) -> impl Iterator<Item = &T>where
T: Component,
Return an iterator over all components of the corresponding type.
If the component type is not found, return an None.
Otherwise, return an Some(impl Iterator<Item = &T>).
Sourcepub fn iter_component_mut<T>(&mut self) -> impl Iterator<Item = &mut T>where
T: Component,
pub fn iter_component_mut<T>(&mut self) -> impl Iterator<Item = &mut T>where
T: Component,
Return a mutable iterator over all components of the corresponding type.
If the component type is not found, return an None.
Otherwise, return an Some(impl Iterator<Item = &mut T>).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for World
impl RefUnwindSafe for World
impl Send for World
impl Sync for World
impl Unpin for World
impl UnsafeUnpin 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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more