[−][src]Struct legion::World
Contains queryable collections of data associated with Entity
s.
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]
S: SharedDataSet,
T: IntoIterator,
T::Item: EntityDataSet,
IterEntitySource<T::IntoIter, T::Item>: EntitySource,
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]
S: SharedDataSet,
T: EntitySource,
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]
&'a self,
entity: Entity
) -> Option<Borrowed<'a, T>>
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]
&mut self,
entity: Entity
) -> Option<&mut T>
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
Auto Trait Implementations
Blanket Implementations
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From for T
[src]
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Downcast for T where
T: Any,
[src]
T: Any,