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::<Health>(), &changeset).join() {
    health.0 -= modifier;
}

Methods

impl<T> ChangeSet<T>
[src]

[src]

Create a new change set

[src]

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.

[src]

Clear the changeset

Trait Implementations

impl<T> FromIterator<(Entity, T)> for ChangeSet<T> where
    T: AddAssign
[src]

[src]

Creates a value from an iterator. Read more

impl<T> Extend<(Entity, T)> for ChangeSet<T> where
    T: AddAssign
[src]

[src]

Extends a collection with the contents of an iterator. Read more

impl<'a, T> Join for &'a mut ChangeSet<T>
[src]

Type of joined components.

Type of joined storages.

Type of joined bit mask.

[src]

Open this join by returning the mask and the storages.

[src]

Get a joined component value by a given index.

Important traits for JoinIter<J>
[src]

Create a joined iterator over the contents.

impl<'a, T> Join for &'a ChangeSet<T>
[src]

Type of joined components.

Type of joined storages.

Type of joined bit mask.

[src]

Open this join by returning the mask and the storages.

[src]

Get a joined component value by a given index.

Important traits for JoinIter<J>
[src]

Create a joined iterator over the contents.

impl<T> Join for ChangeSet<T>
[src]

Type of joined components.

Type of joined storages.

Type of joined bit mask.

[src]

Open this join by returning the mask and the storages.

[src]

Get a joined component value by a given index.

Important traits for JoinIter<J>
[src]

Create a joined iterator over the contents.

Auto Trait Implementations

impl<T> Send for ChangeSet<T> where
    T: Send

impl<T> Sync for ChangeSet<T> where
    T: Sync