mirror of
https://github.com/bevyengine/bevy
synced 2024-11-25 06:00:20 +00:00
Down with the system! (#2496)
# Objective - Remove all the `.system()` possible. - Check for remaining missing cases. ## Solution - Remove all `.system()`, fix compile errors - 32 calls to `.system()` remains, mostly internals, the few others should be removed after #2446
This commit is contained in:
parent
234b2efa71
commit
b724a0f586
125 changed files with 544 additions and 732 deletions
|
@ -1,7 +1,7 @@
|
||||||
use bevy::ecs::{
|
use bevy::ecs::{
|
||||||
world::World,
|
|
||||||
schedule::{Stage, SystemStage},
|
schedule::{Stage, SystemStage},
|
||||||
system::{IntoSystem, Query},
|
system::{IntoSystem, Query},
|
||||||
|
world::World,
|
||||||
};
|
};
|
||||||
use criterion::{criterion_group, criterion_main, Criterion};
|
use criterion::{criterion_group, criterion_main, Criterion};
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ fn empty_systems(criterion: &mut Criterion) {
|
||||||
for amount in 0..5 {
|
for amount in 0..5 {
|
||||||
let mut stage = SystemStage::parallel();
|
let mut stage = SystemStage::parallel();
|
||||||
for _ in 0..amount {
|
for _ in 0..amount {
|
||||||
stage.add_system(empty.system());
|
stage.add_system(empty);
|
||||||
}
|
}
|
||||||
run_stage(&mut stage, &mut world);
|
run_stage(&mut stage, &mut world);
|
||||||
group.bench_function(&format!("{:03}_systems", amount), |bencher| {
|
group.bench_function(&format!("{:03}_systems", amount), |bencher| {
|
||||||
|
@ -42,11 +42,11 @@ fn empty_systems(criterion: &mut Criterion) {
|
||||||
let mut stage = SystemStage::parallel();
|
let mut stage = SystemStage::parallel();
|
||||||
for _ in 0..amount {
|
for _ in 0..amount {
|
||||||
stage
|
stage
|
||||||
.add_system(empty.system())
|
.add_system(empty)
|
||||||
.add_system(empty.system())
|
.add_system(empty)
|
||||||
.add_system(empty.system())
|
.add_system(empty)
|
||||||
.add_system(empty.system())
|
.add_system(empty)
|
||||||
.add_system(empty.system());
|
.add_system(empty);
|
||||||
}
|
}
|
||||||
run_stage(&mut stage, &mut world);
|
run_stage(&mut stage, &mut world);
|
||||||
group.bench_function(&format!("{:03}_systems", 5 * amount), |bencher| {
|
group.bench_function(&format!("{:03}_systems", 5 * amount), |bencher| {
|
||||||
|
@ -85,15 +85,9 @@ fn busy_systems(criterion: &mut Criterion) {
|
||||||
world.spawn_batch((0..ENTITY_BUNCH).map(|_| (A(0.0), B(0.0), C(0.0), E(0.0))));
|
world.spawn_batch((0..ENTITY_BUNCH).map(|_| (A(0.0), B(0.0), C(0.0), E(0.0))));
|
||||||
for system_amount in 0..5 {
|
for system_amount in 0..5 {
|
||||||
let mut stage = SystemStage::parallel();
|
let mut stage = SystemStage::parallel();
|
||||||
stage
|
stage.add_system(ab).add_system(cd).add_system(ce);
|
||||||
.add_system(ab.system())
|
|
||||||
.add_system(cd.system())
|
|
||||||
.add_system(ce.system());
|
|
||||||
for _ in 0..system_amount {
|
for _ in 0..system_amount {
|
||||||
stage
|
stage.add_system(ab).add_system(cd).add_system(ce);
|
||||||
.add_system(ab.system())
|
|
||||||
.add_system(cd.system())
|
|
||||||
.add_system(ce.system());
|
|
||||||
}
|
}
|
||||||
run_stage(&mut stage, &mut world);
|
run_stage(&mut stage, &mut world);
|
||||||
group.bench_function(
|
group.bench_function(
|
||||||
|
@ -142,15 +136,9 @@ fn contrived(criterion: &mut Criterion) {
|
||||||
world.spawn_batch((0..ENTITY_BUNCH).map(|_| (C(0.0), D(0.0))));
|
world.spawn_batch((0..ENTITY_BUNCH).map(|_| (C(0.0), D(0.0))));
|
||||||
for system_amount in 0..5 {
|
for system_amount in 0..5 {
|
||||||
let mut stage = SystemStage::parallel();
|
let mut stage = SystemStage::parallel();
|
||||||
stage
|
stage.add_system(s_0).add_system(s_1).add_system(s_2);
|
||||||
.add_system(s_0.system())
|
|
||||||
.add_system(s_1.system())
|
|
||||||
.add_system(s_2.system());
|
|
||||||
for _ in 0..system_amount {
|
for _ in 0..system_amount {
|
||||||
stage
|
stage.add_system(s_0).add_system(s_1).add_system(s_2);
|
||||||
.add_system(s_0.system())
|
|
||||||
.add_system(s_1.system())
|
|
||||||
.add_system(s_2.system());
|
|
||||||
}
|
}
|
||||||
run_stage(&mut stage, &mut world);
|
run_stage(&mut stage, &mut world);
|
||||||
group.bench_function(
|
group.bench_function(
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use crate::{CoreStage, Events, Plugin, PluginGroup, PluginGroupBuilder, StartupStage};
|
use crate::{CoreStage, Events, Plugin, PluginGroup, PluginGroupBuilder, StartupStage};
|
||||||
use bevy_ecs::{
|
use bevy_ecs::{
|
||||||
component::{Component, ComponentDescriptor},
|
component::{Component, ComponentDescriptor},
|
||||||
prelude::{FromWorld, IntoExclusiveSystem, IntoSystem},
|
prelude::{FromWorld, IntoExclusiveSystem},
|
||||||
schedule::{
|
schedule::{
|
||||||
IntoSystemDescriptor, RunOnce, Schedule, Stage, StageLabel, State, SystemSet, SystemStage,
|
IntoSystemDescriptor, RunOnce, Schedule, Stage, StageLabel, State, SystemSet, SystemStage,
|
||||||
},
|
},
|
||||||
|
@ -28,7 +28,7 @@ use bevy_utils::tracing::info_span;
|
||||||
///
|
///
|
||||||
/// fn main() {
|
/// fn main() {
|
||||||
/// App::new()
|
/// App::new()
|
||||||
/// .add_system(hello_world_system.system())
|
/// .add_system(hello_world_system)
|
||||||
/// .run();
|
/// .run();
|
||||||
/// }
|
/// }
|
||||||
///
|
///
|
||||||
|
@ -180,7 +180,7 @@ impl App {
|
||||||
/// Adds a system that runs every time `app.update()` is called by the runner
|
/// Adds a system that runs every time `app.update()` is called by the runner
|
||||||
///
|
///
|
||||||
/// Systems are the main building block in the Bevy ECS app model. You can define
|
/// Systems are the main building block in the Bevy ECS app model. You can define
|
||||||
/// normal rust functions, and call `.system()` to make them be Bevy systems.
|
/// normal rust functions, and use them as a Bevy system.
|
||||||
///
|
///
|
||||||
/// System functions can have parameters, through which one can query and
|
/// System functions can have parameters, through which one can query and
|
||||||
/// mutate Bevy ECS states.
|
/// mutate Bevy ECS states.
|
||||||
|
@ -201,7 +201,7 @@ impl App {
|
||||||
/// }
|
/// }
|
||||||
///
|
///
|
||||||
/// App::new()
|
/// App::new()
|
||||||
/// .add_system(my_system.system());
|
/// .add_system(my_system);
|
||||||
/// ```
|
/// ```
|
||||||
pub fn add_system<Params>(&mut self, system: impl IntoSystemDescriptor<Params>) -> &mut Self {
|
pub fn add_system<Params>(&mut self, system: impl IntoSystemDescriptor<Params>) -> &mut Self {
|
||||||
self.add_system_to_stage(CoreStage::Update, system)
|
self.add_system_to_stage(CoreStage::Update, system)
|
||||||
|
@ -248,7 +248,7 @@ impl App {
|
||||||
/// }
|
/// }
|
||||||
///
|
///
|
||||||
/// App::new()
|
/// App::new()
|
||||||
/// .add_startup_system(my_startup_system.system());
|
/// .add_startup_system(my_startup_system);
|
||||||
/// ```
|
/// ```
|
||||||
pub fn add_startup_system<Params>(
|
pub fn add_startup_system<Params>(
|
||||||
&mut self,
|
&mut self,
|
||||||
|
@ -335,7 +335,7 @@ impl App {
|
||||||
T: Component,
|
T: Component,
|
||||||
{
|
{
|
||||||
self.insert_resource(Events::<T>::default())
|
self.insert_resource(Events::<T>::default())
|
||||||
.add_system_to_stage(CoreStage::First, Events::<T>::update_system.system())
|
.add_system_to_stage(CoreStage::First, Events::<T>::update_system)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Inserts a resource to the current [App] and overwrites any resource previously added of the same type.
|
/// Inserts a resource to the current [App] and overwrites any resource previously added of the same type.
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
|
|
||||||
use crate::{app::AppExit, App};
|
use crate::{app::AppExit, App};
|
||||||
use bevy_ecs::system::IntoSystem;
|
|
||||||
|
|
||||||
/// Configuration for automated testing on CI
|
/// Configuration for automated testing on CI
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize)]
|
||||||
|
@ -32,7 +31,7 @@ pub(crate) fn setup_app(app_builder: &mut App) -> &mut App {
|
||||||
.expect("error deserializing CI testing configuration file");
|
.expect("error deserializing CI testing configuration file");
|
||||||
app_builder
|
app_builder
|
||||||
.insert_resource(config)
|
.insert_resource(config)
|
||||||
.add_system(ci_testing_exit_after.system());
|
.add_system(ci_testing_exit_after);
|
||||||
|
|
||||||
app_builder
|
app_builder
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,10 +3,7 @@ use crate::{
|
||||||
RefChange,
|
RefChange,
|
||||||
};
|
};
|
||||||
use bevy_app::{App, EventWriter, Events};
|
use bevy_app::{App, EventWriter, Events};
|
||||||
use bevy_ecs::{
|
use bevy_ecs::{system::ResMut, world::FromWorld};
|
||||||
system::{IntoSystem, ResMut},
|
|
||||||
world::FromWorld,
|
|
||||||
};
|
|
||||||
use bevy_utils::HashMap;
|
use bevy_utils::HashMap;
|
||||||
use crossbeam_channel::Sender;
|
use crossbeam_channel::Sender;
|
||||||
use std::fmt::Debug;
|
use std::fmt::Debug;
|
||||||
|
@ -217,14 +214,8 @@ impl AddAsset for App {
|
||||||
};
|
};
|
||||||
|
|
||||||
self.insert_resource(assets)
|
self.insert_resource(assets)
|
||||||
.add_system_to_stage(
|
.add_system_to_stage(AssetStage::AssetEvents, Assets::<T>::asset_event_system)
|
||||||
AssetStage::AssetEvents,
|
.add_system_to_stage(AssetStage::LoadAssets, update_asset_storage_system::<T>)
|
||||||
Assets::<T>::asset_event_system.system(),
|
|
||||||
)
|
|
||||||
.add_system_to_stage(
|
|
||||||
AssetStage::LoadAssets,
|
|
||||||
update_asset_storage_system::<T>.system(),
|
|
||||||
)
|
|
||||||
.register_type::<Handle<T>>()
|
.register_type::<Handle<T>>()
|
||||||
.add_event::<AssetEvent<T>>()
|
.add_event::<AssetEvent<T>>()
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use crate::{Asset, Assets};
|
use crate::{Asset, Assets};
|
||||||
use bevy_app::prelude::*;
|
use bevy_app::prelude::*;
|
||||||
use bevy_diagnostic::{Diagnostic, DiagnosticId, Diagnostics, MAX_DIAGNOSTIC_NAME_WIDTH};
|
use bevy_diagnostic::{Diagnostic, DiagnosticId, Diagnostics, MAX_DIAGNOSTIC_NAME_WIDTH};
|
||||||
use bevy_ecs::system::{IntoSystem, Res, ResMut};
|
use bevy_ecs::system::{Res, ResMut};
|
||||||
|
|
||||||
/// Adds "asset count" diagnostic to an App
|
/// Adds "asset count" diagnostic to an App
|
||||||
pub struct AssetCountDiagnosticsPlugin<T: Asset> {
|
pub struct AssetCountDiagnosticsPlugin<T: Asset> {
|
||||||
|
@ -18,8 +18,8 @@ impl<T: Asset> Default for AssetCountDiagnosticsPlugin<T> {
|
||||||
|
|
||||||
impl<T: Asset> Plugin for AssetCountDiagnosticsPlugin<T> {
|
impl<T: Asset> Plugin for AssetCountDiagnosticsPlugin<T> {
|
||||||
fn build(&self, app: &mut App) {
|
fn build(&self, app: &mut App) {
|
||||||
app.add_startup_system(Self::setup_system.system())
|
app.add_startup_system(Self::setup_system)
|
||||||
.add_system(Self::diagnostic_system.system());
|
.add_system(Self::diagnostic_system);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,10 +27,7 @@ pub use loader::*;
|
||||||
pub use path::*;
|
pub use path::*;
|
||||||
|
|
||||||
use bevy_app::{prelude::Plugin, App};
|
use bevy_app::{prelude::Plugin, App};
|
||||||
use bevy_ecs::{
|
use bevy_ecs::schedule::{StageLabel, SystemStage};
|
||||||
schedule::{StageLabel, SystemStage},
|
|
||||||
system::IntoSystem,
|
|
||||||
};
|
|
||||||
use bevy_tasks::IoTaskPool;
|
use bevy_tasks::IoTaskPool;
|
||||||
|
|
||||||
/// The names of asset stages in an App Schedule
|
/// The names of asset stages in an App Schedule
|
||||||
|
@ -106,16 +103,13 @@ impl Plugin for AssetPlugin {
|
||||||
.register_type::<HandleId>()
|
.register_type::<HandleId>()
|
||||||
.add_system_to_stage(
|
.add_system_to_stage(
|
||||||
bevy_app::CoreStage::PreUpdate,
|
bevy_app::CoreStage::PreUpdate,
|
||||||
asset_server::free_unused_assets_system.system(),
|
asset_server::free_unused_assets_system,
|
||||||
);
|
);
|
||||||
|
|
||||||
#[cfg(all(
|
#[cfg(all(
|
||||||
feature = "filesystem_watcher",
|
feature = "filesystem_watcher",
|
||||||
all(not(target_arch = "wasm32"), not(target_os = "android"))
|
all(not(target_arch = "wasm32"), not(target_os = "android"))
|
||||||
))]
|
))]
|
||||||
app.add_system_to_stage(
|
app.add_system_to_stage(AssetStage::LoadAssets, io::filesystem_watcher_system);
|
||||||
AssetStage::LoadAssets,
|
|
||||||
io::filesystem_watcher_system.system(),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -123,7 +123,6 @@ pub(crate) fn entity_labels_system(
|
||||||
mod tests {
|
mod tests {
|
||||||
use bevy_ecs::{
|
use bevy_ecs::{
|
||||||
schedule::{Schedule, Stage, SystemStage},
|
schedule::{Schedule, Stage, SystemStage},
|
||||||
system::IntoSystem,
|
|
||||||
world::World,
|
world::World,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -134,7 +133,7 @@ mod tests {
|
||||||
world.insert_resource(EntityLabels::default());
|
world.insert_resource(EntityLabels::default());
|
||||||
let mut schedule = Schedule::default();
|
let mut schedule = Schedule::default();
|
||||||
schedule.add_stage("test", SystemStage::single_threaded());
|
schedule.add_stage("test", SystemStage::single_threaded());
|
||||||
schedule.add_system_to_stage("test", entity_labels_system.system());
|
schedule.add_system_to_stage("test", entity_labels_system);
|
||||||
(world, schedule)
|
(world, schedule)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ use bevy_app::prelude::*;
|
||||||
use bevy_ecs::{
|
use bevy_ecs::{
|
||||||
entity::Entity,
|
entity::Entity,
|
||||||
schedule::{ExclusiveSystemDescriptorCoercion, SystemLabel},
|
schedule::{ExclusiveSystemDescriptorCoercion, SystemLabel},
|
||||||
system::{IntoExclusiveSystem, IntoSystem},
|
system::IntoExclusiveSystem,
|
||||||
};
|
};
|
||||||
use bevy_utils::HashSet;
|
use bevy_utils::HashSet;
|
||||||
use std::ops::Range;
|
use std::ops::Range;
|
||||||
|
@ -62,8 +62,8 @@ impl Plugin for CorePlugin {
|
||||||
CoreStage::First,
|
CoreStage::First,
|
||||||
time_system.exclusive_system().label(CoreSystem::Time),
|
time_system.exclusive_system().label(CoreSystem::Time),
|
||||||
)
|
)
|
||||||
.add_startup_system_to_stage(StartupStage::PostStartup, entity_labels_system.system())
|
.add_startup_system_to_stage(StartupStage::PostStartup, entity_labels_system)
|
||||||
.add_system_to_stage(CoreStage::PostUpdate, entity_labels_system.system());
|
.add_system_to_stage(CoreStage::PostUpdate, entity_labels_system);
|
||||||
|
|
||||||
register_rust_types(app);
|
register_rust_types(app);
|
||||||
register_math_types(app);
|
register_math_types(app);
|
||||||
|
|
|
@ -4,7 +4,7 @@ use bevy_ecs::{
|
||||||
component::ComponentId,
|
component::ComponentId,
|
||||||
query::Access,
|
query::Access,
|
||||||
schedule::ShouldRun,
|
schedule::ShouldRun,
|
||||||
system::{IntoSystem, Local, Res, ResMut, System, SystemId},
|
system::{ConfigurableSystem, IntoSystem, Local, Res, ResMut, System, SystemId},
|
||||||
world::World,
|
world::World,
|
||||||
};
|
};
|
||||||
use bevy_utils::HashMap;
|
use bevy_utils::HashMap;
|
||||||
|
@ -179,11 +179,8 @@ impl System for FixedTimestep {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn initialize(&mut self, world: &mut World) {
|
fn initialize(&mut self, world: &mut World) {
|
||||||
self.internal_system = Box::new(
|
self.internal_system =
|
||||||
Self::prepare_system
|
Box::new(Self::prepare_system.config(|c| c.0 = Some(self.state.clone())));
|
||||||
.system()
|
|
||||||
.config(|c| c.0 = Some(self.state.clone())),
|
|
||||||
);
|
|
||||||
self.internal_system.initialize(world);
|
self.internal_system.initialize(world);
|
||||||
if let Some(ref label) = self.state.label {
|
if let Some(ref label) = self.state.label {
|
||||||
let mut fixed_timesteps = world.get_resource_mut::<FixedTimesteps>().unwrap();
|
let mut fixed_timesteps = world.get_resource_mut::<FixedTimesteps>().unwrap();
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use bevy_app::{App, Plugin};
|
use bevy_app::{App, Plugin};
|
||||||
use bevy_ecs::{
|
use bevy_ecs::{
|
||||||
system::{IntoExclusiveSystem, IntoSystem, ResMut},
|
system::{IntoExclusiveSystem, ResMut},
|
||||||
world::World,
|
world::World,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ pub struct EntityCountDiagnosticsPlugin;
|
||||||
|
|
||||||
impl Plugin for EntityCountDiagnosticsPlugin {
|
impl Plugin for EntityCountDiagnosticsPlugin {
|
||||||
fn build(&self, app: &mut App) {
|
fn build(&self, app: &mut App) {
|
||||||
app.add_startup_system(Self::setup_system.system())
|
app.add_startup_system(Self::setup_system)
|
||||||
.add_system(Self::diagnostic_system.exclusive_system());
|
.add_system(Self::diagnostic_system.exclusive_system());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use crate::{Diagnostic, DiagnosticId, Diagnostics};
|
use crate::{Diagnostic, DiagnosticId, Diagnostics};
|
||||||
use bevy_app::prelude::*;
|
use bevy_app::prelude::*;
|
||||||
use bevy_core::Time;
|
use bevy_core::Time;
|
||||||
use bevy_ecs::system::{IntoSystem, Res, ResMut};
|
use bevy_ecs::system::{Res, ResMut};
|
||||||
|
|
||||||
/// Adds "frame time" diagnostic to an App, specifically "frame time", "fps" and "frame count"
|
/// Adds "frame time" diagnostic to an App, specifically "frame time", "fps" and "frame count"
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
|
@ -13,9 +13,9 @@ pub struct FrameTimeDiagnosticsState {
|
||||||
|
|
||||||
impl Plugin for FrameTimeDiagnosticsPlugin {
|
impl Plugin for FrameTimeDiagnosticsPlugin {
|
||||||
fn build(&self, app: &mut bevy_app::App) {
|
fn build(&self, app: &mut bevy_app::App) {
|
||||||
app.add_startup_system(Self::setup_system.system())
|
app.add_startup_system(Self::setup_system)
|
||||||
.insert_resource(FrameTimeDiagnosticsState { frame_count: 0.0 })
|
.insert_resource(FrameTimeDiagnosticsState { frame_count: 0.0 })
|
||||||
.add_system(Self::diagnostic_system.system());
|
.add_system(Self::diagnostic_system);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use super::{Diagnostic, DiagnosticId, Diagnostics};
|
use super::{Diagnostic, DiagnosticId, Diagnostics};
|
||||||
use bevy_app::prelude::*;
|
use bevy_app::prelude::*;
|
||||||
use bevy_core::{Time, Timer};
|
use bevy_core::{Time, Timer};
|
||||||
use bevy_ecs::system::{IntoSystem, Res, ResMut};
|
use bevy_ecs::system::{Res, ResMut};
|
||||||
use bevy_log::{debug, info};
|
use bevy_log::{debug, info};
|
||||||
use bevy_utils::Duration;
|
use bevy_utils::Duration;
|
||||||
|
|
||||||
|
@ -36,12 +36,9 @@ impl Plugin for LogDiagnosticsPlugin {
|
||||||
});
|
});
|
||||||
|
|
||||||
if self.debug {
|
if self.debug {
|
||||||
app.add_system_to_stage(
|
app.add_system_to_stage(CoreStage::PostUpdate, Self::log_diagnostics_debug_system);
|
||||||
CoreStage::PostUpdate,
|
|
||||||
Self::log_diagnostics_debug_system.system(),
|
|
||||||
);
|
|
||||||
} else {
|
} else {
|
||||||
app.add_system_to_stage(CoreStage::PostUpdate, Self::log_diagnostics_system.system());
|
app.add_system_to_stage(CoreStage::PostUpdate, Self::log_diagnostics_system);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -131,7 +131,7 @@ fn main() {
|
||||||
// Add a Stage to our schedule. Each Stage in a schedule runs all of its systems
|
// Add a Stage to our schedule. Each Stage in a schedule runs all of its systems
|
||||||
// before moving on to the next Stage
|
// before moving on to the next Stage
|
||||||
schedule.add_stage("update", SystemStage::parallel()
|
schedule.add_stage("update", SystemStage::parallel()
|
||||||
.with_system(movement.system())
|
.with_system(movement)
|
||||||
);
|
);
|
||||||
|
|
||||||
// Run the schedule once. If your app has a "loop", you would run this once per loop
|
// Run the schedule once. If your app has a "loop", you would run this once per loop
|
||||||
|
|
|
@ -24,15 +24,11 @@ fn main() {
|
||||||
|
|
||||||
// Add systems to the Stage to execute our app logic
|
// Add systems to the Stage to execute our app logic
|
||||||
// We can label our systems to force a specific run-order between some of them
|
// We can label our systems to force a specific run-order between some of them
|
||||||
update.add_system(spawn_entities.system().label(SimulationSystem::Spawn));
|
update.add_system(spawn_entities.label(SimulationSystem::Spawn));
|
||||||
update.add_system(
|
update.add_system(print_counter_when_changed.after(SimulationSystem::Spawn));
|
||||||
print_counter_when_changed
|
update.add_system(age_all_entities.label(SimulationSystem::Age));
|
||||||
.system()
|
update.add_system(remove_old_entities.after(SimulationSystem::Age));
|
||||||
.after(SimulationSystem::Spawn),
|
update.add_system(print_changed_entities.after(SimulationSystem::Age));
|
||||||
);
|
|
||||||
update.add_system(age_all_entities.system().label(SimulationSystem::Age));
|
|
||||||
update.add_system(remove_old_entities.system().after(SimulationSystem::Age));
|
|
||||||
update.add_system(print_changed_entities.system().after(SimulationSystem::Age));
|
|
||||||
// Add the Stage with our systems to the Schedule
|
// Add the Stage with our systems to the Schedule
|
||||||
schedule.add_stage("update", update);
|
schedule.add_stage("update", update);
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@ fn main() {
|
||||||
// Setup a schedule and stage to add a system querying for the just spawned entities
|
// Setup a schedule and stage to add a system querying for the just spawned entities
|
||||||
let mut schedule = Schedule::default();
|
let mut schedule = Schedule::default();
|
||||||
let mut update = SystemStage::parallel();
|
let mut update = SystemStage::parallel();
|
||||||
update.add_system(query_entities.system());
|
update.add_system(query_entities);
|
||||||
schedule.add_stage("update", update);
|
schedule.add_stage("update", update);
|
||||||
|
|
||||||
schedule.run(&mut world);
|
schedule.run(&mut world);
|
||||||
|
|
|
@ -16,13 +16,13 @@ fn main() {
|
||||||
// called "second". In "first" we update the events and in "second" we run our systems
|
// called "second". In "first" we update the events and in "second" we run our systems
|
||||||
// sending and receiving events.
|
// sending and receiving events.
|
||||||
let mut first = SystemStage::parallel();
|
let mut first = SystemStage::parallel();
|
||||||
first.add_system(Events::<MyEvent>::update_system.system());
|
first.add_system(Events::<MyEvent>::update_system);
|
||||||
schedule.add_stage("first", first);
|
schedule.add_stage("first", first);
|
||||||
|
|
||||||
// Add systems sending and receiving events to a "second" Stage
|
// Add systems sending and receiving events to a "second" Stage
|
||||||
let mut second = SystemStage::parallel();
|
let mut second = SystemStage::parallel();
|
||||||
second.add_system(sending_system.system().label(EventSystem::Sending));
|
second.add_system(sending_system.label(EventSystem::Sending));
|
||||||
second.add_system(receiving_system.system().after(EventSystem::Sending));
|
second.add_system(receiving_system.after(EventSystem::Sending));
|
||||||
|
|
||||||
// Run the "second" Stage after the "first" Stage, so our Events always get updated before we use them
|
// Run the "second" Stage after the "first" Stage, so our Events always get updated before we use them
|
||||||
schedule.add_stage_after("first", "second", second);
|
schedule.add_stage_after("first", "second", second);
|
||||||
|
|
|
@ -16,8 +16,8 @@ fn main() {
|
||||||
let mut update = SystemStage::parallel();
|
let mut update = SystemStage::parallel();
|
||||||
|
|
||||||
// Add systems to increase the counter and to print out the current value
|
// Add systems to increase the counter and to print out the current value
|
||||||
update.add_system(increase_counter.system().label(CounterSystem::Increase));
|
update.add_system(increase_counter.label(CounterSystem::Increase));
|
||||||
update.add_system(print_counter.system().after(CounterSystem::Increase));
|
update.add_system(print_counter.after(CounterSystem::Increase));
|
||||||
schedule.add_stage("update", update);
|
schedule.add_stage("update", update);
|
||||||
|
|
||||||
for iteration in 1..=10 {
|
for iteration in 1..=10 {
|
||||||
|
|
|
@ -316,7 +316,7 @@ mod tests {
|
||||||
use super::SchedulingEvent::{self, *};
|
use super::SchedulingEvent::{self, *};
|
||||||
use crate::{
|
use crate::{
|
||||||
schedule::{SingleThreadedExecutor, Stage, SystemStage},
|
schedule::{SingleThreadedExecutor, Stage, SystemStage},
|
||||||
system::{IntoSystem, NonSend, Query, Res, ResMut},
|
system::{NonSend, Query, Res, ResMut},
|
||||||
world::World,
|
world::World,
|
||||||
};
|
};
|
||||||
use async_channel::Receiver;
|
use async_channel::Receiver;
|
||||||
|
@ -338,9 +338,9 @@ mod tests {
|
||||||
let mut world = World::new();
|
let mut world = World::new();
|
||||||
fn wants_for_nothing() {}
|
fn wants_for_nothing() {}
|
||||||
let mut stage = SystemStage::parallel()
|
let mut stage = SystemStage::parallel()
|
||||||
.with_system(wants_for_nothing.system())
|
.with_system(wants_for_nothing)
|
||||||
.with_system(wants_for_nothing.system())
|
.with_system(wants_for_nothing)
|
||||||
.with_system(wants_for_nothing.system());
|
.with_system(wants_for_nothing);
|
||||||
stage.run(&mut world);
|
stage.run(&mut world);
|
||||||
stage.run(&mut world);
|
stage.run(&mut world);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
|
@ -356,24 +356,24 @@ mod tests {
|
||||||
fn wants_mut(_: ResMut<usize>) {}
|
fn wants_mut(_: ResMut<usize>) {}
|
||||||
fn wants_ref(_: Res<usize>) {}
|
fn wants_ref(_: Res<usize>) {}
|
||||||
let mut stage = SystemStage::parallel()
|
let mut stage = SystemStage::parallel()
|
||||||
.with_system(wants_mut.system())
|
.with_system(wants_mut)
|
||||||
.with_system(wants_mut.system());
|
.with_system(wants_mut);
|
||||||
stage.run(&mut world);
|
stage.run(&mut world);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
receive_events(&world),
|
receive_events(&world),
|
||||||
vec![StartedSystems(1), StartedSystems(1),]
|
vec![StartedSystems(1), StartedSystems(1),]
|
||||||
);
|
);
|
||||||
let mut stage = SystemStage::parallel()
|
let mut stage = SystemStage::parallel()
|
||||||
.with_system(wants_mut.system())
|
.with_system(wants_mut)
|
||||||
.with_system(wants_ref.system());
|
.with_system(wants_ref);
|
||||||
stage.run(&mut world);
|
stage.run(&mut world);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
receive_events(&world),
|
receive_events(&world),
|
||||||
vec![StartedSystems(1), StartedSystems(1),]
|
vec![StartedSystems(1), StartedSystems(1),]
|
||||||
);
|
);
|
||||||
let mut stage = SystemStage::parallel()
|
let mut stage = SystemStage::parallel()
|
||||||
.with_system(wants_ref.system())
|
.with_system(wants_ref)
|
||||||
.with_system(wants_ref.system());
|
.with_system(wants_ref);
|
||||||
stage.run(&mut world);
|
stage.run(&mut world);
|
||||||
assert_eq!(receive_events(&world), vec![StartedSystems(2),]);
|
assert_eq!(receive_events(&world), vec![StartedSystems(2),]);
|
||||||
}
|
}
|
||||||
|
@ -385,24 +385,24 @@ mod tests {
|
||||||
fn wants_mut(_: Query<&mut usize>) {}
|
fn wants_mut(_: Query<&mut usize>) {}
|
||||||
fn wants_ref(_: Query<&usize>) {}
|
fn wants_ref(_: Query<&usize>) {}
|
||||||
let mut stage = SystemStage::parallel()
|
let mut stage = SystemStage::parallel()
|
||||||
.with_system(wants_mut.system())
|
.with_system(wants_mut)
|
||||||
.with_system(wants_mut.system());
|
.with_system(wants_mut);
|
||||||
stage.run(&mut world);
|
stage.run(&mut world);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
receive_events(&world),
|
receive_events(&world),
|
||||||
vec![StartedSystems(1), StartedSystems(1),]
|
vec![StartedSystems(1), StartedSystems(1),]
|
||||||
);
|
);
|
||||||
let mut stage = SystemStage::parallel()
|
let mut stage = SystemStage::parallel()
|
||||||
.with_system(wants_mut.system())
|
.with_system(wants_mut)
|
||||||
.with_system(wants_ref.system());
|
.with_system(wants_ref);
|
||||||
stage.run(&mut world);
|
stage.run(&mut world);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
receive_events(&world),
|
receive_events(&world),
|
||||||
vec![StartedSystems(1), StartedSystems(1),]
|
vec![StartedSystems(1), StartedSystems(1),]
|
||||||
);
|
);
|
||||||
let mut stage = SystemStage::parallel()
|
let mut stage = SystemStage::parallel()
|
||||||
.with_system(wants_ref.system())
|
.with_system(wants_ref)
|
||||||
.with_system(wants_ref.system());
|
.with_system(wants_ref);
|
||||||
stage.run(&mut world);
|
stage.run(&mut world);
|
||||||
assert_eq!(receive_events(&world), vec![StartedSystems(2),]);
|
assert_eq!(receive_events(&world), vec![StartedSystems(2),]);
|
||||||
let mut world = World::new();
|
let mut world = World::new();
|
||||||
|
@ -410,8 +410,8 @@ mod tests {
|
||||||
fn wants_mut_usize(_: Query<(&mut usize, &f32)>) {}
|
fn wants_mut_usize(_: Query<(&mut usize, &f32)>) {}
|
||||||
fn wants_mut_u32(_: Query<(&mut u32, &f32)>) {}
|
fn wants_mut_u32(_: Query<(&mut u32, &f32)>) {}
|
||||||
let mut stage = SystemStage::parallel()
|
let mut stage = SystemStage::parallel()
|
||||||
.with_system(wants_mut_usize.system())
|
.with_system(wants_mut_usize)
|
||||||
.with_system(wants_mut_u32.system());
|
.with_system(wants_mut_u32);
|
||||||
stage.run(&mut world);
|
stage.run(&mut world);
|
||||||
assert_eq!(receive_events(&world), vec![StartedSystems(2),]);
|
assert_eq!(receive_events(&world), vec![StartedSystems(2),]);
|
||||||
}
|
}
|
||||||
|
@ -426,12 +426,12 @@ mod tests {
|
||||||
}
|
}
|
||||||
fn empty() {}
|
fn empty() {}
|
||||||
let mut stage = SystemStage::parallel()
|
let mut stage = SystemStage::parallel()
|
||||||
.with_system(non_send.system())
|
.with_system(non_send)
|
||||||
.with_system(non_send.system())
|
.with_system(non_send)
|
||||||
.with_system(empty.system())
|
.with_system(empty)
|
||||||
.with_system(empty.system())
|
.with_system(empty)
|
||||||
.with_system(non_send.system())
|
.with_system(non_send)
|
||||||
.with_system(non_send.system());
|
.with_system(non_send);
|
||||||
stage.run(&mut world);
|
stage.run(&mut world);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
receive_events(&world),
|
receive_events(&world),
|
||||||
|
|
|
@ -22,10 +22,7 @@ pub use system_set::*;
|
||||||
|
|
||||||
use std::fmt::Debug;
|
use std::fmt::Debug;
|
||||||
|
|
||||||
use crate::{
|
use crate::{system::System, world::World};
|
||||||
system::{IntoSystem, System},
|
|
||||||
world::World,
|
|
||||||
};
|
|
||||||
use bevy_utils::HashMap;
|
use bevy_utils::HashMap;
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
|
@ -79,7 +76,7 @@ impl Schedule {
|
||||||
&mut self,
|
&mut self,
|
||||||
system: S,
|
system: S,
|
||||||
) -> &mut Self {
|
) -> &mut Self {
|
||||||
self.run_criteria.set(Box::new(system.system()));
|
self.run_criteria.set(Box::new(system));
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
use crate::{
|
use crate::{
|
||||||
component::ComponentId,
|
component::ComponentId,
|
||||||
|
prelude::IntoSystem,
|
||||||
schedule::{
|
schedule::{
|
||||||
graph_utils::{self, DependencyGraphError},
|
graph_utils::{self, DependencyGraphError},
|
||||||
BoxedRunCriteria, BoxedRunCriteriaLabel, BoxedSystemLabel, DuplicateLabelStrategy,
|
BoxedRunCriteria, BoxedRunCriteriaLabel, BoxedSystemLabel, DuplicateLabelStrategy,
|
||||||
|
@ -8,7 +9,6 @@ use crate::{
|
||||||
RunCriteriaDescriptor, RunCriteriaDescriptorOrLabel, RunCriteriaInner, ShouldRun,
|
RunCriteriaDescriptor, RunCriteriaDescriptorOrLabel, RunCriteriaInner, ShouldRun,
|
||||||
SingleThreadedExecutor, SystemContainer, SystemDescriptor, SystemSet,
|
SingleThreadedExecutor, SystemContainer, SystemDescriptor, SystemSet,
|
||||||
},
|
},
|
||||||
system::System,
|
|
||||||
world::{World, WorldId},
|
world::{World, WorldId},
|
||||||
};
|
};
|
||||||
use bevy_utils::{tracing::info, HashMap, HashSet};
|
use bevy_utils::{tracing::info, HashMap, HashSet};
|
||||||
|
@ -289,16 +289,19 @@ impl SystemStage {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn with_run_criteria<S: System<In = (), Out = ShouldRun>>(mut self, system: S) -> Self {
|
pub fn with_run_criteria<Param, S: IntoSystem<(), ShouldRun, Param>>(
|
||||||
self.set_run_criteria(system);
|
mut self,
|
||||||
|
system: S,
|
||||||
|
) -> Self {
|
||||||
|
self.set_run_criteria(system.system());
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_run_criteria<S: System<In = (), Out = ShouldRun>>(
|
pub fn set_run_criteria<Param, S: IntoSystem<(), ShouldRun, Param>>(
|
||||||
&mut self,
|
&mut self,
|
||||||
system: S,
|
system: S,
|
||||||
) -> &mut Self {
|
) -> &mut Self {
|
||||||
self.stage_run_criteria.set(Box::new(system));
|
self.stage_run_criteria.set(Box::new(system.system()));
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -905,14 +908,8 @@ mod tests {
|
||||||
move |world| world.get_resource_mut::<Vec<usize>>().unwrap().push(tag)
|
move |world| world.get_resource_mut::<Vec<usize>>().unwrap().push(tag)
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is silly. https://github.com/bevyengine/bevy/issues/1029
|
fn make_parallel(tag: usize) -> impl FnMut(ResMut<Vec<usize>>) {
|
||||||
macro_rules! make_parallel {
|
move |mut resource: ResMut<Vec<usize>>| resource.push(tag)
|
||||||
($tag:expr) => {{
|
|
||||||
fn parallel(mut resource: ResMut<Vec<usize>>) {
|
|
||||||
resource.push($tag)
|
|
||||||
}
|
|
||||||
parallel
|
|
||||||
}};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn every_other_time(mut has_ran: Local<bool>) -> ShouldRun {
|
fn every_other_time(mut has_ran: Local<bool>) -> ShouldRun {
|
||||||
|
@ -930,7 +927,7 @@ mod tests {
|
||||||
world.insert_resource(Vec::<usize>::new());
|
world.insert_resource(Vec::<usize>::new());
|
||||||
let mut stage = SystemStage::parallel()
|
let mut stage = SystemStage::parallel()
|
||||||
.with_system(make_exclusive(0).exclusive_system().at_start())
|
.with_system(make_exclusive(0).exclusive_system().at_start())
|
||||||
.with_system(make_parallel!(1).system())
|
.with_system(make_parallel(1))
|
||||||
.with_system(make_exclusive(2).exclusive_system().before_commands())
|
.with_system(make_exclusive(2).exclusive_system().before_commands())
|
||||||
.with_system(make_exclusive(3).exclusive_system().at_end());
|
.with_system(make_exclusive(3).exclusive_system().at_end());
|
||||||
stage.run(&mut world);
|
stage.run(&mut world);
|
||||||
|
@ -949,7 +946,7 @@ mod tests {
|
||||||
let mut stage = SystemStage::parallel()
|
let mut stage = SystemStage::parallel()
|
||||||
.with_system(make_exclusive(2).exclusive_system().before_commands())
|
.with_system(make_exclusive(2).exclusive_system().before_commands())
|
||||||
.with_system(make_exclusive(3).exclusive_system().at_end())
|
.with_system(make_exclusive(3).exclusive_system().at_end())
|
||||||
.with_system(make_parallel!(1).system())
|
.with_system(make_parallel(1))
|
||||||
.with_system(make_exclusive(0).exclusive_system().at_start());
|
.with_system(make_exclusive(0).exclusive_system().at_start());
|
||||||
stage.run(&mut world);
|
stage.run(&mut world);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
|
@ -965,10 +962,10 @@ mod tests {
|
||||||
|
|
||||||
world.get_resource_mut::<Vec<usize>>().unwrap().clear();
|
world.get_resource_mut::<Vec<usize>>().unwrap().clear();
|
||||||
let mut stage = SystemStage::parallel()
|
let mut stage = SystemStage::parallel()
|
||||||
.with_system(make_parallel!(2).exclusive_system().before_commands())
|
.with_system(make_parallel(2).exclusive_system().before_commands())
|
||||||
.with_system(make_parallel!(3).exclusive_system().at_end())
|
.with_system(make_parallel(3).exclusive_system().at_end())
|
||||||
.with_system(make_parallel!(1).system())
|
.with_system(make_parallel(1))
|
||||||
.with_system(make_parallel!(0).exclusive_system().at_start());
|
.with_system(make_parallel(0).exclusive_system().at_start());
|
||||||
stage.run(&mut world);
|
stage.run(&mut world);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
*world.get_resource::<Vec<usize>>().unwrap(),
|
*world.get_resource::<Vec<usize>>().unwrap(),
|
||||||
|
@ -1225,9 +1222,9 @@ mod tests {
|
||||||
let mut world = World::new();
|
let mut world = World::new();
|
||||||
world.insert_resource(Vec::<usize>::new());
|
world.insert_resource(Vec::<usize>::new());
|
||||||
let mut stage = SystemStage::parallel()
|
let mut stage = SystemStage::parallel()
|
||||||
.with_system(make_parallel!(1).system().after("0").label("1"))
|
.with_system(make_parallel(1).after("0").label("1"))
|
||||||
.with_system(make_parallel!(2).system().after("1"))
|
.with_system(make_parallel(2).after("1"))
|
||||||
.with_system(make_parallel!(0).system().label("0"));
|
.with_system(make_parallel(0).label("0"));
|
||||||
stage.run(&mut world);
|
stage.run(&mut world);
|
||||||
stage.set_executor(Box::new(SingleThreadedExecutor::default()));
|
stage.set_executor(Box::new(SingleThreadedExecutor::default()));
|
||||||
stage.run(&mut world);
|
stage.run(&mut world);
|
||||||
|
@ -1242,9 +1239,9 @@ mod tests {
|
||||||
let mut world = World::new();
|
let mut world = World::new();
|
||||||
world.insert_resource(Vec::<usize>::new());
|
world.insert_resource(Vec::<usize>::new());
|
||||||
let mut stage = SystemStage::parallel()
|
let mut stage = SystemStage::parallel()
|
||||||
.with_system(make_parallel!(1).system().label("1").before("2"))
|
.with_system(make_parallel(1).label("1").before("2"))
|
||||||
.with_system(make_parallel!(2).system().label("2"))
|
.with_system(make_parallel(2).label("2"))
|
||||||
.with_system(make_parallel!(0).system().before("1"));
|
.with_system(make_parallel(0).before("1"));
|
||||||
stage.run(&mut world);
|
stage.run(&mut world);
|
||||||
stage.set_executor(Box::new(SingleThreadedExecutor::default()));
|
stage.set_executor(Box::new(SingleThreadedExecutor::default()));
|
||||||
stage.run(&mut world);
|
stage.run(&mut world);
|
||||||
|
@ -1259,11 +1256,11 @@ mod tests {
|
||||||
let mut world = World::new();
|
let mut world = World::new();
|
||||||
world.insert_resource(Vec::<usize>::new());
|
world.insert_resource(Vec::<usize>::new());
|
||||||
let mut stage = SystemStage::parallel()
|
let mut stage = SystemStage::parallel()
|
||||||
.with_system(make_parallel!(2).system().label("2"))
|
.with_system(make_parallel(2).label("2"))
|
||||||
.with_system(make_parallel!(1).system().after("0").before("2"))
|
.with_system(make_parallel(1).after("0").before("2"))
|
||||||
.with_system(make_parallel!(0).system().label("0"))
|
.with_system(make_parallel(0).label("0"))
|
||||||
.with_system(make_parallel!(4).system().label("4"))
|
.with_system(make_parallel(4).label("4"))
|
||||||
.with_system(make_parallel!(3).system().after("2").before("4"));
|
.with_system(make_parallel(3).after("2").before("4"));
|
||||||
stage.run(&mut world);
|
stage.run(&mut world);
|
||||||
stage.set_executor(Box::new(SingleThreadedExecutor::default()));
|
stage.set_executor(Box::new(SingleThreadedExecutor::default()));
|
||||||
stage.run(&mut world);
|
stage.run(&mut world);
|
||||||
|
@ -1278,9 +1275,9 @@ mod tests {
|
||||||
let mut world = World::new();
|
let mut world = World::new();
|
||||||
world.insert_resource(Vec::<usize>::new());
|
world.insert_resource(Vec::<usize>::new());
|
||||||
let mut stage = SystemStage::parallel()
|
let mut stage = SystemStage::parallel()
|
||||||
.with_system(make_parallel!(1).system().label("first").after("0"))
|
.with_system(make_parallel(1).label("first").after("0"))
|
||||||
.with_system(make_parallel!(2).system().after("first"))
|
.with_system(make_parallel(2).after("first"))
|
||||||
.with_system(make_parallel!(0).system().label("first").label("0"));
|
.with_system(make_parallel(0).label("first").label("0"));
|
||||||
stage.run(&mut world);
|
stage.run(&mut world);
|
||||||
stage.set_executor(Box::new(SingleThreadedExecutor::default()));
|
stage.set_executor(Box::new(SingleThreadedExecutor::default()));
|
||||||
stage.run(&mut world);
|
stage.run(&mut world);
|
||||||
|
@ -1291,11 +1288,11 @@ mod tests {
|
||||||
|
|
||||||
world.get_resource_mut::<Vec<usize>>().unwrap().clear();
|
world.get_resource_mut::<Vec<usize>>().unwrap().clear();
|
||||||
let mut stage = SystemStage::parallel()
|
let mut stage = SystemStage::parallel()
|
||||||
.with_system(make_parallel!(2).system().after("01").label("2"))
|
.with_system(make_parallel(2).after("01").label("2"))
|
||||||
.with_system(make_parallel!(1).system().label("01").after("0"))
|
.with_system(make_parallel(1).label("01").after("0"))
|
||||||
.with_system(make_parallel!(0).system().label("01").label("0"))
|
.with_system(make_parallel(0).label("01").label("0"))
|
||||||
.with_system(make_parallel!(4).system().label("4"))
|
.with_system(make_parallel(4).label("4"))
|
||||||
.with_system(make_parallel!(3).system().after("2").before("4"));
|
.with_system(make_parallel(3).after("2").before("4"));
|
||||||
stage.run(&mut world);
|
stage.run(&mut world);
|
||||||
stage.set_executor(Box::new(SingleThreadedExecutor::default()));
|
stage.set_executor(Box::new(SingleThreadedExecutor::default()));
|
||||||
stage.run(&mut world);
|
stage.run(&mut world);
|
||||||
|
@ -1306,17 +1303,11 @@ mod tests {
|
||||||
|
|
||||||
world.get_resource_mut::<Vec<usize>>().unwrap().clear();
|
world.get_resource_mut::<Vec<usize>>().unwrap().clear();
|
||||||
let mut stage = SystemStage::parallel()
|
let mut stage = SystemStage::parallel()
|
||||||
.with_system(make_parallel!(2).system().label("234").label("2"))
|
.with_system(make_parallel(2).label("234").label("2"))
|
||||||
.with_system(make_parallel!(1).system().before("234").after("0"))
|
.with_system(make_parallel(1).before("234").after("0"))
|
||||||
.with_system(make_parallel!(0).system().label("0"))
|
.with_system(make_parallel(0).label("0"))
|
||||||
.with_system(make_parallel!(4).system().label("234").label("4"))
|
.with_system(make_parallel(4).label("234").label("4"))
|
||||||
.with_system(
|
.with_system(make_parallel(3).label("234").after("2").before("4"));
|
||||||
make_parallel!(3)
|
|
||||||
.system()
|
|
||||||
.label("234")
|
|
||||||
.after("2")
|
|
||||||
.before("4"),
|
|
||||||
);
|
|
||||||
stage.run(&mut world);
|
stage.run(&mut world);
|
||||||
stage.set_executor(Box::new(SingleThreadedExecutor::default()));
|
stage.set_executor(Box::new(SingleThreadedExecutor::default()));
|
||||||
stage.run(&mut world);
|
stage.run(&mut world);
|
||||||
|
@ -1332,24 +1323,22 @@ mod tests {
|
||||||
world.insert_resource(Vec::<usize>::new());
|
world.insert_resource(Vec::<usize>::new());
|
||||||
let mut stage = SystemStage::parallel()
|
let mut stage = SystemStage::parallel()
|
||||||
.with_system(
|
.with_system(
|
||||||
make_parallel!(2)
|
make_parallel(2)
|
||||||
.system()
|
|
||||||
.label("2")
|
.label("2")
|
||||||
.after("1")
|
.after("1")
|
||||||
.before("3")
|
.before("3")
|
||||||
.before("3"),
|
.before("3"),
|
||||||
)
|
)
|
||||||
.with_system(
|
.with_system(
|
||||||
make_parallel!(1)
|
make_parallel(1)
|
||||||
.system()
|
|
||||||
.label("1")
|
.label("1")
|
||||||
.after("0")
|
.after("0")
|
||||||
.after("0")
|
.after("0")
|
||||||
.before("2"),
|
.before("2"),
|
||||||
)
|
)
|
||||||
.with_system(make_parallel!(0).system().label("0").before("1"))
|
.with_system(make_parallel(0).label("0").before("1"))
|
||||||
.with_system(make_parallel!(4).system().label("4").after("3"))
|
.with_system(make_parallel(4).label("4").after("3"))
|
||||||
.with_system(make_parallel!(3).system().label("3").after("2").before("4"));
|
.with_system(make_parallel(3).label("3").after("2").before("4"));
|
||||||
stage.run(&mut world);
|
stage.run(&mut world);
|
||||||
for container in stage.parallel.iter() {
|
for container in stage.parallel.iter() {
|
||||||
assert!(container.dependencies().len() <= 1);
|
assert!(container.dependencies().len() <= 1);
|
||||||
|
@ -1367,14 +1356,14 @@ mod tests {
|
||||||
let mut world = World::new();
|
let mut world = World::new();
|
||||||
world.insert_resource(Vec::<usize>::new());
|
world.insert_resource(Vec::<usize>::new());
|
||||||
let mut stage = SystemStage::parallel()
|
let mut stage = SystemStage::parallel()
|
||||||
.with_system(make_parallel!(2).system().label("2"))
|
.with_system(make_parallel(2).label("2"))
|
||||||
.with_system_set(
|
.with_system_set(
|
||||||
SystemSet::new()
|
SystemSet::new()
|
||||||
.with_system(make_parallel!(0).system().label("0"))
|
.with_system(make_parallel(0).label("0"))
|
||||||
.with_system(make_parallel!(4).system().label("4"))
|
.with_system(make_parallel(4).label("4"))
|
||||||
.with_system(make_parallel!(3).system().after("2").before("4")),
|
.with_system(make_parallel(3).after("2").before("4")),
|
||||||
)
|
)
|
||||||
.with_system(make_parallel!(1).system().after("0").before("2"));
|
.with_system(make_parallel(1).after("0").before("2"));
|
||||||
stage.run(&mut world);
|
stage.run(&mut world);
|
||||||
stage.set_executor(Box::new(SingleThreadedExecutor::default()));
|
stage.set_executor(Box::new(SingleThreadedExecutor::default()));
|
||||||
stage.run(&mut world);
|
stage.run(&mut world);
|
||||||
|
@ -1391,12 +1380,11 @@ mod tests {
|
||||||
world.insert_resource(Vec::<usize>::new());
|
world.insert_resource(Vec::<usize>::new());
|
||||||
let mut stage = SystemStage::parallel()
|
let mut stage = SystemStage::parallel()
|
||||||
.with_system(
|
.with_system(
|
||||||
make_parallel!(0)
|
make_parallel(0)
|
||||||
.system()
|
|
||||||
.label("0")
|
.label("0")
|
||||||
.with_run_criteria(every_other_time),
|
.with_run_criteria(every_other_time),
|
||||||
)
|
)
|
||||||
.with_system(make_parallel!(1).system().after("0"));
|
.with_system(make_parallel(1).after("0"));
|
||||||
stage.run(&mut world);
|
stage.run(&mut world);
|
||||||
stage.run(&mut world);
|
stage.run(&mut world);
|
||||||
stage.set_executor(Box::new(SingleThreadedExecutor::default()));
|
stage.set_executor(Box::new(SingleThreadedExecutor::default()));
|
||||||
|
@ -1409,13 +1397,13 @@ mod tests {
|
||||||
|
|
||||||
world.get_resource_mut::<Vec<usize>>().unwrap().clear();
|
world.get_resource_mut::<Vec<usize>>().unwrap().clear();
|
||||||
let mut stage = SystemStage::parallel()
|
let mut stage = SystemStage::parallel()
|
||||||
.with_system(make_parallel!(0).system().before("1"))
|
.with_system(make_parallel(0).before("1"))
|
||||||
.with_system_set(
|
.with_system_set(
|
||||||
SystemSet::new()
|
SystemSet::new()
|
||||||
.with_run_criteria(every_other_time.system())
|
.with_run_criteria(every_other_time)
|
||||||
.with_system(make_parallel!(1).system().label("1")),
|
.with_system(make_parallel(1).label("1")),
|
||||||
)
|
)
|
||||||
.with_system(make_parallel!(2).system().after("1"));
|
.with_system(make_parallel(2).after("1"));
|
||||||
stage.run(&mut world);
|
stage.run(&mut world);
|
||||||
stage.run(&mut world);
|
stage.run(&mut world);
|
||||||
stage.set_executor(Box::new(SingleThreadedExecutor::default()));
|
stage.set_executor(Box::new(SingleThreadedExecutor::default()));
|
||||||
|
@ -1430,21 +1418,19 @@ mod tests {
|
||||||
world.get_resource_mut::<Vec<usize>>().unwrap().clear();
|
world.get_resource_mut::<Vec<usize>>().unwrap().clear();
|
||||||
let mut stage = SystemStage::parallel()
|
let mut stage = SystemStage::parallel()
|
||||||
.with_system_run_criteria(every_other_time.label("every other time"))
|
.with_system_run_criteria(every_other_time.label("every other time"))
|
||||||
.with_system(make_parallel!(0).system().before("1"))
|
.with_system(make_parallel(0).before("1"))
|
||||||
.with_system(
|
.with_system(
|
||||||
make_parallel!(1)
|
make_parallel(1)
|
||||||
.system()
|
|
||||||
.label("1")
|
.label("1")
|
||||||
.with_run_criteria("every other time"),
|
.with_run_criteria("every other time"),
|
||||||
)
|
)
|
||||||
.with_system(
|
.with_system(
|
||||||
make_parallel!(2)
|
make_parallel(2)
|
||||||
.system()
|
|
||||||
.label("2")
|
.label("2")
|
||||||
.after("1")
|
.after("1")
|
||||||
.with_run_criteria("every other time"),
|
.with_run_criteria("every other time"),
|
||||||
)
|
)
|
||||||
.with_system(make_parallel!(3).system().after("2"));
|
.with_system(make_parallel(3).after("2"));
|
||||||
stage.run(&mut world);
|
stage.run(&mut world);
|
||||||
stage.run(&mut world);
|
stage.run(&mut world);
|
||||||
stage.set_executor(Box::new(SingleThreadedExecutor::default()));
|
stage.set_executor(Box::new(SingleThreadedExecutor::default()));
|
||||||
|
@ -1466,34 +1452,26 @@ mod tests {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let mut stage = SystemStage::parallel()
|
let mut stage = SystemStage::parallel()
|
||||||
.with_system(make_parallel!(0).system().label("0"))
|
.with_system(make_parallel(0).label("0"))
|
||||||
.with_system(
|
.with_system(
|
||||||
make_parallel!(1)
|
make_parallel(1)
|
||||||
.system()
|
|
||||||
.label("1")
|
.label("1")
|
||||||
.after("0")
|
.after("0")
|
||||||
.with_run_criteria(every_other_time.system().label("every other time")),
|
.with_run_criteria(every_other_time.label("every other time")),
|
||||||
)
|
)
|
||||||
.with_system(
|
.with_system(
|
||||||
make_parallel!(2)
|
make_parallel(2)
|
||||||
.system()
|
|
||||||
.label("2")
|
.label("2")
|
||||||
.after("1")
|
.after("1")
|
||||||
.with_run_criteria(RunCriteria::pipe("every other time", eot_piped.system())),
|
.with_run_criteria(RunCriteria::pipe("every other time", eot_piped.system())),
|
||||||
)
|
)
|
||||||
.with_system(
|
.with_system(
|
||||||
make_parallel!(3)
|
make_parallel(3)
|
||||||
.system()
|
|
||||||
.label("3")
|
.label("3")
|
||||||
.after("2")
|
.after("2")
|
||||||
.with_run_criteria("every other time".pipe(eot_piped.system()).label("piped")),
|
.with_run_criteria("every other time".pipe(eot_piped.system()).label("piped")),
|
||||||
)
|
)
|
||||||
.with_system(
|
.with_system(make_parallel(4).after("3").with_run_criteria("piped"));
|
||||||
make_parallel!(4)
|
|
||||||
.system()
|
|
||||||
.after("3")
|
|
||||||
.with_run_criteria("piped"),
|
|
||||||
);
|
|
||||||
for _ in 0..4 {
|
for _ in 0..4 {
|
||||||
stage.run(&mut world);
|
stage.run(&mut world);
|
||||||
}
|
}
|
||||||
|
@ -1509,27 +1487,16 @@ mod tests {
|
||||||
|
|
||||||
// Discarding extra criteria with matching labels.
|
// Discarding extra criteria with matching labels.
|
||||||
world.get_resource_mut::<Vec<usize>>().unwrap().clear();
|
world.get_resource_mut::<Vec<usize>>().unwrap().clear();
|
||||||
let mut stage = SystemStage::parallel()
|
let mut stage =
|
||||||
.with_system(make_parallel!(0).system().before("1"))
|
SystemStage::parallel()
|
||||||
.with_system(
|
.with_system(make_parallel(0).before("1"))
|
||||||
make_parallel!(1).system().label("1").with_run_criteria(
|
.with_system(make_parallel(1).label("1").with_run_criteria(
|
||||||
every_other_time
|
every_other_time.label_discard_if_duplicate("every other time"),
|
||||||
.system()
|
))
|
||||||
.label_discard_if_duplicate("every other time"),
|
.with_system(make_parallel(2).label("2").after("1").with_run_criteria(
|
||||||
),
|
every_other_time.label_discard_if_duplicate("every other time"),
|
||||||
)
|
))
|
||||||
.with_system(
|
.with_system(make_parallel(3).after("2"));
|
||||||
make_parallel!(2)
|
|
||||||
.system()
|
|
||||||
.label("2")
|
|
||||||
.after("1")
|
|
||||||
.with_run_criteria(
|
|
||||||
every_other_time
|
|
||||||
.system()
|
|
||||||
.label_discard_if_duplicate("every other time"),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
.with_system(make_parallel!(3).system().after("2"));
|
|
||||||
stage.run(&mut world);
|
stage.run(&mut world);
|
||||||
stage.run(&mut world);
|
stage.run(&mut world);
|
||||||
stage.set_executor(Box::new(SingleThreadedExecutor::default()));
|
stage.set_executor(Box::new(SingleThreadedExecutor::default()));
|
||||||
|
@ -1547,8 +1514,8 @@ mod tests {
|
||||||
fn duplicate_run_criteria_label_panic() {
|
fn duplicate_run_criteria_label_panic() {
|
||||||
let mut world = World::new();
|
let mut world = World::new();
|
||||||
let mut stage = SystemStage::parallel()
|
let mut stage = SystemStage::parallel()
|
||||||
.with_system_run_criteria(every_other_time.system().label("every other time"))
|
.with_system_run_criteria(every_other_time.label("every other time"))
|
||||||
.with_system_run_criteria(every_other_time.system().label("every other time"));
|
.with_system_run_criteria(every_other_time.label("every other time"));
|
||||||
stage.run(&mut world);
|
stage.run(&mut world);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1557,8 +1524,7 @@ mod tests {
|
||||||
fn parallel_cycle_1() {
|
fn parallel_cycle_1() {
|
||||||
let mut world = World::new();
|
let mut world = World::new();
|
||||||
world.insert_resource(Vec::<usize>::new());
|
world.insert_resource(Vec::<usize>::new());
|
||||||
let mut stage =
|
let mut stage = SystemStage::parallel().with_system(make_parallel(0).label("0").after("0"));
|
||||||
SystemStage::parallel().with_system(make_parallel!(0).system().label("0").after("0"));
|
|
||||||
stage.run(&mut world);
|
stage.run(&mut world);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1568,8 +1534,8 @@ mod tests {
|
||||||
let mut world = World::new();
|
let mut world = World::new();
|
||||||
world.insert_resource(Vec::<usize>::new());
|
world.insert_resource(Vec::<usize>::new());
|
||||||
let mut stage = SystemStage::parallel()
|
let mut stage = SystemStage::parallel()
|
||||||
.with_system(make_parallel!(0).system().label("0").after("1"))
|
.with_system(make_parallel(0).label("0").after("1"))
|
||||||
.with_system(make_parallel!(1).system().label("1").after("0"));
|
.with_system(make_parallel(1).label("1").after("0"));
|
||||||
stage.run(&mut world);
|
stage.run(&mut world);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1580,9 +1546,9 @@ mod tests {
|
||||||
|
|
||||||
world.insert_resource(Vec::<usize>::new());
|
world.insert_resource(Vec::<usize>::new());
|
||||||
let mut stage = SystemStage::parallel()
|
let mut stage = SystemStage::parallel()
|
||||||
.with_system(make_parallel!(0).system().label("0"))
|
.with_system(make_parallel(0).label("0"))
|
||||||
.with_system(make_parallel!(1).system().after("0").before("2"))
|
.with_system(make_parallel(1).after("0").before("2"))
|
||||||
.with_system(make_parallel!(2).system().label("2").before("0"));
|
.with_system(make_parallel(2).label("2").before("0"));
|
||||||
stage.run(&mut world);
|
stage.run(&mut world);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1611,21 +1577,21 @@ mod tests {
|
||||||
let mut world = World::new();
|
let mut world = World::new();
|
||||||
|
|
||||||
let mut stage = SystemStage::parallel()
|
let mut stage = SystemStage::parallel()
|
||||||
.with_system(empty.system().label("0"))
|
.with_system(empty.label("0"))
|
||||||
.with_system(empty.system().label("1").after("0"))
|
.with_system(empty.label("1").after("0"))
|
||||||
.with_system(empty.system().label("2"))
|
.with_system(empty.label("2"))
|
||||||
.with_system(empty.system().label("3").after("2").before("4"))
|
.with_system(empty.label("3").after("2").before("4"))
|
||||||
.with_system(empty.system().label("4"));
|
.with_system(empty.label("4"));
|
||||||
stage.initialize_systems(&mut world);
|
stage.initialize_systems(&mut world);
|
||||||
stage.rebuild_orders_and_dependencies();
|
stage.rebuild_orders_and_dependencies();
|
||||||
assert_eq!(find_ambiguities(&stage.parallel).len(), 0);
|
assert_eq!(find_ambiguities(&stage.parallel).len(), 0);
|
||||||
|
|
||||||
let mut stage = SystemStage::parallel()
|
let mut stage = SystemStage::parallel()
|
||||||
.with_system(empty.system().label("0"))
|
.with_system(empty.label("0"))
|
||||||
.with_system(component.system().label("1").after("0"))
|
.with_system(component.label("1").after("0"))
|
||||||
.with_system(empty.system().label("2"))
|
.with_system(empty.label("2"))
|
||||||
.with_system(empty.system().label("3").after("2").before("4"))
|
.with_system(empty.label("3").after("2").before("4"))
|
||||||
.with_system(component.system().label("4"));
|
.with_system(component.label("4"));
|
||||||
stage.initialize_systems(&mut world);
|
stage.initialize_systems(&mut world);
|
||||||
stage.rebuild_orders_and_dependencies();
|
stage.rebuild_orders_and_dependencies();
|
||||||
let ambiguities = find_ambiguities_first_labels(&stage.parallel);
|
let ambiguities = find_ambiguities_first_labels(&stage.parallel);
|
||||||
|
@ -1636,11 +1602,11 @@ mod tests {
|
||||||
assert_eq!(ambiguities.len(), 1);
|
assert_eq!(ambiguities.len(), 1);
|
||||||
|
|
||||||
let mut stage = SystemStage::parallel()
|
let mut stage = SystemStage::parallel()
|
||||||
.with_system(empty.system().label("0"))
|
.with_system(empty.label("0"))
|
||||||
.with_system(resource.system().label("1").after("0"))
|
.with_system(resource.label("1").after("0"))
|
||||||
.with_system(empty.system().label("2"))
|
.with_system(empty.label("2"))
|
||||||
.with_system(empty.system().label("3").after("2").before("4"))
|
.with_system(empty.label("3").after("2").before("4"))
|
||||||
.with_system(resource.system().label("4"));
|
.with_system(resource.label("4"));
|
||||||
stage.initialize_systems(&mut world);
|
stage.initialize_systems(&mut world);
|
||||||
stage.rebuild_orders_and_dependencies();
|
stage.rebuild_orders_and_dependencies();
|
||||||
let ambiguities = find_ambiguities_first_labels(&stage.parallel);
|
let ambiguities = find_ambiguities_first_labels(&stage.parallel);
|
||||||
|
@ -1651,21 +1617,21 @@ mod tests {
|
||||||
assert_eq!(ambiguities.len(), 1);
|
assert_eq!(ambiguities.len(), 1);
|
||||||
|
|
||||||
let mut stage = SystemStage::parallel()
|
let mut stage = SystemStage::parallel()
|
||||||
.with_system(empty.system().label("0"))
|
.with_system(empty.label("0"))
|
||||||
.with_system(resource.system().label("1").after("0"))
|
.with_system(resource.label("1").after("0"))
|
||||||
.with_system(empty.system().label("2"))
|
.with_system(empty.label("2"))
|
||||||
.with_system(empty.system().label("3").after("2").before("4"))
|
.with_system(empty.label("3").after("2").before("4"))
|
||||||
.with_system(component.system().label("4"));
|
.with_system(component.label("4"));
|
||||||
stage.initialize_systems(&mut world);
|
stage.initialize_systems(&mut world);
|
||||||
stage.rebuild_orders_and_dependencies();
|
stage.rebuild_orders_and_dependencies();
|
||||||
assert_eq!(find_ambiguities(&stage.parallel).len(), 0);
|
assert_eq!(find_ambiguities(&stage.parallel).len(), 0);
|
||||||
|
|
||||||
let mut stage = SystemStage::parallel()
|
let mut stage = SystemStage::parallel()
|
||||||
.with_system(component.system().label("0"))
|
.with_system(component.label("0"))
|
||||||
.with_system(resource.system().label("1").after("0"))
|
.with_system(resource.label("1").after("0"))
|
||||||
.with_system(empty.system().label("2"))
|
.with_system(empty.label("2"))
|
||||||
.with_system(component.system().label("3").after("2").before("4"))
|
.with_system(component.label("3").after("2").before("4"))
|
||||||
.with_system(resource.system().label("4"));
|
.with_system(resource.label("4"));
|
||||||
stage.initialize_systems(&mut world);
|
stage.initialize_systems(&mut world);
|
||||||
stage.rebuild_orders_and_dependencies();
|
stage.rebuild_orders_and_dependencies();
|
||||||
let ambiguities = find_ambiguities_first_labels(&stage.parallel);
|
let ambiguities = find_ambiguities_first_labels(&stage.parallel);
|
||||||
|
@ -1680,17 +1646,11 @@ mod tests {
|
||||||
assert_eq!(ambiguities.len(), 2);
|
assert_eq!(ambiguities.len(), 2);
|
||||||
|
|
||||||
let mut stage = SystemStage::parallel()
|
let mut stage = SystemStage::parallel()
|
||||||
.with_system(component.system().label("0"))
|
.with_system(component.label("0"))
|
||||||
.with_system(
|
.with_system(resource.label("1").after("0").in_ambiguity_set("a"))
|
||||||
resource
|
.with_system(empty.label("2"))
|
||||||
.system()
|
.with_system(component.label("3").after("2").before("4"))
|
||||||
.label("1")
|
.with_system(resource.label("4").in_ambiguity_set("a"));
|
||||||
.after("0")
|
|
||||||
.in_ambiguity_set("a"),
|
|
||||||
)
|
|
||||||
.with_system(empty.system().label("2"))
|
|
||||||
.with_system(component.system().label("3").after("2").before("4"))
|
|
||||||
.with_system(resource.system().label("4").in_ambiguity_set("a"));
|
|
||||||
stage.initialize_systems(&mut world);
|
stage.initialize_systems(&mut world);
|
||||||
stage.rebuild_orders_and_dependencies();
|
stage.rebuild_orders_and_dependencies();
|
||||||
let ambiguities = find_ambiguities_first_labels(&stage.parallel);
|
let ambiguities = find_ambiguities_first_labels(&stage.parallel);
|
||||||
|
@ -1701,9 +1661,9 @@ mod tests {
|
||||||
assert_eq!(ambiguities.len(), 1);
|
assert_eq!(ambiguities.len(), 1);
|
||||||
|
|
||||||
let mut stage = SystemStage::parallel()
|
let mut stage = SystemStage::parallel()
|
||||||
.with_system(component.system().label("0").before("2"))
|
.with_system(component.label("0").before("2"))
|
||||||
.with_system(component.system().label("1").before("2"))
|
.with_system(component.label("1").before("2"))
|
||||||
.with_system(component.system().label("2"));
|
.with_system(component.label("2"));
|
||||||
stage.initialize_systems(&mut world);
|
stage.initialize_systems(&mut world);
|
||||||
stage.rebuild_orders_and_dependencies();
|
stage.rebuild_orders_and_dependencies();
|
||||||
let ambiguities = find_ambiguities_first_labels(&stage.parallel);
|
let ambiguities = find_ambiguities_first_labels(&stage.parallel);
|
||||||
|
@ -1714,9 +1674,9 @@ mod tests {
|
||||||
assert_eq!(ambiguities.len(), 1);
|
assert_eq!(ambiguities.len(), 1);
|
||||||
|
|
||||||
let mut stage = SystemStage::parallel()
|
let mut stage = SystemStage::parallel()
|
||||||
.with_system(component.system().label("0"))
|
.with_system(component.label("0"))
|
||||||
.with_system(component.system().label("1").after("0"))
|
.with_system(component.label("1").after("0"))
|
||||||
.with_system(component.system().label("2").after("0"));
|
.with_system(component.label("2").after("0"));
|
||||||
stage.initialize_systems(&mut world);
|
stage.initialize_systems(&mut world);
|
||||||
stage.rebuild_orders_and_dependencies();
|
stage.rebuild_orders_and_dependencies();
|
||||||
let ambiguities = find_ambiguities_first_labels(&stage.parallel);
|
let ambiguities = find_ambiguities_first_labels(&stage.parallel);
|
||||||
|
@ -1727,10 +1687,10 @@ mod tests {
|
||||||
assert_eq!(ambiguities.len(), 1);
|
assert_eq!(ambiguities.len(), 1);
|
||||||
|
|
||||||
let mut stage = SystemStage::parallel()
|
let mut stage = SystemStage::parallel()
|
||||||
.with_system(component.system().label("0").before("1").before("2"))
|
.with_system(component.label("0").before("1").before("2"))
|
||||||
.with_system(component.system().label("1"))
|
.with_system(component.label("1"))
|
||||||
.with_system(component.system().label("2"))
|
.with_system(component.label("2"))
|
||||||
.with_system(component.system().label("3").after("1").after("2"));
|
.with_system(component.label("3").after("1").after("2"));
|
||||||
stage.initialize_systems(&mut world);
|
stage.initialize_systems(&mut world);
|
||||||
stage.rebuild_orders_and_dependencies();
|
stage.rebuild_orders_and_dependencies();
|
||||||
let ambiguities = find_ambiguities_first_labels(&stage.parallel);
|
let ambiguities = find_ambiguities_first_labels(&stage.parallel);
|
||||||
|
@ -1741,20 +1701,20 @@ mod tests {
|
||||||
assert_eq!(ambiguities.len(), 1);
|
assert_eq!(ambiguities.len(), 1);
|
||||||
|
|
||||||
let mut stage = SystemStage::parallel()
|
let mut stage = SystemStage::parallel()
|
||||||
.with_system(component.system().label("0").before("1").before("2"))
|
.with_system(component.label("0").before("1").before("2"))
|
||||||
.with_system(component.system().label("1").in_ambiguity_set("a"))
|
.with_system(component.label("1").in_ambiguity_set("a"))
|
||||||
.with_system(component.system().label("2").in_ambiguity_set("a"))
|
.with_system(component.label("2").in_ambiguity_set("a"))
|
||||||
.with_system(component.system().label("3").after("1").after("2"));
|
.with_system(component.label("3").after("1").after("2"));
|
||||||
stage.initialize_systems(&mut world);
|
stage.initialize_systems(&mut world);
|
||||||
stage.rebuild_orders_and_dependencies();
|
stage.rebuild_orders_and_dependencies();
|
||||||
let ambiguities = find_ambiguities_first_labels(&stage.parallel);
|
let ambiguities = find_ambiguities_first_labels(&stage.parallel);
|
||||||
assert_eq!(ambiguities.len(), 0);
|
assert_eq!(ambiguities.len(), 0);
|
||||||
|
|
||||||
let mut stage = SystemStage::parallel()
|
let mut stage = SystemStage::parallel()
|
||||||
.with_system(component.system().label("0").before("1").before("2"))
|
.with_system(component.label("0").before("1").before("2"))
|
||||||
.with_system(component.system().label("1").in_ambiguity_set("a"))
|
.with_system(component.label("1").in_ambiguity_set("a"))
|
||||||
.with_system(component.system().label("2").in_ambiguity_set("b"))
|
.with_system(component.label("2").in_ambiguity_set("b"))
|
||||||
.with_system(component.system().label("3").after("1").after("2"));
|
.with_system(component.label("3").after("1").after("2"));
|
||||||
stage.initialize_systems(&mut world);
|
stage.initialize_systems(&mut world);
|
||||||
stage.rebuild_orders_and_dependencies();
|
stage.rebuild_orders_and_dependencies();
|
||||||
let ambiguities = find_ambiguities_first_labels(&stage.parallel);
|
let ambiguities = find_ambiguities_first_labels(&stage.parallel);
|
||||||
|
@ -1767,20 +1727,18 @@ mod tests {
|
||||||
let mut stage = SystemStage::parallel()
|
let mut stage = SystemStage::parallel()
|
||||||
.with_system(
|
.with_system(
|
||||||
component
|
component
|
||||||
.system()
|
|
||||||
.label("0")
|
.label("0")
|
||||||
.before("1")
|
.before("1")
|
||||||
.before("2")
|
.before("2")
|
||||||
.before("3")
|
.before("3")
|
||||||
.before("4"),
|
.before("4"),
|
||||||
)
|
)
|
||||||
.with_system(component.system().label("1"))
|
.with_system(component.label("1"))
|
||||||
.with_system(component.system().label("2"))
|
.with_system(component.label("2"))
|
||||||
.with_system(component.system().label("3"))
|
.with_system(component.label("3"))
|
||||||
.with_system(component.system().label("4"))
|
.with_system(component.label("4"))
|
||||||
.with_system(
|
.with_system(
|
||||||
component
|
component
|
||||||
.system()
|
|
||||||
.label("5")
|
.label("5")
|
||||||
.after("1")
|
.after("1")
|
||||||
.after("2")
|
.after("2")
|
||||||
|
@ -1819,20 +1777,18 @@ mod tests {
|
||||||
let mut stage = SystemStage::parallel()
|
let mut stage = SystemStage::parallel()
|
||||||
.with_system(
|
.with_system(
|
||||||
component
|
component
|
||||||
.system()
|
|
||||||
.label("0")
|
.label("0")
|
||||||
.before("1")
|
.before("1")
|
||||||
.before("2")
|
.before("2")
|
||||||
.before("3")
|
.before("3")
|
||||||
.before("4"),
|
.before("4"),
|
||||||
)
|
)
|
||||||
.with_system(component.system().label("1").in_ambiguity_set("a"))
|
.with_system(component.label("1").in_ambiguity_set("a"))
|
||||||
.with_system(component.system().label("2").in_ambiguity_set("a"))
|
.with_system(component.label("2").in_ambiguity_set("a"))
|
||||||
.with_system(component.system().label("3").in_ambiguity_set("a"))
|
.with_system(component.label("3").in_ambiguity_set("a"))
|
||||||
.with_system(component.system().label("4").in_ambiguity_set("a"))
|
.with_system(component.label("4").in_ambiguity_set("a"))
|
||||||
.with_system(
|
.with_system(
|
||||||
component
|
component
|
||||||
.system()
|
|
||||||
.label("5")
|
.label("5")
|
||||||
.after("1")
|
.after("1")
|
||||||
.after("2")
|
.after("2")
|
||||||
|
@ -1847,26 +1803,23 @@ mod tests {
|
||||||
let mut stage = SystemStage::parallel()
|
let mut stage = SystemStage::parallel()
|
||||||
.with_system(
|
.with_system(
|
||||||
component
|
component
|
||||||
.system()
|
|
||||||
.label("0")
|
.label("0")
|
||||||
.before("1")
|
.before("1")
|
||||||
.before("2")
|
.before("2")
|
||||||
.before("3")
|
.before("3")
|
||||||
.before("4"),
|
.before("4"),
|
||||||
)
|
)
|
||||||
.with_system(component.system().label("1").in_ambiguity_set("a"))
|
.with_system(component.label("1").in_ambiguity_set("a"))
|
||||||
.with_system(component.system().label("2").in_ambiguity_set("a"))
|
.with_system(component.label("2").in_ambiguity_set("a"))
|
||||||
.with_system(
|
.with_system(
|
||||||
component
|
component
|
||||||
.system()
|
|
||||||
.label("3")
|
.label("3")
|
||||||
.in_ambiguity_set("a")
|
.in_ambiguity_set("a")
|
||||||
.in_ambiguity_set("b"),
|
.in_ambiguity_set("b"),
|
||||||
)
|
)
|
||||||
.with_system(component.system().label("4").in_ambiguity_set("b"))
|
.with_system(component.label("4").in_ambiguity_set("b"))
|
||||||
.with_system(
|
.with_system(
|
||||||
component
|
component
|
||||||
.system()
|
|
||||||
.label("5")
|
.label("5")
|
||||||
.after("1")
|
.after("1")
|
||||||
.after("2")
|
.after("2")
|
||||||
|
@ -1997,7 +1950,7 @@ mod tests {
|
||||||
|
|
||||||
let mut world = World::new();
|
let mut world = World::new();
|
||||||
world.insert_resource(0_usize);
|
world.insert_resource(0_usize);
|
||||||
let mut stage = SystemStage::single(query_count_system.system());
|
let mut stage = SystemStage::single(query_count_system);
|
||||||
|
|
||||||
let entity = world.spawn().insert_bundle(()).id();
|
let entity = world.spawn().insert_bundle(()).id();
|
||||||
stage.run(&mut world);
|
stage.run(&mut world);
|
||||||
|
@ -2020,7 +1973,7 @@ mod tests {
|
||||||
let mut world = World::new();
|
let mut world = World::new();
|
||||||
world.insert_resource(0_usize);
|
world.insert_resource(0_usize);
|
||||||
let mut stage = SystemStage::parallel();
|
let mut stage = SystemStage::parallel();
|
||||||
stage.add_system(query_count_system.system());
|
stage.add_system(query_count_system);
|
||||||
|
|
||||||
let entity = world.spawn().insert_bundle(()).id();
|
let entity = world.spawn().insert_bundle(()).id();
|
||||||
stage.run(&mut world);
|
stage.run(&mut world);
|
||||||
|
@ -2042,7 +1995,7 @@ mod tests {
|
||||||
|
|
||||||
let mut stage = SystemStage::parallel();
|
let mut stage = SystemStage::parallel();
|
||||||
fn work() {}
|
fn work() {}
|
||||||
stage.add_system(work.system());
|
stage.add_system(work);
|
||||||
|
|
||||||
// Overflow twice
|
// Overflow twice
|
||||||
for _ in 0..10 {
|
for _ in 0..10 {
|
||||||
|
@ -2120,11 +2073,11 @@ mod tests {
|
||||||
let mut world = World::new();
|
let mut world = World::new();
|
||||||
world.insert_resource(Vec::<usize>::new());
|
world.insert_resource(Vec::<usize>::new());
|
||||||
let mut stage = SystemStage::parallel()
|
let mut stage = SystemStage::parallel()
|
||||||
.with_system(spawn_entity.system().label("spawn"))
|
.with_system(spawn_entity.label("spawn"))
|
||||||
.with_system_set(
|
.with_system_set(
|
||||||
SystemSet::new()
|
SystemSet::new()
|
||||||
.with_run_criteria(even_number_of_entities_critiera.system())
|
.with_run_criteria(even_number_of_entities_critiera)
|
||||||
.with_system(count_entities.system().before("spawn")),
|
.with_system(count_entities.before("spawn")),
|
||||||
);
|
);
|
||||||
stage.run(&mut world);
|
stage.run(&mut world);
|
||||||
stage.run(&mut world);
|
stage.run(&mut world);
|
||||||
|
@ -2155,10 +2108,10 @@ mod tests {
|
||||||
|
|
||||||
let mut world = World::new();
|
let mut world = World::new();
|
||||||
world.insert_resource(Vec::<usize>::new());
|
world.insert_resource(Vec::<usize>::new());
|
||||||
let mut stage_spawn = SystemStage::parallel().with_system(spawn_entity.system());
|
let mut stage_spawn = SystemStage::parallel().with_system(spawn_entity);
|
||||||
let mut stage_count = SystemStage::parallel()
|
let mut stage_count = SystemStage::parallel()
|
||||||
.with_run_criteria(even_number_of_entities_critiera.system())
|
.with_run_criteria(even_number_of_entities_critiera)
|
||||||
.with_system(count_entities.system());
|
.with_system(count_entities);
|
||||||
stage_count.run(&mut world);
|
stage_count.run(&mut world);
|
||||||
stage_spawn.run(&mut world);
|
stage_spawn.run(&mut world);
|
||||||
stage_count.run(&mut world);
|
stage_count.run(&mut world);
|
||||||
|
|
|
@ -4,7 +4,7 @@ use crate::{
|
||||||
RunCriteriaDescriptor, RunCriteriaDescriptorCoercion, RunCriteriaLabel, ShouldRun,
|
RunCriteriaDescriptor, RunCriteriaDescriptorCoercion, RunCriteriaLabel, ShouldRun,
|
||||||
SystemSet,
|
SystemSet,
|
||||||
},
|
},
|
||||||
system::{In, IntoChainSystem, IntoSystem, Local, Res, ResMut},
|
system::{ConfigurableSystem, In, IntoChainSystem, Local, Res, ResMut},
|
||||||
};
|
};
|
||||||
use std::{any::TypeId, fmt::Debug, hash::Hash};
|
use std::{any::TypeId, fmt::Debug, hash::Hash};
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
|
@ -97,9 +97,8 @@ where
|
||||||
(|state: Res<State<T>>, pred: Local<Option<T>>| {
|
(|state: Res<State<T>>, pred: Local<Option<T>>| {
|
||||||
state.stack.last().unwrap() == pred.as_ref().unwrap() && state.transition.is_none()
|
state.stack.last().unwrap() == pred.as_ref().unwrap() && state.transition.is_none()
|
||||||
})
|
})
|
||||||
.system()
|
|
||||||
.config(|(_, pred)| *pred = Some(Some(s.clone())))
|
.config(|(_, pred)| *pred = Some(Some(s.clone())))
|
||||||
.chain(should_run_adapter::<T>.system())
|
.chain(should_run_adapter::<T>)
|
||||||
.after(DriverLabel::of::<T>())
|
.after(DriverLabel::of::<T>())
|
||||||
.label_discard_if_duplicate(StateCallback::Update.into_label(s))
|
.label_discard_if_duplicate(StateCallback::Update.into_label(s))
|
||||||
}
|
}
|
||||||
|
@ -118,9 +117,8 @@ where
|
||||||
Some(_) => false,
|
Some(_) => false,
|
||||||
None => *is_inactive,
|
None => *is_inactive,
|
||||||
})
|
})
|
||||||
.system()
|
|
||||||
.config(|(_, _, pred)| *pred = Some(Some(s.clone())))
|
.config(|(_, _, pred)| *pred = Some(Some(s.clone())))
|
||||||
.chain(should_run_adapter::<T>.system())
|
.chain(should_run_adapter::<T>)
|
||||||
.after(DriverLabel::of::<T>())
|
.after(DriverLabel::of::<T>())
|
||||||
.label_discard_if_duplicate(StateCallback::InactiveUpdate.into_label(s))
|
.label_discard_if_duplicate(StateCallback::InactiveUpdate.into_label(s))
|
||||||
}
|
}
|
||||||
|
@ -151,9 +149,8 @@ where
|
||||||
Some(_) => false,
|
Some(_) => false,
|
||||||
None => *is_in_stack,
|
None => *is_in_stack,
|
||||||
})
|
})
|
||||||
.system()
|
|
||||||
.config(|(_, _, pred)| *pred = Some(Some(s.clone())))
|
.config(|(_, _, pred)| *pred = Some(Some(s.clone())))
|
||||||
.chain(should_run_adapter::<T>.system())
|
.chain(should_run_adapter::<T>)
|
||||||
.after(DriverLabel::of::<T>())
|
.after(DriverLabel::of::<T>())
|
||||||
.label_discard_if_duplicate(StateCallback::InStackUpdate.into_label(s))
|
.label_discard_if_duplicate(StateCallback::InStackUpdate.into_label(s))
|
||||||
}
|
}
|
||||||
|
@ -171,9 +168,8 @@ where
|
||||||
_ => false,
|
_ => false,
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
.system()
|
|
||||||
.config(|(_, pred)| *pred = Some(Some(s.clone())))
|
.config(|(_, pred)| *pred = Some(Some(s.clone())))
|
||||||
.chain(should_run_adapter::<T>.system())
|
.chain(should_run_adapter::<T>)
|
||||||
.after(DriverLabel::of::<T>())
|
.after(DriverLabel::of::<T>())
|
||||||
.label_discard_if_duplicate(StateCallback::Enter.into_label(s))
|
.label_discard_if_duplicate(StateCallback::Enter.into_label(s))
|
||||||
}
|
}
|
||||||
|
@ -189,9 +185,8 @@ where
|
||||||
_ => false,
|
_ => false,
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
.system()
|
|
||||||
.config(|(_, pred)| *pred = Some(Some(s.clone())))
|
.config(|(_, pred)| *pred = Some(Some(s.clone())))
|
||||||
.chain(should_run_adapter::<T>.system())
|
.chain(should_run_adapter::<T>)
|
||||||
.after(DriverLabel::of::<T>())
|
.after(DriverLabel::of::<T>())
|
||||||
.label_discard_if_duplicate(StateCallback::Exit.into_label(s))
|
.label_discard_if_duplicate(StateCallback::Exit.into_label(s))
|
||||||
}
|
}
|
||||||
|
@ -206,9 +201,8 @@ where
|
||||||
_ => false,
|
_ => false,
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
.system()
|
|
||||||
.config(|(_, pred)| *pred = Some(Some(s.clone())))
|
.config(|(_, pred)| *pred = Some(Some(s.clone())))
|
||||||
.chain(should_run_adapter::<T>.system())
|
.chain(should_run_adapter::<T>)
|
||||||
.after(DriverLabel::of::<T>())
|
.after(DriverLabel::of::<T>())
|
||||||
.label_discard_if_duplicate(StateCallback::Pause.into_label(s))
|
.label_discard_if_duplicate(StateCallback::Pause.into_label(s))
|
||||||
}
|
}
|
||||||
|
@ -223,9 +217,8 @@ where
|
||||||
_ => false,
|
_ => false,
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
.system()
|
|
||||||
.config(|(_, pred)| *pred = Some(Some(s.clone())))
|
.config(|(_, pred)| *pred = Some(Some(s.clone())))
|
||||||
.chain(should_run_adapter::<T>.system())
|
.chain(should_run_adapter::<T>)
|
||||||
.after(DriverLabel::of::<T>())
|
.after(DriverLabel::of::<T>())
|
||||||
.label_discard_if_duplicate(StateCallback::Resume.into_label(s))
|
.label_discard_if_duplicate(StateCallback::Resume.into_label(s))
|
||||||
}
|
}
|
||||||
|
@ -259,8 +252,7 @@ where
|
||||||
/// Important note: this set must be inserted **before** all other state-dependant sets to work
|
/// Important note: this set must be inserted **before** all other state-dependant sets to work
|
||||||
/// properly!
|
/// properly!
|
||||||
pub fn get_driver() -> SystemSet {
|
pub fn get_driver() -> SystemSet {
|
||||||
SystemSet::default()
|
SystemSet::default().with_run_criteria(state_cleaner::<T>.label(DriverLabel::of::<T>()))
|
||||||
.with_run_criteria(state_cleaner::<T>.system().label(DriverLabel::of::<T>()))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new(initial: T) -> Self {
|
pub fn new(initial: T) -> Self {
|
||||||
|
@ -516,81 +508,63 @@ mod test {
|
||||||
stage
|
stage
|
||||||
.add_system_set(
|
.add_system_set(
|
||||||
State::on_enter_set(MyState::S1)
|
State::on_enter_set(MyState::S1)
|
||||||
.with_system((|mut r: ResMut<Vec<&'static str>>| r.push("startup")).system()),
|
.with_system(|mut r: ResMut<Vec<&'static str>>| r.push("startup")),
|
||||||
)
|
)
|
||||||
.add_system_set(
|
.add_system_set(State::on_update_set(MyState::S1).with_system(
|
||||||
State::on_update_set(MyState::S1).with_system(
|
|mut r: ResMut<Vec<&'static str>>, mut s: ResMut<State<MyState>>| {
|
||||||
(|mut r: ResMut<Vec<&'static str>>, mut s: ResMut<State<MyState>>| {
|
|
||||||
r.push("update S1");
|
r.push("update S1");
|
||||||
s.overwrite_replace(MyState::S2).unwrap();
|
s.overwrite_replace(MyState::S2).unwrap();
|
||||||
})
|
},
|
||||||
.system(),
|
))
|
||||||
),
|
|
||||||
)
|
|
||||||
.add_system_set(
|
.add_system_set(
|
||||||
State::on_enter_set(MyState::S2)
|
State::on_enter_set(MyState::S2)
|
||||||
.with_system((|mut r: ResMut<Vec<&'static str>>| r.push("enter S2")).system()),
|
.with_system(|mut r: ResMut<Vec<&'static str>>| r.push("enter S2")),
|
||||||
)
|
)
|
||||||
.add_system_set(
|
.add_system_set(State::on_update_set(MyState::S2).with_system(
|
||||||
State::on_update_set(MyState::S2).with_system(
|
|mut r: ResMut<Vec<&'static str>>, mut s: ResMut<State<MyState>>| {
|
||||||
(|mut r: ResMut<Vec<&'static str>>, mut s: ResMut<State<MyState>>| {
|
|
||||||
r.push("update S2");
|
r.push("update S2");
|
||||||
s.overwrite_replace(MyState::S3).unwrap();
|
s.overwrite_replace(MyState::S3).unwrap();
|
||||||
})
|
},
|
||||||
.system(),
|
))
|
||||||
),
|
|
||||||
)
|
|
||||||
.add_system_set(
|
.add_system_set(
|
||||||
State::on_exit_set(MyState::S2)
|
State::on_exit_set(MyState::S2)
|
||||||
.with_system((|mut r: ResMut<Vec<&'static str>>| r.push("exit S2")).system()),
|
.with_system(|mut r: ResMut<Vec<&'static str>>| r.push("exit S2")),
|
||||||
)
|
)
|
||||||
.add_system_set(
|
.add_system_set(
|
||||||
State::on_enter_set(MyState::S3)
|
State::on_enter_set(MyState::S3)
|
||||||
.with_system((|mut r: ResMut<Vec<&'static str>>| r.push("enter S3")).system()),
|
.with_system(|mut r: ResMut<Vec<&'static str>>| r.push("enter S3")),
|
||||||
)
|
)
|
||||||
.add_system_set(
|
.add_system_set(State::on_update_set(MyState::S3).with_system(
|
||||||
State::on_update_set(MyState::S3).with_system(
|
|mut r: ResMut<Vec<&'static str>>, mut s: ResMut<State<MyState>>| {
|
||||||
(|mut r: ResMut<Vec<&'static str>>, mut s: ResMut<State<MyState>>| {
|
|
||||||
r.push("update S3");
|
r.push("update S3");
|
||||||
s.overwrite_push(MyState::S4).unwrap();
|
s.overwrite_push(MyState::S4).unwrap();
|
||||||
})
|
},
|
||||||
.system(),
|
))
|
||||||
),
|
|
||||||
)
|
|
||||||
.add_system_set(
|
.add_system_set(
|
||||||
State::on_pause_set(MyState::S3)
|
State::on_pause_set(MyState::S3)
|
||||||
.with_system((|mut r: ResMut<Vec<&'static str>>| r.push("pause S3")).system()),
|
.with_system(|mut r: ResMut<Vec<&'static str>>| r.push("pause S3")),
|
||||||
)
|
)
|
||||||
.add_system_set(
|
.add_system_set(State::on_update_set(MyState::S4).with_system(
|
||||||
State::on_update_set(MyState::S4).with_system(
|
|mut r: ResMut<Vec<&'static str>>, mut s: ResMut<State<MyState>>| {
|
||||||
(|mut r: ResMut<Vec<&'static str>>, mut s: ResMut<State<MyState>>| {
|
|
||||||
r.push("update S4");
|
r.push("update S4");
|
||||||
s.overwrite_push(MyState::S5).unwrap();
|
s.overwrite_push(MyState::S5).unwrap();
|
||||||
})
|
},
|
||||||
.system(),
|
))
|
||||||
),
|
.add_system_set(State::on_inactive_update_set(MyState::S4).with_system(
|
||||||
)
|
(|mut r: ResMut<Vec<&'static str>>| r.push("inactive S4")).label("inactive s4"),
|
||||||
.add_system_set(
|
))
|
||||||
State::on_inactive_update_set(MyState::S4).with_system(
|
|
||||||
(|mut r: ResMut<Vec<&'static str>>| r.push("inactive S4"))
|
|
||||||
.system()
|
|
||||||
.label("inactive s4"),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
.add_system_set(
|
.add_system_set(
|
||||||
State::on_update_set(MyState::S5).with_system(
|
State::on_update_set(MyState::S5).with_system(
|
||||||
(|mut r: ResMut<Vec<&'static str>>, mut s: ResMut<State<MyState>>| {
|
(|mut r: ResMut<Vec<&'static str>>, mut s: ResMut<State<MyState>>| {
|
||||||
r.push("update S5");
|
r.push("update S5");
|
||||||
s.overwrite_push(MyState::S6).unwrap();
|
s.overwrite_push(MyState::S6).unwrap();
|
||||||
})
|
})
|
||||||
.system()
|
|
||||||
.after("inactive s4"),
|
.after("inactive s4"),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.add_system_set(
|
.add_system_set(
|
||||||
State::on_inactive_update_set(MyState::S5).with_system(
|
State::on_inactive_update_set(MyState::S5).with_system(
|
||||||
(|mut r: ResMut<Vec<&'static str>>| r.push("inactive S5"))
|
(|mut r: ResMut<Vec<&'static str>>| r.push("inactive S5"))
|
||||||
.system()
|
|
||||||
.label("inactive s5")
|
.label("inactive s5")
|
||||||
.after("inactive s4"),
|
.after("inactive s4"),
|
||||||
),
|
),
|
||||||
|
@ -601,17 +575,16 @@ mod test {
|
||||||
r.push("update S6");
|
r.push("update S6");
|
||||||
s.overwrite_push(MyState::Final).unwrap();
|
s.overwrite_push(MyState::Final).unwrap();
|
||||||
})
|
})
|
||||||
.system()
|
|
||||||
.after("inactive s5"),
|
.after("inactive s5"),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.add_system_set(
|
.add_system_set(
|
||||||
State::on_resume_set(MyState::S4)
|
State::on_resume_set(MyState::S4)
|
||||||
.with_system((|mut r: ResMut<Vec<&'static str>>| r.push("resume S4")).system()),
|
.with_system(|mut r: ResMut<Vec<&'static str>>| r.push("resume S4")),
|
||||||
)
|
)
|
||||||
.add_system_set(
|
.add_system_set(
|
||||||
State::on_exit_set(MyState::S5)
|
State::on_exit_set(MyState::S5)
|
||||||
.with_system((|mut r: ResMut<Vec<&'static str>>| r.push("exit S4")).system()),
|
.with_system(|mut r: ResMut<Vec<&'static str>>| r.push("exit S4")),
|
||||||
);
|
);
|
||||||
|
|
||||||
const EXPECTED: &[&str] = &[
|
const EXPECTED: &[&str] = &[
|
||||||
|
@ -671,7 +644,7 @@ mod test {
|
||||||
world.insert_resource(State::new(AppState::Main));
|
world.insert_resource(State::new(AppState::Main));
|
||||||
world.insert_resource(false);
|
world.insert_resource(false);
|
||||||
world.insert_resource("control");
|
world.insert_resource("control");
|
||||||
let mut stage = SystemStage::parallel().with_system(should_run_once.system());
|
let mut stage = SystemStage::parallel().with_system(should_run_once);
|
||||||
stage.run(&mut world);
|
stage.run(&mut world);
|
||||||
assert!(*world.get_resource::<bool>().unwrap(), "after control");
|
assert!(*world.get_resource::<bool>().unwrap(), "after control");
|
||||||
|
|
||||||
|
@ -679,7 +652,7 @@ mod test {
|
||||||
world.insert_resource("test");
|
world.insert_resource("test");
|
||||||
let mut stage = SystemStage::parallel()
|
let mut stage = SystemStage::parallel()
|
||||||
.with_system_set(State::<AppState>::get_driver())
|
.with_system_set(State::<AppState>::get_driver())
|
||||||
.with_system(should_run_once.system());
|
.with_system(should_run_once);
|
||||||
stage.run(&mut world);
|
stage.run(&mut world);
|
||||||
assert!(*world.get_resource::<bool>().unwrap(), "after test");
|
assert!(*world.get_resource::<bool>().unwrap(), "after test");
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,8 +30,8 @@ use crate::{
|
||||||
/// struct Something;
|
/// struct Something;
|
||||||
///
|
///
|
||||||
/// SystemStage::parallel()
|
/// SystemStage::parallel()
|
||||||
/// .with_system(do_something.system().label(Something))
|
/// .with_system(do_something.label(Something))
|
||||||
/// .with_system(do_the_other_thing.system().after(Something))
|
/// .with_system(do_the_other_thing.after(Something))
|
||||||
/// .with_system(do_something_else.exclusive_system().at_end());
|
/// .with_system(do_something_else.exclusive_system().at_end());
|
||||||
/// ```
|
/// ```
|
||||||
pub enum SystemDescriptor {
|
pub enum SystemDescriptor {
|
||||||
|
|
|
@ -128,7 +128,7 @@ mod tests {
|
||||||
entity::Entity,
|
entity::Entity,
|
||||||
query::With,
|
query::With,
|
||||||
schedule::{Stage, SystemStage},
|
schedule::{Stage, SystemStage},
|
||||||
system::{Commands, IntoExclusiveSystem, IntoSystem, Query, ResMut},
|
system::{Commands, IntoExclusiveSystem, Query, ResMut},
|
||||||
world::World,
|
world::World,
|
||||||
};
|
};
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -146,7 +146,7 @@ mod tests {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut stage = SystemStage::parallel().with_system(removal.system());
|
let mut stage = SystemStage::parallel().with_system(removal);
|
||||||
world.spawn().insert(0.0f32);
|
world.spawn().insert(0.0f32);
|
||||||
world.insert_resource(0usize);
|
world.insert_resource(0usize);
|
||||||
stage.run(&mut world);
|
stage.run(&mut world);
|
||||||
|
@ -176,7 +176,7 @@ mod tests {
|
||||||
let mut world = World::new();
|
let mut world = World::new();
|
||||||
world.insert_resource(Vec::<usize>::new());
|
world.insert_resource(Vec::<usize>::new());
|
||||||
let mut stage = SystemStage::parallel()
|
let mut stage = SystemStage::parallel()
|
||||||
.with_system(spawn_entity.system())
|
.with_system(spawn_entity)
|
||||||
.with_system(count_entities.exclusive_system());
|
.with_system(count_entities.exclusive_system());
|
||||||
stage.run(&mut world);
|
stage.run(&mut world);
|
||||||
stage.run(&mut world);
|
stage.run(&mut world);
|
||||||
|
|
|
@ -251,7 +251,7 @@ impl<In, Out, Param: SystemParam, Marker, F> FunctionSystem<In, Out, Param, Mark
|
||||||
/// fn local_is_42(local: Local<usize>) {
|
/// fn local_is_42(local: Local<usize>) {
|
||||||
/// assert_eq!(*local, 42);
|
/// assert_eq!(*local, 42);
|
||||||
/// }
|
/// }
|
||||||
/// let mut system = local_is_42.system().config(|config| config.0 = Some(42));
|
/// let mut system = local_is_42.config(|config| config.0 = Some(42));
|
||||||
/// system.initialize(world);
|
/// system.initialize(world);
|
||||||
/// system.run((), world);
|
/// system.run((), world);
|
||||||
/// ```
|
/// ```
|
||||||
|
|
|
@ -60,7 +60,7 @@ mod tests {
|
||||||
system.run((), &mut world);
|
system.run((), &mut world);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn run_system<S: System<In = (), Out = ()>>(world: &mut World, system: S) {
|
fn run_system<Param, S: IntoSystem<(), (), Param>>(world: &mut World, system: S) {
|
||||||
let mut schedule = Schedule::default();
|
let mut schedule = Schedule::default();
|
||||||
let mut update = SystemStage::parallel();
|
let mut update = SystemStage::parallel();
|
||||||
update.add_system(system);
|
update.add_system(system);
|
||||||
|
@ -121,7 +121,7 @@ mod tests {
|
||||||
world.spawn().insert_bundle((A, C));
|
world.spawn().insert_bundle((A, C));
|
||||||
world.spawn().insert_bundle((A, D));
|
world.spawn().insert_bundle((A, D));
|
||||||
|
|
||||||
run_system(&mut world, query_system.system());
|
run_system(&mut world, query_system);
|
||||||
|
|
||||||
assert!(*world.get_resource::<bool>().unwrap(), "system ran");
|
assert!(*world.get_resource::<bool>().unwrap(), "system ran");
|
||||||
}
|
}
|
||||||
|
@ -149,7 +149,7 @@ mod tests {
|
||||||
world.insert_resource(false);
|
world.insert_resource(false);
|
||||||
world.spawn().insert_bundle((A, B));
|
world.spawn().insert_bundle((A, B));
|
||||||
|
|
||||||
run_system(&mut world, query_system.system());
|
run_system(&mut world, query_system);
|
||||||
|
|
||||||
assert!(*world.get_resource::<bool>().unwrap(), "system ran");
|
assert!(*world.get_resource::<bool>().unwrap(), "system ran");
|
||||||
}
|
}
|
||||||
|
@ -179,7 +179,7 @@ mod tests {
|
||||||
|
|
||||||
let mut schedule = Schedule::default();
|
let mut schedule = Schedule::default();
|
||||||
let mut update = SystemStage::parallel();
|
let mut update = SystemStage::parallel();
|
||||||
update.add_system(incr_e_on_flip.system());
|
update.add_system(incr_e_on_flip);
|
||||||
schedule.add_stage("update", update);
|
schedule.add_stage("update", update);
|
||||||
schedule.add_stage(
|
schedule.add_stage(
|
||||||
"clear_trackers",
|
"clear_trackers",
|
||||||
|
@ -206,7 +206,7 @@ mod tests {
|
||||||
fn sys(_q1: Query<&mut A>, _q2: Query<&mut A>) {}
|
fn sys(_q1: Query<&mut A>, _q2: Query<&mut A>) {}
|
||||||
|
|
||||||
let mut world = World::default();
|
let mut world = World::default();
|
||||||
run_system(&mut world, sys.system());
|
run_system(&mut world, sys);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -214,7 +214,7 @@ mod tests {
|
||||||
fn sys(_q1: Query<&mut A, With<B>>, _q2: Query<&mut A, Without<B>>) {}
|
fn sys(_q1: Query<&mut A, With<B>>, _q2: Query<&mut A, Without<B>>) {}
|
||||||
|
|
||||||
let mut world = World::default();
|
let mut world = World::default();
|
||||||
run_system(&mut world, sys.system());
|
run_system(&mut world, sys);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -222,7 +222,7 @@ mod tests {
|
||||||
fn sys(_q1: Query<(&mut A, &B)>, _q2: Query<&mut A, Without<B>>) {}
|
fn sys(_q1: Query<(&mut A, &B)>, _q2: Query<&mut A, Without<B>>) {}
|
||||||
|
|
||||||
let mut world = World::default();
|
let mut world = World::default();
|
||||||
run_system(&mut world, sys.system());
|
run_system(&mut world, sys);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -231,14 +231,14 @@ mod tests {
|
||||||
fn sys(_q1: Query<&A>, _q2: Query<&mut A>) {}
|
fn sys(_q1: Query<&A>, _q2: Query<&mut A>) {}
|
||||||
|
|
||||||
let mut world = World::default();
|
let mut world = World::default();
|
||||||
run_system(&mut world, sys.system());
|
run_system(&mut world, sys);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn query_set_system() {
|
fn query_set_system() {
|
||||||
fn sys(mut _set: QuerySet<(Query<&mut A>, Query<&A>)>) {}
|
fn sys(mut _set: QuerySet<(Query<&mut A>, Query<&A>)>) {}
|
||||||
let mut world = World::default();
|
let mut world = World::default();
|
||||||
run_system(&mut world, sys.system());
|
run_system(&mut world, sys);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -247,7 +247,7 @@ mod tests {
|
||||||
fn sys(_query: Query<&mut A>, _set: QuerySet<(Query<&mut A>, Query<&B>)>) {}
|
fn sys(_query: Query<&mut A>, _set: QuerySet<(Query<&mut A>, Query<&B>)>) {}
|
||||||
|
|
||||||
let mut world = World::default();
|
let mut world = World::default();
|
||||||
run_system(&mut world, sys.system());
|
run_system(&mut world, sys);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -256,7 +256,7 @@ mod tests {
|
||||||
fn sys(_set_1: QuerySet<(Query<&mut A>,)>, _set_2: QuerySet<(Query<&mut A>, Query<&B>)>) {}
|
fn sys(_set_1: QuerySet<(Query<&mut A>,)>, _set_2: QuerySet<(Query<&mut A>, Query<&B>)>) {}
|
||||||
|
|
||||||
let mut world = World::default();
|
let mut world = World::default();
|
||||||
run_system(&mut world, sys.system());
|
run_system(&mut world, sys);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
|
@ -264,39 +264,39 @@ mod tests {
|
||||||
_buffer: Vec<u8>,
|
_buffer: Vec<u8>,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn test_for_conflicting_resources<S: System<In = (), Out = ()>>(sys: S) {
|
fn test_for_conflicting_resources<Param, S: IntoSystem<(), (), Param>>(sys: S) {
|
||||||
let mut world = World::default();
|
let mut world = World::default();
|
||||||
world.insert_resource(BufferRes::default());
|
world.insert_resource(BufferRes::default());
|
||||||
world.insert_resource(A);
|
world.insert_resource(A);
|
||||||
world.insert_resource(B);
|
world.insert_resource(B);
|
||||||
run_system(&mut world, sys.system());
|
run_system(&mut world, sys);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[should_panic]
|
#[should_panic]
|
||||||
fn conflicting_system_resources() {
|
fn conflicting_system_resources() {
|
||||||
fn sys(_: ResMut<BufferRes>, _: Res<BufferRes>) {}
|
fn sys(_: ResMut<BufferRes>, _: Res<BufferRes>) {}
|
||||||
test_for_conflicting_resources(sys.system())
|
test_for_conflicting_resources(sys)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[should_panic]
|
#[should_panic]
|
||||||
fn conflicting_system_resources_reverse_order() {
|
fn conflicting_system_resources_reverse_order() {
|
||||||
fn sys(_: Res<BufferRes>, _: ResMut<BufferRes>) {}
|
fn sys(_: Res<BufferRes>, _: ResMut<BufferRes>) {}
|
||||||
test_for_conflicting_resources(sys.system())
|
test_for_conflicting_resources(sys)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[should_panic]
|
#[should_panic]
|
||||||
fn conflicting_system_resources_multiple_mutable() {
|
fn conflicting_system_resources_multiple_mutable() {
|
||||||
fn sys(_: ResMut<BufferRes>, _: ResMut<BufferRes>) {}
|
fn sys(_: ResMut<BufferRes>, _: ResMut<BufferRes>) {}
|
||||||
test_for_conflicting_resources(sys.system())
|
test_for_conflicting_resources(sys)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn nonconflicting_system_resources() {
|
fn nonconflicting_system_resources() {
|
||||||
fn sys(_: Local<BufferRes>, _: ResMut<BufferRes>, _: Local<A>, _: ResMut<A>) {}
|
fn sys(_: Local<BufferRes>, _: ResMut<BufferRes>, _: Local<A>, _: ResMut<A>) {}
|
||||||
test_for_conflicting_resources(sys.system())
|
test_for_conflicting_resources(sys)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -321,7 +321,7 @@ mod tests {
|
||||||
*modified = true;
|
*modified = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
run_system(&mut world, sys.system());
|
run_system(&mut world, sys);
|
||||||
|
|
||||||
// ensure the system actually ran
|
// ensure the system actually ran
|
||||||
assert!(*world.get_resource::<bool>().unwrap());
|
assert!(*world.get_resource::<bool>().unwrap());
|
||||||
|
@ -352,7 +352,7 @@ mod tests {
|
||||||
*ran = true;
|
*ran = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
run_system(&mut world, validate_removed.system());
|
run_system(&mut world, validate_removed);
|
||||||
assert!(*world.get_resource::<bool>().unwrap(), "system ran");
|
assert!(*world.get_resource::<bool>().unwrap(), "system ran");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -365,18 +365,10 @@ mod tests {
|
||||||
*modified = true;
|
*modified = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
run_system(
|
run_system(&mut world, sys.config(|config| config.0 = Some(42)));
|
||||||
&mut world,
|
|
||||||
sys.system().config(|config| config.0 = Some(42)),
|
|
||||||
);
|
|
||||||
|
|
||||||
// ensure the system actually ran
|
// ensure the system actually ran
|
||||||
assert!(*world.get_resource::<bool>().unwrap());
|
assert!(*world.get_resource::<bool>().unwrap());
|
||||||
|
|
||||||
// Now do the same with omitted `.system()`.
|
|
||||||
world.insert_resource(false);
|
|
||||||
run_system(&mut world, sys.config(|config| config.0 = Some(42)));
|
|
||||||
assert!(*world.get_resource::<bool>().unwrap());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -417,7 +409,7 @@ mod tests {
|
||||||
*modified = true;
|
*modified = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
run_system(&mut world, sys.system());
|
run_system(&mut world, sys);
|
||||||
|
|
||||||
// ensure the system actually ran
|
// ensure the system actually ran
|
||||||
assert!(*world.get_resource::<bool>().unwrap());
|
assert!(*world.get_resource::<bool>().unwrap());
|
||||||
|
|
|
@ -24,7 +24,7 @@ impl SystemId {
|
||||||
///
|
///
|
||||||
/// Systems are functions with all arguments implementing [SystemParam](crate::system::SystemParam).
|
/// Systems are functions with all arguments implementing [SystemParam](crate::system::SystemParam).
|
||||||
///
|
///
|
||||||
/// Systems are added to an application using `App::add_system(my_system.system())`
|
/// Systems are added to an application using `App::add_system(my_system)`
|
||||||
/// or similar methods, and will generally run once per pass of the main loop.
|
/// or similar methods, and will generally run once per pass of the main loop.
|
||||||
///
|
///
|
||||||
/// Systems are executed in parallel, in opportunistic order; data access is managed automatically.
|
/// Systems are executed in parallel, in opportunistic order; data access is managed automatically.
|
||||||
|
|
|
@ -7,10 +7,7 @@ pub mod system;
|
||||||
pub mod touch;
|
pub mod touch;
|
||||||
|
|
||||||
pub use axis::*;
|
pub use axis::*;
|
||||||
use bevy_ecs::{
|
use bevy_ecs::schedule::{ParallelSystemDescriptorCoercion, SystemLabel};
|
||||||
schedule::{ParallelSystemDescriptorCoercion, SystemLabel},
|
|
||||||
system::IntoSystem,
|
|
||||||
};
|
|
||||||
pub use input::*;
|
pub use input::*;
|
||||||
|
|
||||||
pub mod prelude {
|
pub mod prelude {
|
||||||
|
@ -52,7 +49,7 @@ impl Plugin for InputPlugin {
|
||||||
.init_resource::<Input<KeyCode>>()
|
.init_resource::<Input<KeyCode>>()
|
||||||
.add_system_to_stage(
|
.add_system_to_stage(
|
||||||
CoreStage::PreUpdate,
|
CoreStage::PreUpdate,
|
||||||
keyboard_input_system.system().label(InputSystem),
|
keyboard_input_system.label(InputSystem),
|
||||||
)
|
)
|
||||||
// mouse
|
// mouse
|
||||||
.add_event::<MouseButtonInput>()
|
.add_event::<MouseButtonInput>()
|
||||||
|
@ -61,7 +58,7 @@ impl Plugin for InputPlugin {
|
||||||
.init_resource::<Input<MouseButton>>()
|
.init_resource::<Input<MouseButton>>()
|
||||||
.add_system_to_stage(
|
.add_system_to_stage(
|
||||||
CoreStage::PreUpdate,
|
CoreStage::PreUpdate,
|
||||||
mouse_button_input_system.system().label(InputSystem),
|
mouse_button_input_system.label(InputSystem),
|
||||||
)
|
)
|
||||||
// gamepad
|
// gamepad
|
||||||
.add_event::<GamepadEvent>()
|
.add_event::<GamepadEvent>()
|
||||||
|
@ -72,14 +69,14 @@ impl Plugin for InputPlugin {
|
||||||
.init_resource::<Axis<GamepadButton>>()
|
.init_resource::<Axis<GamepadButton>>()
|
||||||
.add_system_to_stage(
|
.add_system_to_stage(
|
||||||
CoreStage::PreUpdate,
|
CoreStage::PreUpdate,
|
||||||
gamepad_event_system.system().label(InputSystem),
|
gamepad_event_system.label(InputSystem),
|
||||||
)
|
)
|
||||||
// touch
|
// touch
|
||||||
.add_event::<TouchInput>()
|
.add_event::<TouchInput>()
|
||||||
.init_resource::<Touches>()
|
.init_resource::<Touches>()
|
||||||
.add_system_to_stage(
|
.add_system_to_stage(
|
||||||
CoreStage::PreUpdate,
|
CoreStage::PreUpdate,
|
||||||
touch_screen_input_system.system().label(InputSystem),
|
touch_screen_input_system.label(InputSystem),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,6 @@ pub mod prelude {
|
||||||
|
|
||||||
use bevy_app::prelude::*;
|
use bevy_app::prelude::*;
|
||||||
use bevy_asset::{AddAsset, Assets, Handle};
|
use bevy_asset::{AddAsset, Assets, Handle};
|
||||||
use bevy_ecs::system::IntoSystem;
|
|
||||||
use bevy_render::{prelude::Color, shader};
|
use bevy_render::{prelude::Color, shader};
|
||||||
use material::StandardMaterial;
|
use material::StandardMaterial;
|
||||||
use render_graph::add_pbr_graph;
|
use render_graph::add_pbr_graph;
|
||||||
|
@ -34,7 +33,7 @@ impl Plugin for PbrPlugin {
|
||||||
.register_type::<PointLight>()
|
.register_type::<PointLight>()
|
||||||
.add_system_to_stage(
|
.add_system_to_stage(
|
||||||
CoreStage::PostUpdate,
|
CoreStage::PostUpdate,
|
||||||
shader::asset_shader_defs_system::<StandardMaterial>.system(),
|
shader::asset_shader_defs_system::<StandardMaterial>,
|
||||||
)
|
)
|
||||||
.init_resource::<AmbientLight>();
|
.init_resource::<AmbientLight>();
|
||||||
add_pbr_graph(&mut app.world);
|
add_pbr_graph(&mut app.world);
|
||||||
|
|
|
@ -6,7 +6,7 @@ use crate::{
|
||||||
};
|
};
|
||||||
use bevy_core::{bytes_of, Pod, Zeroable};
|
use bevy_core::{bytes_of, Pod, Zeroable};
|
||||||
use bevy_ecs::{
|
use bevy_ecs::{
|
||||||
system::{BoxedSystem, IntoSystem, Local, Query, Res, ResMut},
|
system::{BoxedSystem, ConfigurableSystem, Local, Query, Res, ResMut},
|
||||||
world::World,
|
world::World,
|
||||||
};
|
};
|
||||||
use bevy_render::{
|
use bevy_render::{
|
||||||
|
@ -59,7 +59,7 @@ struct LightCount {
|
||||||
|
|
||||||
impl SystemNode for LightsNode {
|
impl SystemNode for LightsNode {
|
||||||
fn get_system(&self) -> BoxedSystem {
|
fn get_system(&self) -> BoxedSystem {
|
||||||
let system = lights_node_system.system().config(|config| {
|
let system = lights_node_system.config(|config| {
|
||||||
config.0 = Some(LightsNodeSystemState {
|
config.0 = Some(LightsNodeSystemState {
|
||||||
command_queue: self.command_queue.clone(),
|
command_queue: self.command_queue.clone(),
|
||||||
max_point_lights: self.max_point_lights,
|
max_point_lights: self.max_point_lights,
|
||||||
|
|
|
@ -14,7 +14,7 @@ pub mod wireframe;
|
||||||
|
|
||||||
use bevy_ecs::{
|
use bevy_ecs::{
|
||||||
schedule::{ParallelSystemDescriptorCoercion, SystemStage},
|
schedule::{ParallelSystemDescriptorCoercion, SystemStage},
|
||||||
system::{IntoExclusiveSystem, IntoSystem, Res},
|
system::{IntoExclusiveSystem, Res},
|
||||||
};
|
};
|
||||||
use bevy_transform::TransformSystem;
|
use bevy_transform::TransformSystem;
|
||||||
use bevy_utils::tracing::warn;
|
use bevy_utils::tracing::warn;
|
||||||
|
@ -174,58 +174,38 @@ impl Plugin for RenderPlugin {
|
||||||
.init_resource::<RenderResourceBindings>()
|
.init_resource::<RenderResourceBindings>()
|
||||||
.init_resource::<AssetRenderResourceBindings>()
|
.init_resource::<AssetRenderResourceBindings>()
|
||||||
.init_resource::<ActiveCameras>()
|
.init_resource::<ActiveCameras>()
|
||||||
.add_startup_system_to_stage(
|
.add_startup_system_to_stage(StartupStage::PreStartup, check_for_render_resource_context)
|
||||||
StartupStage::PreStartup,
|
.add_system_to_stage(CoreStage::PreUpdate, draw::clear_draw_system)
|
||||||
check_for_render_resource_context.system(),
|
.add_system_to_stage(CoreStage::PostUpdate, camera::active_cameras_system)
|
||||||
)
|
|
||||||
.add_system_to_stage(CoreStage::PreUpdate, draw::clear_draw_system.system())
|
|
||||||
.add_system_to_stage(
|
.add_system_to_stage(
|
||||||
CoreStage::PostUpdate,
|
CoreStage::PostUpdate,
|
||||||
camera::active_cameras_system.system(),
|
camera::camera_system::<OrthographicProjection>.before(RenderSystem::VisibleEntities),
|
||||||
)
|
)
|
||||||
.add_system_to_stage(
|
.add_system_to_stage(
|
||||||
CoreStage::PostUpdate,
|
CoreStage::PostUpdate,
|
||||||
camera::camera_system::<OrthographicProjection>
|
camera::camera_system::<PerspectiveProjection>.before(RenderSystem::VisibleEntities),
|
||||||
.system()
|
|
||||||
.before(RenderSystem::VisibleEntities),
|
|
||||||
)
|
|
||||||
.add_system_to_stage(
|
|
||||||
CoreStage::PostUpdate,
|
|
||||||
camera::camera_system::<PerspectiveProjection>
|
|
||||||
.system()
|
|
||||||
.before(RenderSystem::VisibleEntities),
|
|
||||||
)
|
)
|
||||||
.add_system_to_stage(
|
.add_system_to_stage(
|
||||||
CoreStage::PostUpdate,
|
CoreStage::PostUpdate,
|
||||||
camera::visible_entities_system
|
camera::visible_entities_system
|
||||||
.system()
|
|
||||||
.label(RenderSystem::VisibleEntities)
|
.label(RenderSystem::VisibleEntities)
|
||||||
.after(TransformSystem::TransformPropagate),
|
.after(TransformSystem::TransformPropagate),
|
||||||
)
|
)
|
||||||
|
.add_system_to_stage(RenderStage::RenderResource, shader::shader_update_system)
|
||||||
.add_system_to_stage(
|
.add_system_to_stage(
|
||||||
RenderStage::RenderResource,
|
RenderStage::RenderResource,
|
||||||
shader::shader_update_system.system(),
|
mesh::mesh_resource_provider_system,
|
||||||
)
|
)
|
||||||
.add_system_to_stage(
|
.add_system_to_stage(
|
||||||
RenderStage::RenderResource,
|
RenderStage::RenderResource,
|
||||||
mesh::mesh_resource_provider_system.system(),
|
Texture::texture_resource_system,
|
||||||
)
|
|
||||||
.add_system_to_stage(
|
|
||||||
RenderStage::RenderResource,
|
|
||||||
Texture::texture_resource_system.system(),
|
|
||||||
)
|
)
|
||||||
.add_system_to_stage(
|
.add_system_to_stage(
|
||||||
RenderStage::RenderGraphSystems,
|
RenderStage::RenderGraphSystems,
|
||||||
render_graph::render_graph_schedule_executor_system.exclusive_system(),
|
render_graph::render_graph_schedule_executor_system.exclusive_system(),
|
||||||
)
|
)
|
||||||
.add_system_to_stage(
|
.add_system_to_stage(RenderStage::Draw, pipeline::draw_render_pipelines_system)
|
||||||
RenderStage::Draw,
|
.add_system_to_stage(RenderStage::PostRender, shader::clear_shader_defs_system);
|
||||||
pipeline::draw_render_pipelines_system.system(),
|
|
||||||
)
|
|
||||||
.add_system_to_stage(
|
|
||||||
RenderStage::PostRender,
|
|
||||||
shader::clear_shader_defs_system.system(),
|
|
||||||
);
|
|
||||||
|
|
||||||
if let Some(ref config) = self.base_render_graph_config {
|
if let Some(ref config) = self.base_render_graph_config {
|
||||||
crate::base::add_base_graph(config, &mut app.world);
|
crate::base::add_base_graph(config, &mut app.world);
|
||||||
|
|
|
@ -8,7 +8,7 @@ use crate::{
|
||||||
};
|
};
|
||||||
use bevy_core::bytes_of;
|
use bevy_core::bytes_of;
|
||||||
use bevy_ecs::{
|
use bevy_ecs::{
|
||||||
system::{BoxedSystem, IntoSystem, Local, Query, Res, ResMut},
|
system::{BoxedSystem, ConfigurableSystem, Local, Query, Res, ResMut},
|
||||||
world::World,
|
world::World,
|
||||||
};
|
};
|
||||||
use bevy_transform::prelude::*;
|
use bevy_transform::prelude::*;
|
||||||
|
@ -46,7 +46,7 @@ impl Node for CameraNode {
|
||||||
|
|
||||||
impl SystemNode for CameraNode {
|
impl SystemNode for CameraNode {
|
||||||
fn get_system(&self) -> BoxedSystem {
|
fn get_system(&self) -> BoxedSystem {
|
||||||
let system = camera_node_system.system().config(|config| {
|
let system = camera_node_system.config(|config| {
|
||||||
config.0 = Some(CameraNodeState {
|
config.0 = Some(CameraNodeState {
|
||||||
camera_name: self.camera_name.clone(),
|
camera_name: self.camera_name.clone(),
|
||||||
command_queue: self.command_queue.clone(),
|
command_queue: self.command_queue.clone(),
|
||||||
|
|
|
@ -14,7 +14,9 @@ use bevy_asset::{Asset, AssetEvent, Assets, Handle, HandleId};
|
||||||
use bevy_ecs::{
|
use bevy_ecs::{
|
||||||
entity::Entity,
|
entity::Entity,
|
||||||
query::{Changed, Or, With},
|
query::{Changed, Or, With},
|
||||||
system::{BoxedSystem, IntoSystem, Local, Query, QuerySet, RemovedComponents, Res, ResMut},
|
system::{
|
||||||
|
BoxedSystem, ConfigurableSystem, Local, Query, QuerySet, RemovedComponents, Res, ResMut,
|
||||||
|
},
|
||||||
world::World,
|
world::World,
|
||||||
};
|
};
|
||||||
use bevy_utils::HashMap;
|
use bevy_utils::HashMap;
|
||||||
|
@ -400,7 +402,7 @@ where
|
||||||
T: renderer::RenderResources,
|
T: renderer::RenderResources,
|
||||||
{
|
{
|
||||||
fn get_system(&self) -> BoxedSystem {
|
fn get_system(&self) -> BoxedSystem {
|
||||||
let system = render_resources_node_system::<T>.system().config(|config| {
|
let system = render_resources_node_system::<T>.config(|config| {
|
||||||
config.0 = Some(RenderResourcesNodeState {
|
config.0 = Some(RenderResourcesNodeState {
|
||||||
command_queue: self.command_queue.clone(),
|
command_queue: self.command_queue.clone(),
|
||||||
uniform_buffer_arrays: UniformBufferArrays::<Entity, T>::default(),
|
uniform_buffer_arrays: UniformBufferArrays::<Entity, T>::default(),
|
||||||
|
@ -583,9 +585,7 @@ where
|
||||||
T: renderer::RenderResources + Asset,
|
T: renderer::RenderResources + Asset,
|
||||||
{
|
{
|
||||||
fn get_system(&self) -> BoxedSystem {
|
fn get_system(&self) -> BoxedSystem {
|
||||||
let system = asset_render_resources_node_system::<T>
|
let system = asset_render_resources_node_system::<T>.config(|config| {
|
||||||
.system()
|
|
||||||
.config(|config| {
|
|
||||||
config.0 = Some(RenderResourcesNodeState {
|
config.0 = Some(RenderResourcesNodeState {
|
||||||
command_queue: self.command_queue.clone(),
|
command_queue: self.command_queue.clone(),
|
||||||
uniform_buffer_arrays: UniformBufferArrays::<HandleId, T>::default(),
|
uniform_buffer_arrays: UniformBufferArrays::<HandleId, T>::default(),
|
||||||
|
|
|
@ -10,7 +10,7 @@ use bevy_asset::{Assets, Handle, HandleUntyped};
|
||||||
use bevy_ecs::{
|
use bevy_ecs::{
|
||||||
query::With,
|
query::With,
|
||||||
reflect::ReflectComponent,
|
reflect::ReflectComponent,
|
||||||
system::{IntoSystem, Query, QuerySet, Res},
|
system::{Query, QuerySet, Res},
|
||||||
world::Mut,
|
world::Mut,
|
||||||
};
|
};
|
||||||
use bevy_reflect::{Reflect, TypeUuid};
|
use bevy_reflect::{Reflect, TypeUuid};
|
||||||
|
@ -27,7 +27,7 @@ pub struct WireframePlugin;
|
||||||
impl Plugin for WireframePlugin {
|
impl Plugin for WireframePlugin {
|
||||||
fn build(&self, app: &mut App) {
|
fn build(&self, app: &mut App) {
|
||||||
app.init_resource::<WireframeConfig>()
|
app.init_resource::<WireframeConfig>()
|
||||||
.add_system_to_stage(crate::RenderStage::Draw, draw_wireframes_system.system());
|
.add_system_to_stage(crate::RenderStage::Draw, draw_wireframes_system);
|
||||||
let world = app.world.cell();
|
let world = app.world.cell();
|
||||||
let mut shaders = world.get_resource_mut::<Assets<Shader>>().unwrap();
|
let mut shaders = world.get_resource_mut::<Assets<Shader>>().unwrap();
|
||||||
let mut pipelines = world
|
let mut pipelines = world
|
||||||
|
|
|
@ -28,10 +28,7 @@ pub use texture_atlas_builder::*;
|
||||||
|
|
||||||
use bevy_app::prelude::*;
|
use bevy_app::prelude::*;
|
||||||
use bevy_asset::{AddAsset, Assets, Handle, HandleUntyped};
|
use bevy_asset::{AddAsset, Assets, Handle, HandleUntyped};
|
||||||
use bevy_ecs::{
|
use bevy_ecs::component::{ComponentDescriptor, StorageType};
|
||||||
component::{ComponentDescriptor, StorageType},
|
|
||||||
system::IntoSystem,
|
|
||||||
};
|
|
||||||
use bevy_math::Vec2;
|
use bevy_math::Vec2;
|
||||||
use bevy_reflect::TypeUuid;
|
use bevy_reflect::TypeUuid;
|
||||||
use bevy_render::{
|
use bevy_render::{
|
||||||
|
@ -72,14 +69,11 @@ impl Plugin for SpritePlugin {
|
||||||
.add_asset::<TextureAtlas>()
|
.add_asset::<TextureAtlas>()
|
||||||
.register_type::<Sprite>()
|
.register_type::<Sprite>()
|
||||||
.register_type::<SpriteResizeMode>()
|
.register_type::<SpriteResizeMode>()
|
||||||
.add_system_to_stage(CoreStage::PostUpdate, sprite_system.system())
|
.add_system_to_stage(CoreStage::PostUpdate, sprite_system)
|
||||||
|
.add_system_to_stage(CoreStage::PostUpdate, material_texture_detection_system)
|
||||||
.add_system_to_stage(
|
.add_system_to_stage(
|
||||||
CoreStage::PostUpdate,
|
CoreStage::PostUpdate,
|
||||||
material_texture_detection_system.system(),
|
asset_shader_defs_system::<ColorMaterial>,
|
||||||
)
|
|
||||||
.add_system_to_stage(
|
|
||||||
CoreStage::PostUpdate,
|
|
||||||
asset_shader_defs_system::<ColorMaterial>.system(),
|
|
||||||
);
|
);
|
||||||
|
|
||||||
let sprite_settings = app
|
let sprite_settings = app
|
||||||
|
@ -89,11 +83,11 @@ impl Plugin for SpritePlugin {
|
||||||
if sprite_settings.frustum_culling_enabled {
|
if sprite_settings.frustum_culling_enabled {
|
||||||
app.add_system_to_stage(
|
app.add_system_to_stage(
|
||||||
CoreStage::PostUpdate,
|
CoreStage::PostUpdate,
|
||||||
frustum_culling::sprite_frustum_culling_system.system(),
|
frustum_culling::sprite_frustum_culling_system,
|
||||||
)
|
)
|
||||||
.add_system_to_stage(
|
.add_system_to_stage(
|
||||||
CoreStage::PostUpdate,
|
CoreStage::PostUpdate,
|
||||||
frustum_culling::atlas_frustum_culling_system.system(),
|
frustum_culling::atlas_frustum_culling_system,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
app.world
|
app.world
|
||||||
|
|
|
@ -29,7 +29,7 @@ pub mod prelude {
|
||||||
|
|
||||||
use bevy_app::prelude::*;
|
use bevy_app::prelude::*;
|
||||||
use bevy_asset::AddAsset;
|
use bevy_asset::AddAsset;
|
||||||
use bevy_ecs::{entity::Entity, system::IntoSystem};
|
use bevy_ecs::entity::Entity;
|
||||||
use bevy_render::RenderStage;
|
use bevy_render::RenderStage;
|
||||||
|
|
||||||
pub type DefaultTextPipeline = TextPipeline<Entity>;
|
pub type DefaultTextPipeline = TextPipeline<Entity>;
|
||||||
|
@ -43,7 +43,7 @@ impl Plugin for TextPlugin {
|
||||||
.add_asset::<FontAtlasSet>()
|
.add_asset::<FontAtlasSet>()
|
||||||
.init_asset_loader::<FontLoader>()
|
.init_asset_loader::<FontLoader>()
|
||||||
.insert_resource(DefaultTextPipeline::default())
|
.insert_resource(DefaultTextPipeline::default())
|
||||||
.add_system_to_stage(CoreStage::PostUpdate, text2d_system.system())
|
.add_system_to_stage(CoreStage::PostUpdate, text2d_system)
|
||||||
.add_system_to_stage(RenderStage::Draw, text2d::draw_text2d_system.system());
|
.add_system_to_stage(RenderStage::Draw, text2d::draw_text2d_system);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,7 +75,7 @@ pub fn parent_update_system(
|
||||||
mod test {
|
mod test {
|
||||||
use bevy_ecs::{
|
use bevy_ecs::{
|
||||||
schedule::{Schedule, Stage, SystemStage},
|
schedule::{Schedule, Stage, SystemStage},
|
||||||
system::{CommandQueue, IntoSystem},
|
system::CommandQueue,
|
||||||
world::World,
|
world::World,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -87,8 +87,8 @@ mod test {
|
||||||
let mut world = World::default();
|
let mut world = World::default();
|
||||||
|
|
||||||
let mut update_stage = SystemStage::parallel();
|
let mut update_stage = SystemStage::parallel();
|
||||||
update_stage.add_system(parent_update_system.system());
|
update_stage.add_system(parent_update_system);
|
||||||
update_stage.add_system(transform_propagate_system.system());
|
update_stage.add_system(transform_propagate_system);
|
||||||
|
|
||||||
let mut schedule = Schedule::default();
|
let mut schedule = Schedule::default();
|
||||||
schedule.add_stage("update", update_stage);
|
schedule.add_stage("update", update_stage);
|
||||||
|
|
|
@ -8,10 +8,7 @@ pub mod prelude {
|
||||||
}
|
}
|
||||||
|
|
||||||
use bevy_app::prelude::*;
|
use bevy_app::prelude::*;
|
||||||
use bevy_ecs::{
|
use bevy_ecs::schedule::{ParallelSystemDescriptorCoercion, SystemLabel};
|
||||||
schedule::{ParallelSystemDescriptorCoercion, SystemLabel},
|
|
||||||
system::IntoSystem,
|
|
||||||
};
|
|
||||||
use prelude::{parent_update_system, Children, GlobalTransform, Parent, PreviousParent, Transform};
|
use prelude::{parent_update_system, Children, GlobalTransform, Parent, PreviousParent, Transform};
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
|
@ -33,27 +30,21 @@ impl Plugin for TransformPlugin {
|
||||||
// add transform systems to startup so the first update is "correct"
|
// add transform systems to startup so the first update is "correct"
|
||||||
.add_startup_system_to_stage(
|
.add_startup_system_to_stage(
|
||||||
StartupStage::PostStartup,
|
StartupStage::PostStartup,
|
||||||
parent_update_system
|
parent_update_system.label(TransformSystem::ParentUpdate),
|
||||||
.system()
|
|
||||||
.label(TransformSystem::ParentUpdate),
|
|
||||||
)
|
)
|
||||||
.add_startup_system_to_stage(
|
.add_startup_system_to_stage(
|
||||||
StartupStage::PostStartup,
|
StartupStage::PostStartup,
|
||||||
transform_propagate_system::transform_propagate_system
|
transform_propagate_system::transform_propagate_system
|
||||||
.system()
|
|
||||||
.label(TransformSystem::TransformPropagate)
|
.label(TransformSystem::TransformPropagate)
|
||||||
.after(TransformSystem::ParentUpdate),
|
.after(TransformSystem::ParentUpdate),
|
||||||
)
|
)
|
||||||
.add_system_to_stage(
|
.add_system_to_stage(
|
||||||
CoreStage::PostUpdate,
|
CoreStage::PostUpdate,
|
||||||
parent_update_system
|
parent_update_system.label(TransformSystem::ParentUpdate),
|
||||||
.system()
|
|
||||||
.label(TransformSystem::ParentUpdate),
|
|
||||||
)
|
)
|
||||||
.add_system_to_stage(
|
.add_system_to_stage(
|
||||||
CoreStage::PostUpdate,
|
CoreStage::PostUpdate,
|
||||||
transform_propagate_system::transform_propagate_system
|
transform_propagate_system::transform_propagate_system
|
||||||
.system()
|
|
||||||
.label(TransformSystem::TransformPropagate)
|
.label(TransformSystem::TransformPropagate)
|
||||||
.after(TransformSystem::ParentUpdate),
|
.after(TransformSystem::ParentUpdate),
|
||||||
);
|
);
|
||||||
|
|
|
@ -77,7 +77,7 @@ fn propagate_recursive(
|
||||||
mod test {
|
mod test {
|
||||||
use bevy_ecs::{
|
use bevy_ecs::{
|
||||||
schedule::{Schedule, Stage, SystemStage},
|
schedule::{Schedule, Stage, SystemStage},
|
||||||
system::{CommandQueue, Commands, IntoSystem},
|
system::{CommandQueue, Commands},
|
||||||
world::World,
|
world::World,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -89,8 +89,8 @@ mod test {
|
||||||
let mut world = World::default();
|
let mut world = World::default();
|
||||||
|
|
||||||
let mut update_stage = SystemStage::parallel();
|
let mut update_stage = SystemStage::parallel();
|
||||||
update_stage.add_system(parent_update_system.system());
|
update_stage.add_system(parent_update_system);
|
||||||
update_stage.add_system(transform_propagate_system.system());
|
update_stage.add_system(transform_propagate_system);
|
||||||
|
|
||||||
let mut schedule = Schedule::default();
|
let mut schedule = Schedule::default();
|
||||||
schedule.add_stage("update", update_stage);
|
schedule.add_stage("update", update_stage);
|
||||||
|
@ -144,8 +144,8 @@ mod test {
|
||||||
let mut world = World::default();
|
let mut world = World::default();
|
||||||
|
|
||||||
let mut update_stage = SystemStage::parallel();
|
let mut update_stage = SystemStage::parallel();
|
||||||
update_stage.add_system(parent_update_system.system());
|
update_stage.add_system(parent_update_system);
|
||||||
update_stage.add_system(transform_propagate_system.system());
|
update_stage.add_system(transform_propagate_system);
|
||||||
|
|
||||||
let mut schedule = Schedule::default();
|
let mut schedule = Schedule::default();
|
||||||
schedule.add_stage("update", update_stage);
|
schedule.add_stage("update", update_stage);
|
||||||
|
|
|
@ -22,10 +22,7 @@ pub mod prelude {
|
||||||
}
|
}
|
||||||
|
|
||||||
use bevy_app::prelude::*;
|
use bevy_app::prelude::*;
|
||||||
use bevy_ecs::{
|
use bevy_ecs::schedule::{ParallelSystemDescriptorCoercion, SystemLabel};
|
||||||
schedule::{ParallelSystemDescriptorCoercion, SystemLabel},
|
|
||||||
system::IntoSystem,
|
|
||||||
};
|
|
||||||
use bevy_input::InputSystem;
|
use bevy_input::InputSystem;
|
||||||
use bevy_math::{Rect, Size};
|
use bevy_math::{Rect, Size};
|
||||||
use bevy_render::RenderStage;
|
use bevy_render::RenderStage;
|
||||||
|
@ -62,35 +59,30 @@ impl Plugin for UiPlugin {
|
||||||
.register_type::<Val>()
|
.register_type::<Val>()
|
||||||
.add_system_to_stage(
|
.add_system_to_stage(
|
||||||
CoreStage::PreUpdate,
|
CoreStage::PreUpdate,
|
||||||
ui_focus_system
|
ui_focus_system.label(UiSystem::Focus).after(InputSystem),
|
||||||
.system()
|
|
||||||
.label(UiSystem::Focus)
|
|
||||||
.after(InputSystem),
|
|
||||||
)
|
)
|
||||||
// add these stages to front because these must run before transform update systems
|
// add these stages to front because these must run before transform update systems
|
||||||
.add_system_to_stage(
|
.add_system_to_stage(
|
||||||
CoreStage::PostUpdate,
|
CoreStage::PostUpdate,
|
||||||
widget::text_system.system().before(UiSystem::Flex),
|
widget::text_system.before(UiSystem::Flex),
|
||||||
)
|
)
|
||||||
.add_system_to_stage(
|
.add_system_to_stage(
|
||||||
CoreStage::PostUpdate,
|
CoreStage::PostUpdate,
|
||||||
widget::image_node_system.system().before(UiSystem::Flex),
|
widget::image_node_system.before(UiSystem::Flex),
|
||||||
)
|
)
|
||||||
.add_system_to_stage(
|
.add_system_to_stage(
|
||||||
CoreStage::PostUpdate,
|
CoreStage::PostUpdate,
|
||||||
flex_node_system
|
flex_node_system
|
||||||
.system()
|
|
||||||
.label(UiSystem::Flex)
|
.label(UiSystem::Flex)
|
||||||
.before(TransformSystem::TransformPropagate),
|
.before(TransformSystem::TransformPropagate),
|
||||||
)
|
)
|
||||||
.add_system_to_stage(
|
.add_system_to_stage(
|
||||||
CoreStage::PostUpdate,
|
CoreStage::PostUpdate,
|
||||||
ui_z_system
|
ui_z_system
|
||||||
.system()
|
|
||||||
.after(UiSystem::Flex)
|
.after(UiSystem::Flex)
|
||||||
.before(TransformSystem::TransformPropagate),
|
.before(TransformSystem::TransformPropagate),
|
||||||
)
|
)
|
||||||
.add_system_to_stage(RenderStage::Draw, widget::draw_text_system.system());
|
.add_system_to_stage(RenderStage::Draw, widget::draw_text_system);
|
||||||
|
|
||||||
crate::render::add_ui_graph(&mut app.world);
|
crate::render::add_ui_graph(&mut app.world);
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,7 +54,7 @@ fn update_hierarchy(
|
||||||
mod tests {
|
mod tests {
|
||||||
use bevy_ecs::{
|
use bevy_ecs::{
|
||||||
schedule::{Schedule, Stage, SystemStage},
|
schedule::{Schedule, Stage, SystemStage},
|
||||||
system::{CommandQueue, Commands, IntoSystem},
|
system::{CommandQueue, Commands},
|
||||||
world::World,
|
world::World,
|
||||||
};
|
};
|
||||||
use bevy_transform::{components::Transform, hierarchy::BuildChildren};
|
use bevy_transform::{components::Transform, hierarchy::BuildChildren};
|
||||||
|
@ -122,7 +122,7 @@ mod tests {
|
||||||
|
|
||||||
let mut schedule = Schedule::default();
|
let mut schedule = Schedule::default();
|
||||||
let mut update_stage = SystemStage::parallel();
|
let mut update_stage = SystemStage::parallel();
|
||||||
update_stage.add_system(ui_z_system.system());
|
update_stage.add_system(ui_z_system);
|
||||||
schedule.add_stage("update", update_stage);
|
schedule.add_stage("update", update_stage);
|
||||||
schedule.run(&mut world);
|
schedule.run(&mut world);
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use crate::renderer::WgpuRenderResourceContext;
|
use crate::renderer::WgpuRenderResourceContext;
|
||||||
use bevy_app::prelude::*;
|
use bevy_app::prelude::*;
|
||||||
use bevy_diagnostic::{Diagnostic, DiagnosticId, Diagnostics};
|
use bevy_diagnostic::{Diagnostic, DiagnosticId, Diagnostics};
|
||||||
use bevy_ecs::system::{IntoSystem, Res, ResMut};
|
use bevy_ecs::system::{Res, ResMut};
|
||||||
use bevy_render::renderer::RenderResourceContext;
|
use bevy_render::renderer::RenderResourceContext;
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
|
@ -9,8 +9,8 @@ pub struct WgpuResourceDiagnosticsPlugin;
|
||||||
|
|
||||||
impl Plugin for WgpuResourceDiagnosticsPlugin {
|
impl Plugin for WgpuResourceDiagnosticsPlugin {
|
||||||
fn build(&self, app: &mut App) {
|
fn build(&self, app: &mut App) {
|
||||||
app.add_startup_system(Self::setup_system.system())
|
app.add_startup_system(Self::setup_system)
|
||||||
.add_system(Self::diagnostic_system.system());
|
.add_system(Self::diagnostic_system);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,10 +10,7 @@ pub use wgpu_renderer::*;
|
||||||
pub use wgpu_resources::*;
|
pub use wgpu_resources::*;
|
||||||
|
|
||||||
use bevy_app::prelude::*;
|
use bevy_app::prelude::*;
|
||||||
use bevy_ecs::{
|
use bevy_ecs::{system::IntoExclusiveSystem, world::World};
|
||||||
system::{IntoExclusiveSystem, IntoSystem},
|
|
||||||
world::World,
|
|
||||||
};
|
|
||||||
use bevy_render::{
|
use bevy_render::{
|
||||||
renderer::{shared_buffers_update_system, RenderResourceContext, SharedBuffers},
|
renderer::{shared_buffers_update_system, RenderResourceContext, SharedBuffers},
|
||||||
RenderStage,
|
RenderStage,
|
||||||
|
@ -107,10 +104,7 @@ impl Plugin for WgpuPlugin {
|
||||||
fn build(&self, app: &mut App) {
|
fn build(&self, app: &mut App) {
|
||||||
let render_system = get_wgpu_render_system(&mut app.world);
|
let render_system = get_wgpu_render_system(&mut app.world);
|
||||||
app.add_system_to_stage(RenderStage::Render, render_system.exclusive_system())
|
app.add_system_to_stage(RenderStage::Render, render_system.exclusive_system())
|
||||||
.add_system_to_stage(
|
.add_system_to_stage(RenderStage::PostRender, shared_buffers_update_system);
|
||||||
RenderStage::PostRender,
|
|
||||||
shared_buffers_update_system.system(),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,6 @@ mod system;
|
||||||
mod window;
|
mod window;
|
||||||
mod windows;
|
mod windows;
|
||||||
|
|
||||||
use bevy_ecs::system::IntoSystem;
|
|
||||||
pub use event::*;
|
pub use event::*;
|
||||||
pub use system::*;
|
pub use system::*;
|
||||||
pub use window::*;
|
pub use window::*;
|
||||||
|
@ -68,7 +67,7 @@ impl Plugin for WindowPlugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
if self.exit_on_close {
|
if self.exit_on_close {
|
||||||
app.add_system(exit_on_window_close_system.system());
|
app.add_system(exit_on_window_close_system);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,8 +24,8 @@ fn main() {
|
||||||
})
|
})
|
||||||
.add_plugins(DefaultPlugins)
|
.add_plugins(DefaultPlugins)
|
||||||
.add_startup_system(setup)
|
.add_startup_system(setup)
|
||||||
.add_system(tick.system().label("Tick"))
|
.add_system(tick.label("Tick"))
|
||||||
.add_system(move_camera.system().after("Tick"))
|
.add_system(move_camera.after("Tick"))
|
||||||
.run()
|
.run()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ fn main() {
|
||||||
App::new()
|
App::new()
|
||||||
.insert_resource(Msaa { samples: 4 })
|
.insert_resource(Msaa { samples: 4 })
|
||||||
.add_plugins(DefaultPlugins)
|
.add_plugins(DefaultPlugins)
|
||||||
.add_startup_system(setup.system())
|
.add_startup_system(setup)
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,8 +8,8 @@ fn main() {
|
||||||
})
|
})
|
||||||
.insert_resource(Msaa { samples: 4 })
|
.insert_resource(Msaa { samples: 4 })
|
||||||
.add_plugins(DefaultPlugins)
|
.add_plugins(DefaultPlugins)
|
||||||
.add_startup_system(setup.system())
|
.add_startup_system(setup)
|
||||||
.add_system(rotator_system.system())
|
.add_system(rotator_system)
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ fn main() {
|
||||||
App::new()
|
App::new()
|
||||||
.insert_resource(Msaa { samples: 4 })
|
.insert_resource(Msaa { samples: 4 })
|
||||||
.add_plugins(DefaultPlugins)
|
.add_plugins(DefaultPlugins)
|
||||||
.add_startup_system(setup.system())
|
.add_startup_system(setup)
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ fn main() {
|
||||||
App::new()
|
App::new()
|
||||||
.insert_resource(Msaa { samples: 4 })
|
.insert_resource(Msaa { samples: 4 })
|
||||||
.add_plugins(DefaultPlugins)
|
.add_plugins(DefaultPlugins)
|
||||||
.add_startup_system(setup.system())
|
.add_startup_system(setup)
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,8 +6,8 @@ fn main() {
|
||||||
App::new()
|
App::new()
|
||||||
.insert_resource(Msaa { samples: 4 })
|
.insert_resource(Msaa { samples: 4 })
|
||||||
.add_plugins(DefaultPlugins)
|
.add_plugins(DefaultPlugins)
|
||||||
.add_startup_system(setup.system())
|
.add_startup_system(setup)
|
||||||
.add_system(rotator_system.system())
|
.add_system(rotator_system)
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ fn main() {
|
||||||
App::new()
|
App::new()
|
||||||
.insert_resource(Msaa { samples: 4 })
|
.insert_resource(Msaa { samples: 4 })
|
||||||
.add_plugins(DefaultPlugins)
|
.add_plugins(DefaultPlugins)
|
||||||
.add_startup_system(setup.system())
|
.add_startup_system(setup)
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -226,8 +226,8 @@ fn setup(
|
||||||
fn main() {
|
fn main() {
|
||||||
let mut app = App::new();
|
let mut app = App::new();
|
||||||
app.add_plugins(DefaultPlugins)
|
app.add_plugins(DefaultPlugins)
|
||||||
.add_startup_system(setup.system())
|
.add_startup_system(setup)
|
||||||
.add_system(cube_rotator_system.system())
|
.add_system(cube_rotator_system)
|
||||||
.add_system(rotator_system.system())
|
.add_system(rotator_system)
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,8 +17,8 @@ fn main() {
|
||||||
.add_plugins(DefaultPlugins)
|
.add_plugins(DefaultPlugins)
|
||||||
.add_plugin(FrameTimeDiagnosticsPlugin::default())
|
.add_plugin(FrameTimeDiagnosticsPlugin::default())
|
||||||
.add_plugin(LogDiagnosticsPlugin::default())
|
.add_plugin(LogDiagnosticsPlugin::default())
|
||||||
.add_startup_system(setup.system())
|
.add_startup_system(setup)
|
||||||
.add_system(move_cubes.system())
|
.add_system(move_cubes)
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ use bevy::prelude::*;
|
||||||
fn main() {
|
fn main() {
|
||||||
App::new()
|
App::new()
|
||||||
.add_plugins(DefaultPlugins)
|
.add_plugins(DefaultPlugins)
|
||||||
.add_startup_system(setup.system())
|
.add_startup_system(setup)
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,9 +5,9 @@ fn main() {
|
||||||
.insert_resource(Msaa { samples: 4 })
|
.insert_resource(Msaa { samples: 4 })
|
||||||
.add_plugins(DefaultPlugins)
|
.add_plugins(DefaultPlugins)
|
||||||
.insert_resource(SceneInstance::default())
|
.insert_resource(SceneInstance::default())
|
||||||
.add_startup_system(setup.system())
|
.add_startup_system(setup)
|
||||||
.add_system(scene_update.system())
|
.add_system(scene_update)
|
||||||
.add_system(move_scene_entities.system())
|
.add_system(move_scene_entities)
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ fn main() {
|
||||||
})
|
})
|
||||||
.add_plugins(DefaultPlugins)
|
.add_plugins(DefaultPlugins)
|
||||||
.add_plugin(WireframePlugin)
|
.add_plugin(WireframePlugin)
|
||||||
.add_startup_system(setup.system())
|
.add_startup_system(setup)
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,9 +11,9 @@ use bevy::{
|
||||||
fn main() {
|
fn main() {
|
||||||
App::new()
|
App::new()
|
||||||
.add_plugins(DefaultPlugins)
|
.add_plugins(DefaultPlugins)
|
||||||
.add_startup_system(setup.system())
|
.add_startup_system(setup)
|
||||||
.add_system(rotator_system.system())
|
.add_system(rotator_system)
|
||||||
.add_system(camera_order_color_system.system())
|
.add_system(camera_order_color_system)
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ fn main() {
|
||||||
App::new()
|
App::new()
|
||||||
.insert_resource(Msaa { samples: 2 })
|
.insert_resource(Msaa { samples: 2 })
|
||||||
.add_plugins(DefaultPlugins)
|
.add_plugins(DefaultPlugins)
|
||||||
.add_startup_system(setup.system())
|
.add_startup_system(setup)
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,6 @@ fn main() {
|
||||||
App::new()
|
App::new()
|
||||||
.insert_resource(Input(String::new()))
|
.insert_resource(Input(String::new()))
|
||||||
.set_runner(my_runner)
|
.set_runner(my_runner)
|
||||||
.add_system(print_system.system())
|
.add_system(print_system)
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@ use bevy::prelude::*;
|
||||||
fn main() {
|
fn main() {
|
||||||
App::new()
|
App::new()
|
||||||
.add_plugins(DefaultPlugins)
|
.add_plugins(DefaultPlugins)
|
||||||
.add_system(file_drag_and_drop_system.system())
|
.add_system(file_drag_and_drop_system)
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@ fn main() {
|
||||||
App::new()
|
App::new()
|
||||||
.insert_resource(ScheduleRunnerSettings::run_once())
|
.insert_resource(ScheduleRunnerSettings::run_once())
|
||||||
.add_plugins(MinimalPlugins)
|
.add_plugins(MinimalPlugins)
|
||||||
.add_system(hello_world_system.system())
|
.add_system(hello_world_system)
|
||||||
.run();
|
.run();
|
||||||
|
|
||||||
// this app loops forever at 60 fps
|
// this app loops forever at 60 fps
|
||||||
|
@ -22,7 +22,7 @@ fn main() {
|
||||||
1.0 / 60.0,
|
1.0 / 60.0,
|
||||||
)))
|
)))
|
||||||
.add_plugins(MinimalPlugins)
|
.add_plugins(MinimalPlugins)
|
||||||
.add_system(counter.system())
|
.add_system(counter)
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ fn main() {
|
||||||
// filter: "wgpu=warn,bevy_ecs=info".to_string(),
|
// filter: "wgpu=warn,bevy_ecs=info".to_string(),
|
||||||
// })
|
// })
|
||||||
.add_plugins(DefaultPlugins)
|
.add_plugins(DefaultPlugins)
|
||||||
.add_system(log_system.system())
|
.add_system(log_system)
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,8 +28,7 @@ impl Plugin for PrintMessagePlugin {
|
||||||
message: self.message.clone(),
|
message: self.message.clone(),
|
||||||
timer: Timer::new(self.wait_duration, true),
|
timer: Timer::new(self.wait_duration, true),
|
||||||
};
|
};
|
||||||
app.insert_resource(state)
|
app.insert_resource(state).add_system(print_message_system);
|
||||||
.add_system(print_message_system.system());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@ pub struct PrintHelloPlugin;
|
||||||
|
|
||||||
impl Plugin for PrintHelloPlugin {
|
impl Plugin for PrintHelloPlugin {
|
||||||
fn build(&self, app: &mut App) {
|
fn build(&self, app: &mut App) {
|
||||||
app.add_system(print_hello_system.system());
|
app.add_system(print_hello_system);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ pub struct PrintWorldPlugin;
|
||||||
|
|
||||||
impl Plugin for PrintWorldPlugin {
|
impl Plugin for PrintWorldPlugin {
|
||||||
fn build(&self, app: &mut App) {
|
fn build(&self, app: &mut App) {
|
||||||
app.add_system(print_world_system.system());
|
app.add_system(print_world_system);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ fn main() {
|
||||||
})
|
})
|
||||||
.insert_resource(ClearColor(Color::rgb(0.2, 0.2, 0.8)))
|
.insert_resource(ClearColor(Color::rgb(0.2, 0.2, 0.8)))
|
||||||
.add_plugins(DefaultPlugins)
|
.add_plugins(DefaultPlugins)
|
||||||
.add_system(system1.system())
|
.add_system(system1)
|
||||||
.run();
|
.run();
|
||||||
println!("Running another App.");
|
println!("Running another App.");
|
||||||
App::new()
|
App::new()
|
||||||
|
@ -19,7 +19,7 @@ fn main() {
|
||||||
.add_plugins_with(DefaultPlugins, |group| {
|
.add_plugins_with(DefaultPlugins, |group| {
|
||||||
group.disable::<bevy::log::LogPlugin>()
|
group.disable::<bevy::log::LogPlugin>()
|
||||||
})
|
})
|
||||||
.add_system(system2.system())
|
.add_system(system2)
|
||||||
.run();
|
.run();
|
||||||
println!("Done.");
|
println!("Done.");
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@ fn main() {
|
||||||
App::new()
|
App::new()
|
||||||
.insert_resource(Msaa { samples: 4 })
|
.insert_resource(Msaa { samples: 4 })
|
||||||
.add_plugins(DefaultPlugins)
|
.add_plugins(DefaultPlugins)
|
||||||
.add_startup_system(setup.system())
|
.add_startup_system(setup)
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,8 +39,8 @@ fn main() {
|
||||||
.init_resource::<State>()
|
.init_resource::<State>()
|
||||||
.add_asset::<CustomAsset>()
|
.add_asset::<CustomAsset>()
|
||||||
.init_asset_loader::<CustomAssetLoader>()
|
.init_asset_loader::<CustomAssetLoader>()
|
||||||
.add_startup_system(setup.system())
|
.add_startup_system(setup)
|
||||||
.add_system(print_on_load.system())
|
.add_system(print_on_load)
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -85,7 +85,7 @@ fn main() {
|
||||||
// asset system are initialized correctly.
|
// asset system are initialized correctly.
|
||||||
group.add_before::<bevy::asset::AssetPlugin, _>(CustomAssetIoPlugin)
|
group.add_before::<bevy::asset::AssetPlugin, _>(CustomAssetIoPlugin)
|
||||||
})
|
})
|
||||||
.add_startup_system(setup.system())
|
.add_startup_system(setup)
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ use bevy::prelude::*;
|
||||||
fn main() {
|
fn main() {
|
||||||
App::new()
|
App::new()
|
||||||
.add_plugins(DefaultPlugins)
|
.add_plugins(DefaultPlugins)
|
||||||
.add_startup_system(setup.system())
|
.add_startup_system(setup)
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,10 +12,10 @@ fn main() {
|
||||||
App::new()
|
App::new()
|
||||||
.insert_resource(Msaa { samples: 4 })
|
.insert_resource(Msaa { samples: 4 })
|
||||||
.add_plugins(DefaultPlugins)
|
.add_plugins(DefaultPlugins)
|
||||||
.add_startup_system(setup_env.system())
|
.add_startup_system(setup_env)
|
||||||
.add_startup_system(add_assets.system())
|
.add_startup_system(add_assets)
|
||||||
.add_startup_system(spawn_tasks.system())
|
.add_startup_system(spawn_tasks)
|
||||||
.add_system(handle_tasks.system())
|
.add_system(handle_tasks)
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ use bevy::prelude::*;
|
||||||
fn main() {
|
fn main() {
|
||||||
App::new()
|
App::new()
|
||||||
.add_plugins(DefaultPlugins)
|
.add_plugins(DefaultPlugins)
|
||||||
.add_startup_system(setup.system())
|
.add_startup_system(setup)
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,8 +10,8 @@ fn main() {
|
||||||
// The "print diagnostics" plugin is optional. It just visualizes our diagnostics in the
|
// The "print diagnostics" plugin is optional. It just visualizes our diagnostics in the
|
||||||
// console
|
// console
|
||||||
.add_plugin(LogDiagnosticsPlugin::default())
|
.add_plugin(LogDiagnosticsPlugin::default())
|
||||||
.add_startup_system(setup_diagnostic_system.system())
|
.add_startup_system(setup_diagnostic_system)
|
||||||
.add_system(my_system.system())
|
.add_system(my_system)
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,10 +5,10 @@ use rand::Rng;
|
||||||
fn main() {
|
fn main() {
|
||||||
App::new()
|
App::new()
|
||||||
.add_plugins(DefaultPlugins)
|
.add_plugins(DefaultPlugins)
|
||||||
.add_startup_system(setup.system())
|
.add_startup_system(setup)
|
||||||
.add_system(change_component.system())
|
.add_system(change_component)
|
||||||
.add_system(change_detection.system())
|
.add_system(change_detection)
|
||||||
.add_system(tracker_monitoring.system())
|
.add_system(tracker_monitoring)
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,8 +7,8 @@ fn main() {
|
||||||
.add_plugins(DefaultPlugins)
|
.add_plugins(DefaultPlugins)
|
||||||
.add_event::<MyEvent>()
|
.add_event::<MyEvent>()
|
||||||
.init_resource::<EventTriggerState>()
|
.init_resource::<EventTriggerState>()
|
||||||
.add_system(event_trigger_system.system())
|
.add_system(event_trigger_system)
|
||||||
.add_system(event_listener_system.system())
|
.add_system(event_listener_system)
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ fn main() {
|
||||||
App::new()
|
App::new()
|
||||||
.add_plugins(DefaultPlugins)
|
.add_plugins(DefaultPlugins)
|
||||||
// this system will run once every update (it should match your screen's refresh rate)
|
// this system will run once every update (it should match your screen's refresh rate)
|
||||||
.add_system(frame_update.system())
|
.add_system(frame_update)
|
||||||
// add a new stage that runs twice a second
|
// add a new stage that runs twice a second
|
||||||
.add_stage_after(
|
.add_stage_after(
|
||||||
CoreStage::Update,
|
CoreStage::Update,
|
||||||
|
@ -24,7 +24,7 @@ fn main() {
|
||||||
// FixedTimestep state from within a system
|
// FixedTimestep state from within a system
|
||||||
.with_label(LABEL),
|
.with_label(LABEL),
|
||||||
)
|
)
|
||||||
.with_system(fixed_update.system()),
|
.with_system(fixed_update),
|
||||||
)
|
)
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,8 +3,8 @@ use bevy::prelude::*;
|
||||||
fn main() {
|
fn main() {
|
||||||
App::new()
|
App::new()
|
||||||
.add_plugins(DefaultPlugins)
|
.add_plugins(DefaultPlugins)
|
||||||
.add_startup_system(setup.system())
|
.add_startup_system(setup)
|
||||||
.add_system(rotate.system())
|
.add_system(rotate)
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,14 +10,14 @@ fn main() {
|
||||||
App::new()
|
App::new()
|
||||||
.insert_resource(Msaa { samples: 4 })
|
.insert_resource(Msaa { samples: 4 })
|
||||||
.add_plugins(DefaultPlugins)
|
.add_plugins(DefaultPlugins)
|
||||||
.add_startup_system(generate_bodies.system())
|
.add_startup_system(generate_bodies)
|
||||||
.add_stage_after(
|
.add_stage_after(
|
||||||
CoreStage::Update,
|
CoreStage::Update,
|
||||||
FixedUpdateStage,
|
FixedUpdateStage,
|
||||||
SystemStage::parallel()
|
SystemStage::parallel()
|
||||||
.with_run_criteria(FixedTimestep::step(DELTA_TIME))
|
.with_run_criteria(FixedTimestep::step(DELTA_TIME))
|
||||||
.with_system(interact_bodies.system())
|
.with_system(interact_bodies)
|
||||||
.with_system(integrate.system()),
|
.with_system(integrate),
|
||||||
)
|
)
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,8 +70,8 @@ fn bounce_system(
|
||||||
fn main() {
|
fn main() {
|
||||||
App::new()
|
App::new()
|
||||||
.add_plugins(DefaultPlugins)
|
.add_plugins(DefaultPlugins)
|
||||||
.add_startup_system(spawn_system.system())
|
.add_startup_system(spawn_system)
|
||||||
.add_system(move_system.system())
|
.add_system(move_system)
|
||||||
.add_system(bounce_system.system())
|
.add_system(bounce_system)
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,9 +3,9 @@ use bevy::{log::LogPlugin, prelude::*};
|
||||||
fn main() {
|
fn main() {
|
||||||
App::new()
|
App::new()
|
||||||
.add_plugin(LogPlugin)
|
.add_plugin(LogPlugin)
|
||||||
.add_startup_system(setup.system())
|
.add_startup_system(setup)
|
||||||
.add_system(log_names.system().label(LogNamesSystem))
|
.add_system(log_names.label(LogNamesSystem))
|
||||||
.add_system(log_person_bundles.system().after(LogNamesSystem))
|
.add_system(log_person_bundles.after(LogNamesSystem))
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,9 +15,9 @@ fn main() {
|
||||||
// `CoreStage::PostUpdate` stage.
|
// `CoreStage::PostUpdate` stage.
|
||||||
App::new()
|
App::new()
|
||||||
.add_plugins(DefaultPlugins)
|
.add_plugins(DefaultPlugins)
|
||||||
.add_startup_system(setup.system())
|
.add_startup_system(setup)
|
||||||
.add_system_to_stage(CoreStage::Update, remove_component.system())
|
.add_system_to_stage(CoreStage::Update, remove_component)
|
||||||
.add_system_to_stage(CoreStage::PostUpdate, react_on_removal.system())
|
.add_system_to_stage(CoreStage::PostUpdate, react_on_removal)
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,8 +2,8 @@ use bevy::prelude::*;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
App::new()
|
App::new()
|
||||||
.add_startup_system(startup_system.system())
|
.add_startup_system(startup_system)
|
||||||
.add_system(normal_system.system())
|
.add_system(normal_system)
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,14 +7,14 @@ fn main() {
|
||||||
.add_plugins(DefaultPlugins)
|
.add_plugins(DefaultPlugins)
|
||||||
.init_resource::<ButtonMaterials>()
|
.init_resource::<ButtonMaterials>()
|
||||||
.add_state(AppState::Menu)
|
.add_state(AppState::Menu)
|
||||||
.add_system_set(SystemSet::on_enter(AppState::Menu).with_system(setup_menu.system()))
|
.add_system_set(SystemSet::on_enter(AppState::Menu).with_system(setup_menu))
|
||||||
.add_system_set(SystemSet::on_update(AppState::Menu).with_system(menu.system()))
|
.add_system_set(SystemSet::on_update(AppState::Menu).with_system(menu))
|
||||||
.add_system_set(SystemSet::on_exit(AppState::Menu).with_system(cleanup_menu.system()))
|
.add_system_set(SystemSet::on_exit(AppState::Menu).with_system(cleanup_menu))
|
||||||
.add_system_set(SystemSet::on_enter(AppState::InGame).with_system(setup_game.system()))
|
.add_system_set(SystemSet::on_enter(AppState::InGame).with_system(setup_game))
|
||||||
.add_system_set(
|
.add_system_set(
|
||||||
SystemSet::on_update(AppState::InGame)
|
SystemSet::on_update(AppState::InGame)
|
||||||
.with_system(movement.system())
|
.with_system(movement)
|
||||||
.with_system(change_color.system()),
|
.with_system(change_color),
|
||||||
)
|
)
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@ use bevy::prelude::*;
|
||||||
fn main() {
|
fn main() {
|
||||||
App::new()
|
App::new()
|
||||||
.insert_resource(Message("42".to_string()))
|
.insert_resource(Message("42".to_string()))
|
||||||
.add_system(parse_message_system.system().chain(handler_system.system()))
|
.add_system(parse_message_system.chain(handler_system))
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,8 +4,8 @@ use bevy::{ecs::system::SystemParam, prelude::*};
|
||||||
fn main() {
|
fn main() {
|
||||||
App::new()
|
App::new()
|
||||||
.insert_resource(PlayerCount(0))
|
.insert_resource(PlayerCount(0))
|
||||||
.add_startup_system(spawn.system())
|
.add_startup_system(spawn)
|
||||||
.add_system(count_players.system())
|
.add_system(count_players)
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -63,16 +63,14 @@ fn main() {
|
||||||
.label(Physics)
|
.label(Physics)
|
||||||
// This criteria ensures this whole system set only runs when this system's
|
// This criteria ensures this whole system set only runs when this system's
|
||||||
// output says so (ShouldRun::Yes)
|
// output says so (ShouldRun::Yes)
|
||||||
.with_run_criteria(run_for_a_second.system())
|
.with_run_criteria(run_for_a_second)
|
||||||
.with_system(
|
.with_system(
|
||||||
update_velocity
|
update_velocity
|
||||||
.system()
|
|
||||||
// Only applied to the `update_velocity` system
|
// Only applied to the `update_velocity` system
|
||||||
.label(PhysicsSystem::UpdateVelocity),
|
.label(PhysicsSystem::UpdateVelocity),
|
||||||
)
|
)
|
||||||
.with_system(
|
.with_system(
|
||||||
movement
|
movement
|
||||||
.system()
|
|
||||||
// Only applied to the `movement` system
|
// Only applied to the `movement` system
|
||||||
.label(PhysicsSystem::Movement)
|
.label(PhysicsSystem::Movement)
|
||||||
// Enforce order within this system by specifying this
|
// Enforce order within this system by specifying this
|
||||||
|
@ -93,14 +91,13 @@ fn main() {
|
||||||
.with_run_criteria(RunCriteria::pipe("is_done_label", inverse.system()))
|
.with_run_criteria(RunCriteria::pipe("is_done_label", inverse.system()))
|
||||||
// `collision` and `sfx` are not ordered with respect to
|
// `collision` and `sfx` are not ordered with respect to
|
||||||
// each other, and may run in any order
|
// each other, and may run in any order
|
||||||
.with_system(collision.system())
|
.with_system(collision)
|
||||||
.with_system(sfx.system()),
|
.with_system(sfx),
|
||||||
)
|
)
|
||||||
.add_system(
|
.add_system(
|
||||||
exit.system()
|
exit.after(PostPhysics)
|
||||||
.after(PostPhysics)
|
|
||||||
// Label the run criteria such that the `PostPhysics` set can reference it
|
// Label the run criteria such that the `PostPhysics` set can reference it
|
||||||
.with_run_criteria(is_done.system().label("is_done_label")),
|
.with_run_criteria(is_done.label("is_done_label")),
|
||||||
)
|
)
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,9 +4,9 @@ fn main() {
|
||||||
App::new()
|
App::new()
|
||||||
.add_plugins(DefaultPlugins)
|
.add_plugins(DefaultPlugins)
|
||||||
.insert_resource(Countdown::default())
|
.insert_resource(Countdown::default())
|
||||||
.add_startup_system(setup_system.system())
|
.add_startup_system(setup_system)
|
||||||
.add_system(countdown_system.system())
|
.add_system(countdown_system)
|
||||||
.add_system(timer_system.system())
|
.add_system(timer_system)
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,29 +18,25 @@ fn main() {
|
||||||
.init_resource::<Game>()
|
.init_resource::<Game>()
|
||||||
.add_plugins(DefaultPlugins)
|
.add_plugins(DefaultPlugins)
|
||||||
.add_state(GameState::Playing)
|
.add_state(GameState::Playing)
|
||||||
.add_startup_system(setup_cameras.system())
|
.add_startup_system(setup_cameras)
|
||||||
.add_system_set(SystemSet::on_enter(GameState::Playing).with_system(setup.system()))
|
.add_system_set(SystemSet::on_enter(GameState::Playing).with_system(setup))
|
||||||
.add_system_set(
|
.add_system_set(
|
||||||
SystemSet::on_update(GameState::Playing)
|
SystemSet::on_update(GameState::Playing)
|
||||||
.with_system(move_player.system())
|
.with_system(move_player)
|
||||||
.with_system(focus_camera.system())
|
.with_system(focus_camera)
|
||||||
.with_system(rotate_bonus.system())
|
.with_system(rotate_bonus)
|
||||||
.with_system(scoreboard_system.system()),
|
.with_system(scoreboard_system),
|
||||||
)
|
)
|
||||||
.add_system_set(SystemSet::on_exit(GameState::Playing).with_system(teardown.system()))
|
.add_system_set(SystemSet::on_exit(GameState::Playing).with_system(teardown))
|
||||||
.add_system_set(
|
.add_system_set(SystemSet::on_enter(GameState::GameOver).with_system(display_score))
|
||||||
SystemSet::on_enter(GameState::GameOver).with_system(display_score.system()),
|
.add_system_set(SystemSet::on_update(GameState::GameOver).with_system(gameover_keyboard))
|
||||||
)
|
.add_system_set(SystemSet::on_exit(GameState::GameOver).with_system(teardown))
|
||||||
.add_system_set(
|
|
||||||
SystemSet::on_update(GameState::GameOver).with_system(gameover_keyboard.system()),
|
|
||||||
)
|
|
||||||
.add_system_set(SystemSet::on_exit(GameState::GameOver).with_system(teardown.system()))
|
|
||||||
.add_system_set(
|
.add_system_set(
|
||||||
SystemSet::new()
|
SystemSet::new()
|
||||||
.with_run_criteria(FixedTimestep::step(5.0))
|
.with_run_criteria(FixedTimestep::step(5.0))
|
||||||
.with_system(spawn_bonus.system()),
|
.with_system(spawn_bonus),
|
||||||
)
|
)
|
||||||
.add_system(bevy::input::system::exit_on_esc_system.system())
|
.add_system(bevy::input::system::exit_on_esc_system)
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,16 +12,16 @@ fn main() {
|
||||||
.add_plugins(DefaultPlugins)
|
.add_plugins(DefaultPlugins)
|
||||||
.insert_resource(Scoreboard { score: 0 })
|
.insert_resource(Scoreboard { score: 0 })
|
||||||
.insert_resource(ClearColor(Color::rgb(0.9, 0.9, 0.9)))
|
.insert_resource(ClearColor(Color::rgb(0.9, 0.9, 0.9)))
|
||||||
.add_startup_system(setup.system())
|
.add_startup_system(setup)
|
||||||
.add_system_set(
|
.add_system_set(
|
||||||
SystemSet::new()
|
SystemSet::new()
|
||||||
.with_run_criteria(FixedTimestep::step(TIME_STEP as f64))
|
.with_run_criteria(FixedTimestep::step(TIME_STEP as f64))
|
||||||
.with_system(paddle_movement_system.system())
|
.with_system(paddle_movement_system)
|
||||||
.with_system(ball_collision_system.system())
|
.with_system(ball_collision_system)
|
||||||
.with_system(ball_movement_system.system()),
|
.with_system(ball_movement_system),
|
||||||
)
|
)
|
||||||
.add_system(scoreboard_system.system())
|
.add_system(scoreboard_system)
|
||||||
.add_system(bevy::input::system::exit_on_esc_system.system())
|
.add_system(bevy::input::system::exit_on_esc_system)
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use bevy::prelude::*;
|
use bevy::prelude::*;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
App::new().add_system(hello_world_system.system()).run();
|
App::new().add_system(hello_world_system).run();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn hello_world_system() {
|
fn hello_world_system() {
|
||||||
|
|
|
@ -3,7 +3,7 @@ use bevy::{prelude::*, window::ReceivedCharacter};
|
||||||
fn main() {
|
fn main() {
|
||||||
App::new()
|
App::new()
|
||||||
.add_plugins(DefaultPlugins)
|
.add_plugins(DefaultPlugins)
|
||||||
.add_system(print_char_event_system.system())
|
.add_system(print_char_event_system)
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,8 +8,8 @@ fn main() {
|
||||||
App::new()
|
App::new()
|
||||||
.add_plugins(DefaultPlugins)
|
.add_plugins(DefaultPlugins)
|
||||||
.init_resource::<GamepadLobby>()
|
.init_resource::<GamepadLobby>()
|
||||||
.add_system_to_stage(CoreStage::PreUpdate, connection_system.system())
|
.add_system_to_stage(CoreStage::PreUpdate, connection_system)
|
||||||
.add_system(gamepad_system.system())
|
.add_system(gamepad_system)
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ use bevy::{
|
||||||
fn main() {
|
fn main() {
|
||||||
App::new()
|
App::new()
|
||||||
.add_plugins(DefaultPlugins)
|
.add_plugins(DefaultPlugins)
|
||||||
.add_system(gamepad_events.system())
|
.add_system(gamepad_events)
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ use bevy::{
|
||||||
fn main() {
|
fn main() {
|
||||||
App::new()
|
App::new()
|
||||||
.add_plugins(DefaultPlugins)
|
.add_plugins(DefaultPlugins)
|
||||||
.add_system(keyboard_input_system.system())
|
.add_system(keyboard_input_system)
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ use bevy::{input::keyboard::KeyboardInput, prelude::*};
|
||||||
fn main() {
|
fn main() {
|
||||||
App::new()
|
App::new()
|
||||||
.add_plugins(DefaultPlugins)
|
.add_plugins(DefaultPlugins)
|
||||||
.add_system(print_keyboard_event_system.system())
|
.add_system(print_keyboard_event_system)
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ use bevy::{
|
||||||
fn main() {
|
fn main() {
|
||||||
App::new()
|
App::new()
|
||||||
.add_plugins(DefaultPlugins)
|
.add_plugins(DefaultPlugins)
|
||||||
.add_system(keyboard_input_system.system())
|
.add_system(keyboard_input_system)
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ use bevy::prelude::*;
|
||||||
fn main() {
|
fn main() {
|
||||||
App::new()
|
App::new()
|
||||||
.add_plugins(DefaultPlugins)
|
.add_plugins(DefaultPlugins)
|
||||||
.add_system(mouse_click_system.system())
|
.add_system(mouse_click_system)
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ use bevy::{
|
||||||
fn main() {
|
fn main() {
|
||||||
App::new()
|
App::new()
|
||||||
.add_plugins(DefaultPlugins)
|
.add_plugins(DefaultPlugins)
|
||||||
.add_system(print_mouse_events_system.system())
|
.add_system(print_mouse_events_system)
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ use bevy::{input::touch::*, prelude::*};
|
||||||
fn main() {
|
fn main() {
|
||||||
App::new()
|
App::new()
|
||||||
.add_plugins(DefaultPlugins)
|
.add_plugins(DefaultPlugins)
|
||||||
.add_system(touch_system.system())
|
.add_system(touch_system)
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ use bevy::{input::touch::*, prelude::*};
|
||||||
fn main() {
|
fn main() {
|
||||||
App::new()
|
App::new()
|
||||||
.add_plugins(DefaultPlugins)
|
.add_plugins(DefaultPlugins)
|
||||||
.add_system(touch_event_system.system())
|
.add_system(touch_event_system)
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,8 +12,8 @@ fn main() {
|
||||||
})
|
})
|
||||||
.insert_resource(Msaa { samples: 4 })
|
.insert_resource(Msaa { samples: 4 })
|
||||||
.add_plugins(DefaultPlugins)
|
.add_plugins(DefaultPlugins)
|
||||||
.add_startup_system(setup_scene.system())
|
.add_startup_system(setup_scene)
|
||||||
.add_startup_system(setup_music.system())
|
.add_startup_system(setup_music)
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
/// set up a simple 3D scene
|
/// set up a simple 3D scene
|
||||||
|
|
|
@ -6,7 +6,7 @@ fn main() {
|
||||||
App::new()
|
App::new()
|
||||||
.add_plugins(DefaultPlugins)
|
.add_plugins(DefaultPlugins)
|
||||||
.register_type::<MyType<u32>>()
|
.register_type::<MyType<u32>>()
|
||||||
.add_startup_system(setup.system())
|
.add_startup_system(setup)
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue