Skip to content

Commit

Permalink
Adjust schedules to add systems
Browse files Browse the repository at this point in the history
  • Loading branch information
B-head committed Jul 8, 2023
1 parent fe794a8 commit 557408e
Show file tree
Hide file tree
Showing 24 changed files with 50 additions and 52 deletions.
2 changes: 1 addition & 1 deletion crates/bevy_asset/src/debug_asset_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ impl Plugin for DebugAssetServerPlugin {
watch_for_changes: ChangeWatcher::with_delay(Duration::from_millis(200)),
});
app.insert_non_send_resource(DebugAssetApp(debug_asset_app));
app.add_systems(Update, run_debug_asset_app);
app.add_systems(FrameReady, run_debug_asset_app);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ impl<T: Asset> Default for AssetCountDiagnosticsPlugin<T> {
impl<T: Asset> Plugin for AssetCountDiagnosticsPlugin<T> {
fn build(&self, app: &mut App) {
app.add_systems(Startup, Self::setup_system)
.add_systems(Update, Self::diagnostic_system);
.add_systems(FrameReady, Self::diagnostic_system);
}
}

Expand Down
14 changes: 7 additions & 7 deletions crates/bevy_asset/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ pub use loader::*;
pub use path::*;
pub use reflect::*;

use bevy_app::{prelude::*, UpdateFlowOrder};
use bevy_ecs::schedule::ScheduleLabel;
use bevy_app::prelude::*;
use bevy_ecs::{schedule::ScheduleLabel, world::World};
use bevy_utils::Duration;

/// Asset storages are updated.
Expand Down Expand Up @@ -132,7 +132,6 @@ impl Plugin for AssetPlugin {
app.register_type::<HandleId>();
app.register_type::<AssetPath>();

app.add_systems(PreUpdate, asset_server::free_unused_assets_system);
app.init_schedule(LoadAssets);
app.init_schedule(AssetEvents);

Expand All @@ -141,9 +140,10 @@ impl Plugin for AssetPlugin {
all(not(target_arch = "wasm32"), not(target_os = "android"))
))]
app.add_systems(LoadAssets, io::filesystem_watcher_system);

let mut order = app.world.resource_mut::<UpdateFlowOrder>();
order.insert_after(First, LoadAssets);
order.insert_after(PostUpdate, AssetEvents);
app.add_systems(LoadAssets, asset_server::free_unused_assets_system);
app.add_systems(FrameReady, |world: &mut World| {
world.run_schedule(LoadAssets);
world.run_schedule(AssetEvents);
});
}
}
4 changes: 2 additions & 2 deletions crates/bevy_audio/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ impl Plugin for AudioPlugin {
.add_asset::<SpatialAudioSink>()
.init_resource::<Audio<AudioSource>>()
.insert_resource(self.global_volume)
.add_systems(PostUpdate, play_queued_audio_system::<AudioSource>);
.add_systems(FrameReady, play_queued_audio_system::<AudioSource>);

#[cfg(any(feature = "mp3", feature = "flac", feature = "wav", feature = "vorbis"))]
app.init_asset_loader::<AudioLoader>();
Expand All @@ -80,6 +80,6 @@ impl AddAudioSource for App {
self.add_asset::<T>()
.init_resource::<Audio<T>>()
.init_resource::<AudioOutput<T>>()
.add_systems(PostUpdate, play_queued_audio_system::<T>)
.add_systems(FrameReady, play_queued_audio_system::<T>)
}
}
2 changes: 1 addition & 1 deletion crates/bevy_core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ impl Plugin for TaskPoolPlugin {
self.task_pool_options.create_default_pools();

#[cfg(not(target_arch = "wasm32"))]
_app.add_systems(Last, tick_global_task_pools);
_app.add_systems(FrameReady, tick_global_task_pools);
}
}
/// A dummy type that is [`!Send`](Send), to force systems to run on the main thread.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pub struct EntityCountDiagnosticsPlugin;
impl Plugin for EntityCountDiagnosticsPlugin {
fn build(&self, app: &mut App) {
app.register_diagnostic(Diagnostic::new(Self::ENTITY_COUNT, "entity_count", 20))
.add_systems(Update, Self::diagnostic_system);
.add_systems(FrameReady, Self::diagnostic_system);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ impl Plugin for FrameTimeDiagnosticsPlugin {
.register_diagnostic(
Diagnostic::new(Self::FRAME_COUNT, "frame_count", 1).with_smoothing_factor(0.0),
)
.add_systems(Update, Self::diagnostic_system);
.add_systems(FrameReady, Self::diagnostic_system);
}
}

Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_diagnostic/src/log_diagnostics_plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ impl Plugin for LogDiagnosticsPlugin {
});

