specs_messenger

Crates.iospecs_messenger
lib.rsspecs_messenger
version0.1.0
sourcesrc
created_at2018-06-24 13:10:22.247456
updated_at2018-06-24 13:10:22.247456
descriptionmessage passing component for specs
homepagehttps://gitlab.com/nathanfaucett/rs-specs_messenger
repositoryhttps://gitlab.com/nathanfaucett/rs-specs_messenger.git
max_upload_size
id71472
size11,102
Nathan Faucett (nathanfaucett)

documentation

README

specs_messenger

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);
Commit count: 3

cargo fmt