#![allow(unused)]
use beet::prelude::*;
use bevy::prelude::*;
use bevy::time::common_conditions::on_timer;
use std::time::Duration;
fn main() {
let mut app = App::new();
app.add_plugins((
MinimalPlugins,
ControlFlowPlugin::default(),
DebugFlowPlugin::with_result(),
))
.add_systems(Update, patrol.run_if(on_timer(Duration::from_millis(100))));
app.world_mut()
.spawn((Name::new("root"), Sequence))
.with_children(|parent| {
parent
.spawn((
Name::new("Long Running"),
Sequence,
EndInDuration::new(Outcome::Pass, Duration::from_secs(5)),
))
.with_children(|parent| {
parent
.spawn((
Name::new("Patrol Sequence"),
Sequence,
Repeat::default(),
))
.with_child((
Name::new("Patrol Left"),
Patrol::default(),
EndInDuration::new(
Outcome::Pass,
Duration::from_secs(1),
),
))
.with_child((
Name::new("Patrol Right"),
Patrol::default(),
EndInDuration::new(
Outcome::Pass,
Duration::from_secs(1),
),
));
});
parent.spawn(Name::new("After Long Running")).observe_any(
|_trigger: On<GetOutcome>| {
println!("After Long Running triggered, exiting");
std::process::exit(0);
},
);
})
.trigger_target(GetOutcome);
app.run();
}
#[derive(Default, Component, Reflect)]
#[require(ContinueRun)]
struct Patrol {
count: usize,
}
fn patrol(mut query: Query<(&mut Patrol, &Name), With<Running>>) {
for (mut action, name) in query.iter_mut() {
action.count += 1;
println!("{}: {}", name, action.count);
}
}