mirror of
https://github.com/bevyengine/bevy
synced 2024-11-21 12:13:25 +00:00
Expose BRP system scheduling and add system set (#16400)
# Objective When adding custom BRP methods one might need to: - Run custom systems in the `RemoteLast` schedule. - Order those systems before/after request processing and cleanup. For example in `bevy_remote_inspector` we need a way to perform some preparation _before_ request processing. And to perform cleanup _between_ request processing and watcher cleanup. ## Solution - Make `RemoteLast` public - Add `RemoteSet` with `ProcessRequests` and `Cleanup` variants.
This commit is contained in:
parent
3ec09582c6
commit
9f04fc030b
1 changed files with 22 additions and 7 deletions
|
@ -305,7 +305,7 @@ use bevy_app::{prelude::*, MainScheduleOrder};
|
||||||
use bevy_derive::{Deref, DerefMut};
|
use bevy_derive::{Deref, DerefMut};
|
||||||
use bevy_ecs::{
|
use bevy_ecs::{
|
||||||
entity::Entity,
|
entity::Entity,
|
||||||
schedule::{IntoSystemConfigs, ScheduleLabel},
|
schedule::{IntoSystemConfigs, IntoSystemSetConfigs, ScheduleLabel, SystemSet},
|
||||||
system::{Commands, In, IntoSystem, ResMut, Resource, System, SystemId},
|
system::{Commands, In, IntoSystem, ResMut, Resource, System, SystemId},
|
||||||
world::World,
|
world::World,
|
||||||
};
|
};
|
||||||
|
@ -442,21 +442,36 @@ impl Plugin for RemotePlugin {
|
||||||
app.insert_resource(remote_methods)
|
app.insert_resource(remote_methods)
|
||||||
.init_resource::<RemoteWatchingRequests>()
|
.init_resource::<RemoteWatchingRequests>()
|
||||||
.add_systems(PreStartup, setup_mailbox_channel)
|
.add_systems(PreStartup, setup_mailbox_channel)
|
||||||
|
.configure_sets(
|
||||||
|
RemoteLast,
|
||||||
|
(RemoteSet::ProcessRequests, RemoteSet::Cleanup).chain(),
|
||||||
|
)
|
||||||
.add_systems(
|
.add_systems(
|
||||||
RemoteLast,
|
RemoteLast,
|
||||||
(
|
(
|
||||||
process_remote_requests,
|
(process_remote_requests, process_ongoing_watching_requests)
|
||||||
process_ongoing_watching_requests,
|
.chain()
|
||||||
remove_closed_watching_requests,
|
.in_set(RemoteSet::ProcessRequests),
|
||||||
)
|
remove_closed_watching_requests.in_set(RemoteSet::Cleanup),
|
||||||
.chain(),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Schedule that contains all systems to process Bevy Remote Protocol requests
|
/// Schedule that contains all systems to process Bevy Remote Protocol requests
|
||||||
#[derive(ScheduleLabel, Clone, Debug, PartialEq, Eq, Hash)]
|
#[derive(ScheduleLabel, Clone, Debug, PartialEq, Eq, Hash)]
|
||||||
struct RemoteLast;
|
pub struct RemoteLast;
|
||||||
|
|
||||||
|
/// The systems sets of the [`RemoteLast`] schedule.
|
||||||
|
///
|
||||||
|
/// These can be useful for ordering.
|
||||||
|
#[derive(Debug, Hash, PartialEq, Eq, Clone, SystemSet)]
|
||||||
|
pub enum RemoteSet {
|
||||||
|
/// Processing of remote requests.
|
||||||
|
ProcessRequests,
|
||||||
|
/// Cleanup (remove closed watchers etc)
|
||||||
|
Cleanup,
|
||||||
|
}
|
||||||
|
|
||||||
/// A type to hold the allowed types of systems to be used as method handlers.
|
/// A type to hold the allowed types of systems to be used as method handlers.
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
|
Loading…
Reference in a new issue