if self.debug {
app.add_systems(PostUpdate, Self::log_diagnostics_debug_system);
app.add_systems(FrameReady, Self::log_diagnostics_debug_system);
} else {
app.add_systems(PostUpdate, Self::log_diagnostics_system);
app.add_systems(FrameReady, Self::log_diagnostics_system);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub struct SystemInformationDiagnosticsPlugin;
impl Plugin for SystemInformationDiagnosticsPlugin {
fn build(&self, app: &mut App) {
app.add_systems(Startup, internal::setup_system)
.add_systems(Update, internal::diagnostic_system);
.add_systems(FrameReady, internal::diagnostic_system);
}
}

Expand Down
6 changes: 3 additions & 3 deletions crates/bevy_gilrs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ mod converter;
mod gilrs_system;
mod rumble;

use bevy_app::{App, Plugin, PostUpdate, PreStartup, PreUpdate};
use bevy_app::{App, Control, FrameReady, Plugin, PreStartup};
use bevy_ecs::prelude::*;
use bevy_input::InputSystem;
use bevy_utils::tracing::error;
Expand All @@ -30,8 +30,8 @@ impl Plugin for GilrsPlugin {
app.insert_non_send_resource(gilrs)
.init_non_send_resource::<RunningRumbleEffects>()
.add_systems(PreStartup, gilrs_event_startup_system)
.add_systems(PreUpdate, gilrs_event_system.before(InputSystem))
.add_systems(PostUpdate, play_gilrs_rumble.in_set(RumbleSystem));
.add_systems(Control, gilrs_event_system.before(InputSystem))
.add_systems(FrameReady, play_gilrs_rumble.in_set(RumbleSystem));
}
Err(err) => error!("Failed to start Gilrs. {}", err),
}
Expand Down
6 changes: 3 additions & 3 deletions crates/bevy_gizmos/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
use std::mem;

