Struct specs::changeset::ChangeSet [−][src]
pub struct ChangeSet<T> { /* fields omitted */ }
Change set that can be collected from an iterator, and joined on for easy application to components.
Example
pub struct Health(i32); impl Component for Health { type Storage = DenseVecStorage<Self>; } let a = world.create_entity().with(Health(100)).build(); let b = world.create_entity().with(Health(200)).build(); let changeset = [(a, 32), (b, 12), (b, 13)] .iter() .cloned() .collect::<ChangeSet<i32>>(); for (health, modifier) in (&mut world.write_storage::<Health>(), &changeset).join() { health.0 -= modifier; }
Methods
impl<T> ChangeSet<T>
[src]
impl<T> ChangeSet<T>
pub fn new() -> Self
[src]
pub fn new() -> Self
Create a new change set
pub fn add(&mut self, entity: Entity, value: T) where
T: AddAssign,
[src]
pub fn add(&mut self, entity: Entity, value: T) where
T: AddAssign,
Add a value to the change set. If the entity already have a value in the change set, the incoming value will be added to that.
pub fn clear(&mut self)
[src]
pub fn clear(&mut self)
Clear the changeset
Trait Implementations
impl<T> Default for ChangeSet<T>
[src]
impl<T> Default for ChangeSet<T>
impl<T> FromIterator<(Entity, T)> for ChangeSet<T> where
T: AddAssign,
[src]
impl<T> FromIterator<(Entity, T)> for ChangeSet<T> where
T: AddAssign,
fn from_iter<I: IntoIterator<Item = (Entity, T)>>(iter: I) -> Self
[src]
fn from_iter<I: IntoIterator<Item = (Entity, T)>>(iter: I) -> Self
Creates a value from an iterator. Read more
impl<T> Extend<(Entity, T)> for ChangeSet<T> where
T: AddAssign,
[src]
impl<T> Extend<(Entity, T)> for ChangeSet<T> where
T: AddAssign,
fn extend<I: IntoIterator<Item = (Entity, T)>>(&mut self, iter: I)
[src]
fn extend<I: IntoIterator<Item = (Entity, T)>>(&mut self, iter: I)
Extends a collection with the contents of an iterator. Read more
impl<'a, T> Join for &'a mut ChangeSet<T>
[src]
impl<'a, T> Join for &'a mut ChangeSet<T>
type Type = &'a mut T
Type of joined components.
type Value = &'a mut DenseVecStorage<T>
Type of joined storages.
type Mask = &'a BitSet
Type of joined bit mask.
unsafe fn open(self) -> (Self::Mask, Self::Value)
[src]
unsafe fn open(self) -> (Self::Mask, Self::Value)
Open this join by returning the mask and the storages. Read more
unsafe fn get(v: &mut Self::Value, id: Index) -> Self::Type
[src]
unsafe fn get(v: &mut Self::Value, id: Index) -> Self::Type
Get a joined component value by a given index.
ⓘImportant traits for JoinIter<J>fn join(self) -> JoinIter<Self> where
Self: Sized,
[src]
fn join(self) -> JoinIter<Self> where
Self: Sized,
Create a joined iterator over the contents.
fn maybe(self) -> MaybeJoin<Self> where
Self: Sized,
[src]
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
fn is_unconstrained() -> bool
[src]
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. Read more
impl<'a, T> Join for &'a ChangeSet<T>
[src]
impl<'a, T> Join for &'a ChangeSet<T>
type Type = &'a T
Type of joined components.
type Value = &'a DenseVecStorage<T>
Type of joined storages.
type Mask = &'a BitSet
Type of joined bit mask.
unsafe fn open(self) -> (Self::Mask, Self::Value)
[src]
unsafe fn open(self) -> (Self::Mask, Self::Value)
Open this join by returning the mask and the storages. Read more
unsafe fn get(value: &mut Self::Value, id: Index) -> Self::Type
[src]
unsafe fn get(value: &mut Self::Value, id: Index) -> Self::Type
Get a joined component value by a given index.
ⓘImportant traits for JoinIter<J>fn join(self) -> JoinIter<Self> where
Self: Sized,
[src]
fn join(self) -> JoinIter<Self> where
Self: Sized,
Create a joined iterator over the contents.
fn maybe(self) -> MaybeJoin<Self> where
Self: Sized,
[src]
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
fn is_unconstrained() -> bool
[src]
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. Read more
impl<T> Join for ChangeSet<T>
[src]
impl<T> Join for ChangeSet<T>
type Type = T
Type of joined components.
type Value = DenseVecStorage<T>
Type of joined storages.
type Mask = BitSet
Type of joined bit mask.
unsafe fn open(self) -> (Self::Mask, Self::Value)
[src]
unsafe fn open(self) -> (Self::Mask, Self::Value)
Open this join by returning the mask and the storages. Read more
unsafe fn get(value: &mut Self::Value, id: Index) -> Self::Type
[src]
unsafe fn get(value: &mut Self::Value, id: Index) -> Self::Type
Get a joined component value by a given index.
ⓘImportant traits for JoinIter<J>fn join(self) -> JoinIter<Self> where
Self: Sized,
[src]
fn join(self) -> JoinIter<Self> where
Self: Sized,
Create a joined iterator over the contents.
fn maybe(self) -> MaybeJoin<Self> where
Self: Sized,
[src]
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
fn is_unconstrained() -> bool
[src]
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. Read more