1 unstable release
0.1.0 | Mar 5, 2024 |
---|
#2297 in Game dev
11KB
134 lines
"A simple concurrent event plugin,the principle is similar to Commads,events can be send/read concurrently, but the reading of events is always in the next bevy frame"
#[derive(Event)] struct E;
fn main() { App::new().add_event_manager::() .... ; } fn send(mut sender:EventsSender){ sender.send(e); ... } fn read(sender:EventsReader){ sender.par_iter()...//iter() }
use bevy::{ app::{App, Update}, ecs::event::Event, }; use bevy_concurrent_event::events::{ ConcurrentEvent, EventsReader, EventsSender, }; use rayon::iter::ParallelIterator;
#[derive(Event)] struct E;
pub fn main() { App::new().add_event_manager::().add_systems( Update, ( |mut s: EventsSender| s.send(E), |r: EventsReader| r.par_read().for_each(|_| {}), ), ); }
Dependencies
~22–49MB
~802K SLoC