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
impl Entities
Sourcepub fn allocate(&mut self) -> Entity
pub fn allocate(&mut self) -> Entity
Creates a new entity. This will be persistent after this call.
Sourcepub fn create(&self) -> Entity
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.
Sourcepub fn create_iter(&self) -> CreateIterAtomic<'_> ⓘ
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
.
Sourcepub fn build_entity(&self) -> AtomicBuilder<'_>
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.
Sourcepub fn kill(&mut self, delete: &[Entity]) -> Result<(), Error>
pub fn kill(&mut self, delete: &[Entity]) -> Result<(), Error>
Kills a list of entities immediately.
Trait Implementations§
Source§impl<'a> Join for &'a Entities
impl<'a> Join for &'a Entities
Source§unsafe fn open(self) -> (Self::Mask, Self)
unsafe fn open(self) -> (Self::Mask, Self)
Source§unsafe fn get(v: &mut &'a Entities, index: Index) -> Entity
unsafe fn get(v: &mut &'a Entities, index: Index) -> Entity
Source§fn join(self) -> JoinIter<Self> ⓘwhere
Self: Sized,
fn join(self) -> JoinIter<Self> ⓘwhere
Self: Sized,
Source§fn maybe(self) -> MaybeJoin<Self>where
Self: Sized,
fn maybe(self) -> MaybeJoin<Self>where
Self: Sized,
Join
-able structure that yields all indices, returning
None
for all missing elements and Some(T)
for found elements. Read moreSource§fn is_unconstrained() -> bool
fn is_unconstrained() -> bool
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.