use std::num::NonZero; use bevy::{ app::{AppExit, Startup, Update}, prelude::*, MinimalPlugins, }; use bevy_dexterous_developer::*; fn terminal_runner(mut app: App) -> AppExit { app.update(); eprintln!("Ready for Input"); for line in std::io::stdin().lines() { let typed: String = line.unwrap_or_default(); if typed == "exit" { println!("Exiting"); return AppExit::Success; } app.update(); } AppExit::Error(NonZero::::new(1).unwrap()) } reloadable_main!( bevy_main(initial_plugins) { App::new() .add_plugins(initial_plugins.initialize::()) .set_runner(terminal_runner) .setup_reloadable_elements::() .run(); }); #[derive(Event, Debug, Clone)] enum MyEvent { First, Second, } fn update(mut reader: EventReader) -> Option { println!("Running Update"); let event = reader.read().next().cloned(); println!("{event:?}"); event } fn publish(previous: In>, mut writer: EventWriter) { println!("Publish Event"); match previous.0 { Some(MyEvent::First) => writer.send(MyEvent::Second), Some(MyEvent::Second) => writer.send(MyEvent::First), None => writer.send(MyEvent::First), }; } fn startup() { println!("Press Enter to Progress, or type 'exit' to exit"); } reloadable_scope!(reloadable(app) { app.add_systems(Startup, startup) .add_systems(Update, update.pipe(publish)) .add_event::(); });