Crates.io | specs_messenger |
lib.rs | specs_messenger |
version | 0.1.0 |
source | src |
created_at | 2018-06-24 13:10:22.247456 |
updated_at | 2018-06-24 13:10:22.247456 |
description | message passing component for specs |
homepage | https://gitlab.com/nathanfaucett/rs-specs_messenger |
repository | https://gitlab.com/nathanfaucett/rs-specs_messenger.git |
max_upload_size | |
id | 71472 |
size | 11,102 |
message passing component for specs
let mut world = World::new();
let mut dispatcher = SpecsBundler::new(&mut world, DispatcherBuilder::new())
.bundle(MessengerBundle::<String>::new()).unwrap()
.build();
let entity0 = world
.create_entity()
.with(Messenger::<String>::new())
.build();
let entity1 = world
.create_entity()
.with(Messenger::<String>::new())
.build();
let entity2 = world
.create_entity()
.with(Messenger::<String>::new())
.build();
{
let mut messengers = world.write_storage::<Messenger<String>>();
messengers
.get_mut(entity0)
.unwrap()
.send(entity1, "Direct".into());
messengers
.get_mut(entity2)
.unwrap()
.broadcast("Broadcast".into());
}
dispatcher.dispatch(&mut world.res);