use bevy_app::{Last, Plugin, RenderFlow, Update};
use bevy_app::{FrameReady, Plugin, RenderFlow};
use bevy_asset::{load_internal_asset, AddAsset, Assets, Handle, HandleUntyped};
use bevy_core::cast_slice;
use bevy_ecs::{
Expand Down Expand Up @@ -84,12 +84,12 @@ impl Plugin for GizmoPlugin {
.init_resource::<LineGizmoHandles>()
.init_resource::<GizmoConfig>()
.init_resource::<GizmoStorage>()
.add_systems(Last, update_gizmo_meshes)
.add_systems(
Update,
FrameReady,
(
draw_aabbs,
draw_all_aabbs.run_if(|config: Res<GizmoConfig>| config.aabb.draw_all),
update_gizmo_meshes,
),
);

Expand Down
6 changes: 3 additions & 3 deletions crates/bevy_input/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,13 @@ impl Plugin for InputPlugin {
.add_event::<KeyboardInput>()
.init_resource::<Input<KeyCode>>()
.init_resource::<Input<ScanCode>>()
.add_systems(PreUpdate, keyboard_input_system.in_set(InputSystem))
.add_systems(Control, keyboard_input_system.in_set(InputSystem))
// mouse
.add_event::<MouseButtonInput>()
.add_event::<MouseMotion>()
.add_event::<MouseWheel>()
.init_resource::<Input<MouseButton>>()
.add_systems(PreUpdate, mouse_button_input_system.in_set(InputSystem))
.add_systems(Control, mouse_button_input_system.in_set(InputSystem))
.add_event::<TouchpadMagnify>()
.add_event::<TouchpadRotate>()
// gamepad
Expand Down Expand Up @@ -99,7 +99,7 @@ impl Plugin for InputPlugin {
// touch
.add_event::<TouchInput>()
.init_resource::<Touches>()
.add_systems(PreUpdate, touch_screen_input_system.in_set(InputSystem));
.add_systems(Control, touch_screen_input_system.in_set(InputSystem));

// Register common types
app.register_type::<ButtonState>();
Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_render/src/mesh/morph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::{
render_resource::{Extent3d, TextureDimension, TextureFormat},
texture::Image,
};
use bevy_app::{Plugin, PostUpdate};
use bevy_app::{FrameReady, Plugin};
use bevy_asset::Handle;
use bevy_ecs::prelude::*;
use bevy_hierarchy::Children;
Expand All @@ -28,7 +28,7 @@ impl Plugin for MorphPlugin {
fn build(&self, app: &mut bevy_app::App) {
app.register_type::<MorphWeights>()
.register_type::<MeshMorphWeights>()
.add_systems(PostUpdate, inherit_weights);
.add_systems(FrameReady, inherit_weights);
}
}

Expand Down
1 change: 1 addition & 0 deletions crates/bevy_render/src/render_resource/texture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ pub struct TextureView {
value: ErasedTextureView,
}

#[derive(Debug)]
pub struct SurfaceTexture {
value: ErasedSurfaceTexture,
}
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_render/src/renderer/render_device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use crate::render_resource::resource_macros::*;
render_resource_wrapper!(ErasedRenderDevice, wgpu::Device);

/// This GPU device is responsible for the creation of most rendering and compute resources.
#[derive(Resource, Clone)]
#[derive(Debug, Resource, Clone)]
pub struct RenderDevice {
device: ErasedRenderDevice,
}
Expand Down
8 changes: 4 additions & 4 deletions crates/bevy_render/src/view/visibility/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ mod render_layers;

pub use render_layers::*;

use bevy_app::{Plugin, PostUpdate};
use bevy_app::{FrameReady, Plugin};
use bevy_asset::{Assets, Handle};
use bevy_ecs::prelude::*;
use bevy_hierarchy::{Children, Parent};
Expand Down Expand Up @@ -213,10 +213,10 @@ impl Plugin for VisibilityPlugin {

app
// We add an AABB component in CalculateBounds, which must be ready on the same frame.
.add_systems(PostUpdate, apply_deferred.in_set(CalculateBoundsFlush))
.configure_set(PostUpdate, CalculateBoundsFlush.after(CalculateBounds))
.add_systems(FrameReady, apply_deferred.in_set(CalculateBoundsFlush))
.configure_set(FrameReady, CalculateBoundsFlush.after(CalculateBounds))
.add_systems(
PostUpdate,
FrameReady,
(
calculate_bounds.in_set(CalculateBounds),
update_frusta::<OrthographicProjection>
Expand Down
1 change: 1 addition & 0 deletions crates/bevy_render/src/view/window/screenshot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ impl SpecializedRenderPipeline for ScreenshotToScreenPipeline {
}
}

#[derive(Debug)]
pub struct ScreenshotPreparedState {
pub texture: Texture,
pub buffer: Buffer,
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_time/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ impl Plugin for TimePlugin {
.register_type::<Time>()
.register_type::<Stopwatch>()
.init_resource::<FixedTime>()
.add_systems(First, time_system.in_set(TimeSystem))
.add_systems(Control, time_system.in_set(TimeSystem))
.add_systems(RunFixedUpdateLoop, run_fixed_update_schedule);

#[cfg(feature = "bevy_ci_testing")]
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_ui/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ impl Plugin for UiPlugin {
);
#[cfg(feature = "bevy_text")]
app.add_plugins(accessibility::AccessibilityPlugin);
app.add_systems(PostUpdate, {
app.add_systems(FrameReady, {
let system = widget::update_image_content_size_system.before(UiSystem::Layout);
// Potential conflicts: `Assets<Image>`
// They run independently since `widget::image_node_system` will only ever observe
Expand Down
6 changes: 3 additions & 3 deletions crates/bevy_window/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,17 +95,17 @@ impl Plugin for WindowPlugin {

match self.exit_condition {
ExitCondition::OnPrimaryClosed => {
app.add_systems(PostUpdate, exit_on_primary_closed);
app.add_systems(Control, exit_on_primary_closed);
}
ExitCondition::OnAllClosed => {
app.add_systems(PostUpdate, exit_on_all_closed);
app.add_systems(Control, exit_on_all_closed);
}
ExitCondition::DontExit => {}
}

if self.close_when_requested {
// Need to run before `exit_on_*` systems
app.add_systems(PostUpdate, close_when_requested);
app.add_systems(Control, close_when_requested);
}

// Register event types
Expand Down
14 changes: 5 additions & 9 deletions crates/bevy_winit/src/accessibility.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use bevy_a11y::{
accesskit::{ActionHandler, ActionRequest, NodeBuilder, NodeClassSet, Role, TreeUpdate},
AccessKitEntityExt, AccessibilityNode, AccessibilityRequested, Focus,
};
use bevy_app::{App, Plugin, PostUpdate};
use bevy_app::{App, Control, FrameReady, Plugin};
use bevy_derive::{Deref, DerefMut};
use bevy_ecs::{
prelude::{DetectChanges, Entity, EventReader, EventWriter},
Expand Down Expand Up @@ -170,13 +170,9 @@ impl Plugin for AccessibilityPlugin {
.init_resource::<WinitActionHandlers>()
.add_event::<ActionRequestWrapper>()
.add_systems(
PostUpdate,
(
handle_window_focus,
window_closed,
poll_receivers,
update_accessibility_nodes,
),
);
Control,
(handle_window_focus, window_closed, poll_receivers),
)
.add_systems(FrameReady, update_accessibility_nodes);
}
}
4 changes: 2 additions & 2 deletions crates/bevy_winit/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pub use winit_config::*;
pub use winit_handler::*;
pub use winit_windows::*;

use bevy_app::{App, AppExit, Last, Plugin};
use bevy_app::{App, AppExit, Control, Plugin};
use bevy_ecs::event::ManualEventReader;
use bevy_ecs::prelude::*;
use bevy_input::{
Expand Down Expand Up @@ -108,7 +108,7 @@ impl Plugin for WinitPlugin {
// exit_on_all_closed only uses the query to determine if the query is empty,
// and so doesn't care about ordering relative to changed_window
.add_systems(
Last,
Control,
(
changed_window.ambiguous_with(exit_on_all_closed),
// Update the state of the window before attempting to despawn to ensure consistent event ordering
Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_winit/src/web_resize.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::WinitWindows;
use bevy_app::{App, Plugin, Update};
use bevy_app::{App, Plugin};
use bevy_ecs::prelude::*;
use crossbeam_channel::{Receiver, Sender};
use wasm_bindgen::JsCast;
Expand All @@ -10,7 +10,7 @@ pub(crate) struct CanvasParentResizePlugin;
impl Plugin for CanvasParentResizePlugin {
fn build(&self, app: &mut App) {
app.init_resource::<CanvasParentResizeEventChannel>()
.add_systems(Update, canvas_parent_resize_event_handler);
.add_systems(Control, canvas_parent_resize_event_handler);
}
}

Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_winit/src/winit_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ impl WinitHandler {
}

/// Requests frame redraw.
///
///
/// If called during redrawing, the next redraw is reserved.
pub fn redraw(&mut self) {
if let Err(e) = self.proxy.get().send_event(HandleEvent::RequestRedraw) {
Expand Down

0 comments on commit 557408e

Please sign in to comment.