Struct Entities

Source
pub struct Entities { /* private fields */ }
Expand description

The entities of this ECS. This is a resource, stored in the World. If you just want to access it in your system, you can also use Read<Entities>.

Please note that you should never get this mutably in a system, because it would block all the other systems.

You need to call World::maintain after creating / deleting entities with this struct.

Implementations§

Source§

impl Entities

Source

pub fn allocate(&mut self) -> Entity

Creates a new entity. This will be persistent after this call.

Source

pub fn create(&self) -> Entity

Creates a new entity atomically. This will be persistent as soon as you call World::maintain.

If you want a lazy entity builder, take a look at LazyUpdate::create_entity.

In case you have access to the World, you can also use World::create_entity which creates the entity and the components immediately.

Source

pub fn create_iter(&self) -> CreateIterAtomic<'_>

Returns an iterator which creates new entities atomically. They will be persistent as soon as you call World::maintain.

Source

pub fn build_entity(&self) -> AtomicBuilder<'_>

Similar to the create method above this creates an entity atomically, and then returns a builder which can be used to insert components into various storages if available.

Source

pub fn kill(&mut self, delete: &[Entity]) -> Result<(), Error>

Kills a list of entities immediately.

Source

pub fn delete(&self, entity: Entity) -> Result<(), Error>

Deletes an entity atomically. The associated components will be deleted as soon as you call World::maintain.

Source

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

Returns true if the specified entity is alive.

Source

pub fn maintain(&mut self) -> Vec<Entity>

Maintains the allocated entities, mainly dealing with atomically allocated or killed entities.

Trait Implementations§

Source§

impl Default for Entities

Source§

fn default() -> Entities

Returns the “default value” for a type. Read more
Source§

impl<'a> Join for &'a Entities

Source§

type Mask = &'a BitSet

Type of joined bit mask.
Source§

type Type = Entity

Type of joined components.
Source§

type Value = &'a Entities

Type of joined storages.
Source§

unsafe fn open(self) -> (Self::Mask, Self)

Open this join by returning the mask and the storages. Read more
Source§

unsafe fn get(v: &mut &'a Entities, index: Index) -> Entity

Get a joined component value by a given index. Read more
Source§

fn join(self) -> JoinIter<Self>
where Self: Sized,

Create a joined iterator over the contents.
Source§

fn maybe(self) -> MaybeJoin<Self>
where Self: Sized,

Returns a Join-able structure that yields all indices, returning None for all missing elements and Some(T) for found elements. Read more
Source§

fn is_unconstrained() -> bool

If this Join typically returns all indices in the mask, then iterating over only it or combined with other joins that are also dangerous will cause the JoinIter/ParJoin to go through all indices which is usually not what is wanted and will kill performance.
Source§

impl<'a> ParJoin for &'a Entities

Source§

fn par_join(self) -> JoinParIter<Self>
where Self: Sized,

Auto Trait Implementations§

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> Any for T
where T: Any,

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> TryDefault for T
where T: Default,

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.
Source§

impl<T> Resource for T
where T: Any + Send + Sync,