World

Struct World 

Source
pub struct World { /* private fields */ }
Expand description

This type stores everything that is offered by this crate. It is the main type of the ECS. It exposes the API for the ECS, it is the bedrock of the engine.

Implementations§

Source§

impl World

Source

pub fn with_tags(tagf: TagFactory) -> World

Create a new empty World (just like World::default), but with a custom tag factory (instead of an empty one). This is useful because you can’t change the tag factory after assigning it to the world.

Source§

impl World

Source

pub fn get_tag_tracker(&self, entity: EntityId) -> TagTracker

Get the TagTracker of an entity.

Source§

impl World

Source

pub fn query<Q>(&mut self) -> impl Iterator<Item = <Q as ArchQuery>::Item<'_>>
where Q: ArchQuery,

Query the world for components.

Source

pub fn query_filtered<'a, Q, F>( &'a mut self, ) -> impl Iterator<Item = <Q as ArchQuery>::Item<'a>> + 'a
where Q: ArchQuery + 'a, F: ArchFilter + 'a,

Query the world for components, with a filter.

Source§

impl World

Source

pub fn spawn<B>(&mut self, bundle: B) -> EntityId
where B: Bundle + Archetype,

Spawn a new entity with a bundle of components.

Source

pub fn get_component<C>(&self, entity: EntityId) -> Option<&C>
where C: Component,

Get a reference to a Component of an entity.

Source

pub fn get_component_mut<C>(&mut self, entity: EntityId) -> Option<&mut C>
where C: Component,

Get a mutable reference to a Component of an entity.

Source

pub fn despawn(&mut self, entity: EntityId)

Despawn an entity from the World.

Trait Implementations§

Source§

impl Default for World

Source§

fn default() -> World

Returns the “default value” for a type. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V