World

Struct World 

Source
pub struct World {
    pub camera: Camera,
    /* private fields */
}
Expand description

World - manages entities and provides system execution

Fields§

§camera: Camera

Implementations§

Source§

impl World

Source

pub fn new() -> World

Create a new world

Source

pub fn create_entity(&mut self) -> Option<Entity>

Create a new entity

Source

pub fn destroy_entity(&mut self, entity: Entity)

Destroy an entity (note: components must be manually removed)

Source

pub fn entities(&self) -> &[Entity]

Get all active entities

Source

pub fn entity_count(&self) -> usize

Get count of active entities

Source

pub fn query<'a, T>(&'a self, storage: &'a ComponentStorage<T>) -> Query1<'a, T>
where T: Component,

Query entities with one component type

Source

pub fn query2<'a, T1, T2>( &'a self, storage1: &'a ComponentStorage<T1>, storage2: &'a ComponentStorage<T2>, ) -> Query2<'a, T1, T2>
where T1: Component, T2: Component,

Query entities with two component types

Source

pub fn query3<'a, T1, T2, T3>( &'a self, storage1: &'a ComponentStorage<T1>, storage2: &'a ComponentStorage<T2>, storage3: &'a ComponentStorage<T3>, ) -> Query3<'a, T1, T2, T3>
where T1: Component, T2: Component, T3: Component,

Query entities with three component types

Source

pub fn query4<'a, T1, T2, T3, T4>( &'a self, storage1: &'a ComponentStorage<T1>, storage2: &'a ComponentStorage<T2>, storage3: &'a ComponentStorage<T3>, storage4: &'a ComponentStorage<T4>, ) -> Query4<'a, T1, T2, T3, T4>
where T1: Component, T2: Component, T3: Component, T4: Component,

Query entities with four component types

Source

pub fn query_mut<'a, T>( &'a self, storage: &'a mut ComponentStorage<T>, ) -> Query1Mut<'a, T>
where T: Component,

Query entities with one mutable component

Source

pub fn query_1mut_1<'a, T1, T2>( &'a self, storage1: &'a mut ComponentStorage<T1>, storage2: &'a ComponentStorage<T2>, ) -> Query1Mut1<'a, T1, T2>
where T1: Component, T2: Component,

Query: 1 mutable, 1 immutable

Source

pub fn query_1mut_2<'a, T1, T2, T3>( &'a self, storage1: &'a mut ComponentStorage<T1>, storage2: &'a ComponentStorage<T2>, storage3: &'a ComponentStorage<T3>, ) -> Query1Mut2<'a, T1, T2, T3>
where T1: Component, T2: Component, T3: Component,

Query: 1 mutable, 2 immutable

Source

pub fn query_1mut_3<'a, T1, T2, T3, T4>( &'a self, storage1: &'a mut ComponentStorage<T1>, storage2: &'a ComponentStorage<T2>, storage3: &'a ComponentStorage<T3>, storage4: &'a ComponentStorage<T4>, ) -> Query1Mut3<'a, T1, T2, T3, T4>
where T1: Component, T2: Component, T3: Component, T4: Component,

Query: 1 mutable, 3 immutable

Source

pub fn query_2mut_1<'a, T1, T2, T3>( &'a self, storage1: &'a mut ComponentStorage<T1>, storage2: &'a mut ComponentStorage<T2>, storage3: &'a ComponentStorage<T3>, ) -> Query2Mut1<'a, T1, T2, T3>
where T1: Component, T2: Component, T3: Component,

Query: 2 mutable, 1 immutable

Source

pub fn query_2mut<'a, T1, T2>( &'a self, storage1: &'a mut ComponentStorage<T1>, storage2: &'a mut ComponentStorage<T2>, ) -> Query2Mut<'a, T1, T2>
where T1: Component, T2: Component,

Query: 2 mutable components

Source

pub fn query_3mut<'a, T1, T2, T3>( &'a self, storage1: &'a mut ComponentStorage<T1>, storage2: &'a mut ComponentStorage<T2>, storage3: &'a mut ComponentStorage<T3>, ) -> Query3Mut<'a, T1, T2, T3>
where T1: Component, T2: Component, T3: Component,

Query: 3 mutable components

Source

pub fn query_4mut<'a, T1, T2, T3, T4>( &'a self, storage1: &'a mut ComponentStorage<T1>, storage2: &'a mut ComponentStorage<T2>, storage3: &'a mut ComponentStorage<T3>, storage4: &'a mut ComponentStorage<T4>, ) -> Query4Mut<'a, T1, T2, T3, T4>
where T1: Component, T2: Component, T3: Component, T4: Component,

Query: 4 mutable components

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.