[−][src]Struct legion::world::World
Contains queryable collections of data associated with Entity
s.
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]
T: TagSet + TagLayout + for<'a> Filter<ChunksetFilterData<'a>>,
C: IntoComponentSource,
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]
&self,
entity: Entity
) -> Option<RefMut<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.
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]
&mut self,
entity: Entity
) -> Option<RefMut<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 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
Auto Trait Implementations
Blanket Implementations
impl<T> Resource for T where
T: 'static + Send + Sync,
[src]
T: 'static + Send + Sync,
impl<T> Component for T where
T: 'static + Send + Sync,
[src]
T: 'static + Send + Sync,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = !
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, U> TryInto<U> 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> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[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,
fn into_any(self: Box<T>) -> Box<dyn Any + 'static>
[src]
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
[src]
fn as_any(&self) -> &(dyn Any + 'static)
[src]
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
[src]
impl<T> DowncastSync for T where
T: Send + Sync + Any,
[src]
T: Send + Sync + Any,