| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
use bevy::{ |
| 5 |
app::MainScheduleOrder, |
| 6 |
ecs::schedule::{ScheduleLabel, SingleThreadedExecutor}, |
| 7 |
prelude::*, |
| 8 |
}; |
| 9 |
|
| 10 |
#[derive(ScheduleLabel, Debug, Hash, PartialEq, Eq, Clone)] |
| 11 |
struct SingleThreadedUpdate; |
| 12 |
|
| 13 |
#[derive(ScheduleLabel, Debug, Hash, PartialEq, Eq, Clone)] |
| 14 |
struct CustomStartup; |
| 15 |
|
| 16 |
fn main() { |
| 17 |
let mut app = App::new(); |
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
let mut custom_update_schedule = Schedule::new(SingleThreadedUpdate); |
| 23 |
custom_update_schedule.set_executor(SingleThreadedExecutor::new()); |
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
app.add_schedule(custom_update_schedule); |
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
let mut main_schedule_order = app.world_mut().resource_mut::<MainScheduleOrder>(); |
| 39 |
main_schedule_order.insert_after(Update, SingleThreadedUpdate); |
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
app.add_schedule(Schedule::new(CustomStartup)); |
| 44 |
|
| 45 |
let mut main_schedule_order = app.world_mut().resource_mut::<MainScheduleOrder>(); |
| 46 |
main_schedule_order.insert_startup_after(PreStartup, CustomStartup); |
| 47 |
|
| 48 |
app.add_systems(SingleThreadedUpdate, single_threaded_update_system) |
| 49 |
.add_systems(CustomStartup, custom_startup_system) |
| 50 |
.add_systems(PreStartup, pre_startup_system) |
| 51 |
.add_systems(Startup, startup_system) |
| 52 |
.add_systems(First, first_system) |
| 53 |
.add_systems(Update, update_system) |
| 54 |
.add_systems(Last, last_system) |
| 55 |
.run(); |
| 56 |
} |
| 57 |
|
| 58 |
fn pre_startup_system() { |
| 59 |
println!("Pre Startup"); |
| 60 |
} |
| 61 |
|
| 62 |
fn startup_system() { |
| 63 |
println!("Startup"); |
| 64 |
} |
| 65 |
|
| 66 |
fn custom_startup_system() { |
| 67 |
println!("Custom Startup"); |
| 68 |
} |
| 69 |
|
| 70 |
fn first_system() { |
| 71 |
println!("First"); |
| 72 |
} |
| 73 |
|
| 74 |
fn update_system() { |
| 75 |
println!("Update"); |
| 76 |
} |
| 77 |
|
| 78 |
fn single_threaded_update_system() { |
| 79 |
println!("Single Threaded Update"); |
| 80 |
} |
| 81 |
|
| 82 |
fn last_system() { |
| 83 |
println!("Last"); |
| 84 |
} |