[][src]Struct legion::World

pub struct World { /* fields omitted */ }

Contains queryable collections of data associated with Entitys.

Methods

impl World[src]

pub fn merge(&mut self, other: World)[src]

Merges two worlds together.

This function moves all chunks from other into self. This operation is very fast, however the resulting memory layout may be inefficient if other contains a very small number of entities.

Merge is most effectively used to allow large numbers of entities to be loaded and initialized in the background, and then shunted into the "main" world all at once, once ready.

Safety

It is only safe to merge worlds which belong to the same Universe. This is currently not validated by the API.

pub fn is_alive(&self, entity: &Entity) -> bool[src]

Determines if the given Entity is alive within this World.

pub fn insert_from<S, T>(&mut self, shared: S, components: T) -> &[Entity] where
    S: SharedDataSet,
    T: IntoIterator,
    T::Item: EntityDataSet,
    IterEntitySource<T::IntoIter, T::Item>: EntitySource
[src]

Inserts entities from an iterator of component tuples.

Examples

Inserting entity tuples:

let shared = (model, color);
let data = vec![
    (Position(0.0), Rotation(0.0)),
    (Position(1.0), Rotation(1.0)),
    (Position(2.0), Rotation(2.0)),
];
world.insert_from(shared, data);

pub fn insert<S, T>(&mut self, shared: S, components: T) -> &[Entity] where
    S: SharedDataSet,
    T: EntitySource
[src]

Inserts entities from an EntitySource.

pub fn delete(&mut self, entity: Entity) -> bool[src]

Removes the given Entity from the World.

Returns true if the entity was deleted; else false.

pub fn entity_data<'a, T: EntityData>(
    &'a self,
    entity: Entity
) -> Option<Borrowed<'a, T>>
[src]

Borrows entity data for the given entity.

Returns Some(data) if the entity was found and contains the specified data. Otherwise None is returned.

Panics

This function borrows all components of type T in the world. It may panic if any other code is currently borrowing T mutably (such as in a query).

pub fn entity_data_mut<T: EntityData>(
    &mut self,
    entity: Entity
) -> Option<&mut T>
[src]

Mutably borrows entity data for the given entity.

Returns Some(data) if the entity was found and contains the specified data. Otherwise None is returned.

pub fn shared<T: SharedData>(&self, entity: Entity) -> Option<&T>[src]

Borrows shared data for the given entity.

Returns Some(data) if the entity was found and contains the specified data. Otherwise None is returned.

Trait Implementations

impl Debug for World[src]

Auto Trait Implementations

impl !Send for World

impl Sync for World

Blanket Implementations

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> From for T[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Downcast for T where
    T: Any
[src]

impl<T> Erased for T