[−][src]Struct specs::changeset::ChangeSet
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]
pub fn new() -> Self
[src]
Create a new change set
pub fn add(&mut self, entity: Entity, value: T) where
T: AddAssign,
[src]
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]
Clear the changeset
Trait Implementations
impl<'a, T> Join for &'a mut ChangeSet<T>
[src]
type Mask = &'a BitSet
Type of joined bit mask.
type Type = &'a mut T
Type of joined components.
type Value = &'a mut DenseVecStorage<T>
Type of joined storages.
unsafe fn open(self) -> (Self::Mask, Self::Value)
[src]
unsafe fn get(v: &mut Self::Value, id: Index) -> Self::Type
[src]
ⓘImportant traits for JoinIter<J>fn join(self) -> JoinIter<Self> where
Self: Sized,
[src]
Self: Sized,
Create a joined iterator over the contents.
fn maybe(self) -> MaybeJoin<Self> where
Self: Sized,
[src]
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]
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]
type Mask = &'a BitSet
Type of joined bit mask.
type Type = &'a T
Type of joined components.
type Value = &'a DenseVecStorage<T>
Type of joined storages.
unsafe fn open(self) -> (Self::Mask, Self::Value)
[src]
unsafe fn get(value: &mut Self::Value, id: Index) -> Self::Type
[src]
ⓘImportant traits for JoinIter<J>fn join(self) -> JoinIter<Self> where
Self: Sized,
[src]
Self: Sized,
Create a joined iterator over the contents.
fn maybe(self) -> MaybeJoin<Self> where
Self: Sized,
[src]
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]
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]
A Join
implementation for ChangeSet
that simply removes all the entries
on a call to get
.
type Mask = BitSet
Type of joined bit mask.
type Type = T
Type of joined components.
type Value = DenseVecStorage<T>
Type of joined storages.
unsafe fn open(self) -> (Self::Mask, Self::Value)
[src]
unsafe fn get(value: &mut Self::Value, id: Index) -> Self::Type
[src]
ⓘImportant traits for JoinIter<J>fn join(self) -> JoinIter<Self> where
Self: Sized,
[src]
Self: Sized,
Create a joined iterator over the contents.
fn maybe(self) -> MaybeJoin<Self> where
Self: Sized,
[src]
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]
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> Default for ChangeSet<T>
[src]
impl<T> Extend<(Entity, T)> for ChangeSet<T> where
T: AddAssign,
[src]
T: AddAssign,
impl<T> FromIterator<(Entity, T)> for ChangeSet<T> where
T: AddAssign,
[src]
T: AddAssign,
Auto Trait Implementations
impl<T> Unpin for ChangeSet<T> where
T: Unpin,
T: Unpin,
impl<T> Sync for ChangeSet<T> where
T: Sync,
T: Sync,
impl<T> Send for ChangeSet<T> where
T: Send,
T: Send,
impl<T> UnwindSafe for ChangeSet<T> where
T: UnwindSafe,
T: UnwindSafe,
impl<T> RefUnwindSafe for ChangeSet<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
Blanket Implementations
impl<T> TryDefault for T where
T: Default,
[src]
T: Default,
fn try_default() -> Result<T, String>
[src]
fn unwrap_default() -> Self
[src]
Calls try_default
and panics on an error case.
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 = Infallible
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> Resource for T where
T: Any + Send + Sync,
[src]
T: Any + Send + Sync,
impl<T> Any for T where
T: Any,
[src]
T: Any,
fn get_type_id(&self) -> TypeId
[src]
impl<T> Event for T where
T: Send + Sync + 'static,
[src]
T: Send + Sync + 'static,