99extern crate alloc;
1010
1111use bevy_app:: prelude:: * ;
12- use bevy_ecs:: prelude:: * ;
12+ use bevy_ecs:: {
13+ prelude:: * ,
14+ schedule:: { InternedScheduleLabel , ScheduleLabel } ,
15+ } ;
1316
1417#[ cfg( feature = "builder" ) ]
1518pub mod builder;
@@ -21,8 +24,67 @@ pub mod signal_vec;
2124pub mod utils;
2225
2326/// Includes the systems required for [jonmo](crate) to function.
24- #[ derive( Default ) ]
25- pub struct JonmoPlugin ;
27+ ///
28+ /// # Example
29+ ///
30+ /// ```rust
31+ /// use bevy_app::prelude::*;
32+ /// use bevy_ecs::prelude::*;
33+ /// use jonmo::{SignalProcessing, prelude::*};
34+ ///
35+ /// let mut app = App::new();
36+ /// // Use default configuration (runs in Last schedule)
37+ /// app.add_plugins(JonmoPlugin::default());
38+ ///
39+ /// let mut app = App::new();
40+ /// // Or customize the schedule
41+ /// app.add_plugins(JonmoPlugin::new().in_schedule(PostUpdate));
42+ ///
43+ /// // Add ordering constraints using configure_sets
44+ /// # #[derive(SystemSet, Debug, Clone, PartialEq, Eq, Hash)]
45+ /// # struct SystemSet1;
46+ ///
47+ /// # #[derive(SystemSet, Debug, Clone, PartialEq, Eq, Hash)]
48+ /// # struct SystemSet2;
49+ ///
50+ /// app.configure_sets(
51+ /// PostUpdate,
52+ /// SignalProcessing.before(SystemSet1).before(SystemSet2),
53+ /// );
54+ /// ```
55+ pub struct JonmoPlugin {
56+ schedule : InternedScheduleLabel ,
57+ }
58+
59+ impl Default for JonmoPlugin {
60+ fn default ( ) -> Self {
61+ Self {
62+ schedule : Last . intern ( ) ,
63+ }
64+ }
65+ }
66+
67+ impl JonmoPlugin {
68+ /// Create a new `JonmoPlugin` with signal processing running in the `Last` schedule.
69+ pub fn new ( ) -> Self {
70+ Self :: default ( )
71+ }
72+
73+ /// Specify which schedule the signal processing systems should run in.
74+ ///
75+ /// # Example
76+ ///
77+ /// ```rust
78+ /// use bevy_app::prelude::*;
79+ /// use jonmo::prelude::*;
80+ ///
81+ /// JonmoPlugin::new().in_schedule(Update);
82+ /// ```
83+ pub fn in_schedule ( mut self , schedule : impl ScheduleLabel ) -> Self {
84+ self . schedule = schedule. intern ( ) ;
85+ self
86+ }
87+ }
2688
2789/// [`SystemSet`] that can be used to schedule systems around signal processing.
2890#[ derive( SystemSet , Debug , Clone , PartialEq , Eq , Hash ) ]
@@ -31,7 +93,7 @@ pub struct SignalProcessing;
3193impl Plugin for JonmoPlugin {
3294 fn build ( & self , app : & mut App ) {
3395 app. add_systems (
34- Last ,
96+ self . schedule ,
3597 (
3698 (
3799 signal_vec:: trigger_replays :: < signal_vec:: VecReplayTrigger > ,
0 commit comments