[][src]Struct legion::world::World

pub struct World {
    pub resources: Resources,
    // some fields omitted
}

Contains queryable collections of data associated with Entitys.

Fields

resources: Resources

Methods

impl World[src]

pub fn new() -> Self[src]

Create a new World independent of any Universe.

Entity IDs in such a world will only be unique within that world. See also Universe::create_world.

pub fn entity_channel(&mut self) -> &mut Channel<EntityEvent>[src]

pub fn id(&self) -> WorldId[src]

Gets the unique ID of this world within its universe.

pub fn insert<T, C>(&mut self, tags: T, components: C) -> &[Entity] where
    T: TagSet + TagLayout + for<'a> Filter<ChunksetFilterData<'a>>,
    C: IntoComponentSource
[src]

Inserts new entities into the world.

Examples

Inserting entity tuples:

let tags = (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(tags, data);

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 add_component<T: Component>(&mut self, entity: Entity, component: T)[src]

Adds a component to an entity, or sets its value if the component is already present.

pub fn remove_component<T: Component>(&mut self, entity: Entity)[src]

Removes a component from an entity.

pub fn add_tag<T: Tag>(&mut self, entity: Entity, tag: T)[src]

Adds a tag to an entity, or sets its value if the tag is already present.

pub fn remove_tag<T: Tag>(&mut self, entity: Entity)[src]

Removes a tag from an entity.

pub fn get_component<T: Component>(&self, entity: Entity) -> Option<Ref<T>>[src]

Borrows component data for the given entity.

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

pub unsafe fn get_component_mut_unchecked<T: Component>(
    &self,
    entity: Entity
) -> Option<RefMut<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.

Safety

Accessing a component which is already being concurrently accessed elsewhere is undefined behavior.

Panics

This function may panic if any other code is currently borrowing T (such as in a query).

pub fn get_component_mut<T: Component>(
    &mut self,
    entity: Entity
) -> Option<RefMut<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 get_tag<T: Tag>(&self, entity: Entity) -> Option<&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. Gets tag data for the given entity.

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

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

Determines if the given Entity is alive within this World.

pub fn defrag(&mut self, budget: Option<usize>)[src]

Iteratively defragments the world's internal memory.

This compacts entities into fewer more continuous chunks.

budget describes the maximum number of entities that can be moved in one call. Subsequent calls to defrag will resume progress from the previous call.

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

Trait Implementations

impl Send for World[src]

impl Sync for World[src]

impl Default for World[src]

Auto Trait Implementations

impl Unpin for World

impl !UnwindSafe for World

impl !RefUnwindSafe for World

Blanket Implementations

impl<T> Resource for T where
    T: 'static + Send + Sync
[src]

impl<T> Component for T where
    T: 'static + Send + Sync
[src]

impl<T> From<T> for T[src]

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

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

type Error = !

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> 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> Borrow<T> for T where
    T: ?Sized
[src]

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

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

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

impl<T> DowncastSync for T where
    T: Send + Sync + Any
[src]