TG6AFI4L4KMIDBEFUTT7CVTAORNP2I5GSMXV64C7NXNJ7WWSBERQC
MO5LXGIHDLSIDXP44J2E2BIKHUHUDHO72UOR4GD7VQ4JLMT3NDCAC
use bevy::app::AppExit;
const TRACK_LENGTH: f32 = 1000.;
#[derive(Debug, Clone, Eq, PartialEq, Hash)]enum RaceState { Running, Finished,}
#[derive(Debug, Clone, Eq, PartialEq, Hash)]
enum RaceState {
Running,
Finished,
}
.insert_resource(RoundTimer(Timer::from_seconds(1., true)))
.add_state(RaceState::Running) .insert_resource(RoundTimer(Timer::from_seconds(0.1, true)))
.add_state(RaceState::Running)
.insert_resource(RoundTimer(Timer::from_seconds(0.1, true)))
.add_system(racers_movement_system);
.add_system_set( SystemSet::on_update(RaceState::Running).with_system(racers_movement_system), ) .add_system_set(SystemSet::on_enter(RaceState::Finished).with_system(race_end_system));
.add_system_set(
SystemSet::on_update(RaceState::Running).with_system(racers_movement_system),
)
.add_system_set(SystemSet::on_enter(RaceState::Finished).with_system(race_end_system));
mut state: ResMut<State<RaceState>>,
if p.0 >= TRACK_LENGTH { state.replace(RaceState::Finished).unwrap(); }
if p.0 >= TRACK_LENGTH {
state.replace(RaceState::Finished).unwrap();
}}fn race_end_system(mut app_exit_events: EventWriter<AppExit>, query: Query<(&Racer, &Position)>) { println!("The race is over"); for (r, p) in query.iter() { println!("Racer {} at {:?}", r.0, p.0);
fn race_end_system(mut app_exit_events: EventWriter<AppExit>, query: Query<(&Racer, &Position)>) {
println!("The race is over");
for (r, p) in query.iter() {
println!("Racer {} at {:?}", r.0, p.0);
app_exit_events.send(AppExit);