@@ -31,12 +31,62 @@ pub struct Or<T>(pub T);
31
31
32
32
/// Query transformer that retrieves components of type `T` that have been mutated since the start of the frame.
33
33
/// Added components do not count as mutated.
34
+ /// This filter is useful as a performance optimization as it means that a system can be made to run only when
35
+ /// it needs to rather than every frame.
36
+ ///
37
+ /// Because the ordering of systems can change and this filter is only effective on changes before the query executes
38
+ /// you need to use explicit dependency ordering or ordered stages for these query filters to be useful.
39
+ ///
40
+ /// Example:
41
+ /// ```
42
+ /// # use bevy_ecs::Query;
43
+ /// # use bevy_ecs::Mutated;
44
+ ///
45
+ /// # #[derive(Debug)]
46
+ /// # struct Name {};
47
+ /// # struct Transform {};
48
+ ///
49
+ /// fn print_moving_objects_system(query: Query<(&Name,), (Mutated<Transform>,)>) {
50
+ /// for (name, ) in query.iter() {
51
+ /// println!("Entity Moved: {:?}", name)
52
+ /// }
53
+ /// }
54
+ /// ```
34
55
pub struct Mutated < T > ( NonNull < ComponentFlags > , PhantomData < T > ) ;
35
56
36
57
/// Query transformer that retrieves components of type `T` that have been added since the start of the frame.
58
+ /// This filter is useful as a performance optimization as it means that a system can be made to run only when
59
+ /// it needs to rather than every frame.
60
+ ///
61
+ /// Because the ordering of systems can change and this filter is only effective on changes before the query executes
62
+ /// you need to use explicit dependency ordering or ordered stages for these query filters to be useful.
63
+ ///
64
+ ///
65
+ /// Example:
66
+ /// ```
67
+ /// # use bevy_ecs::Query;
68
+ /// # use bevy_ecs::Added;
69
+ ///
70
+ /// # #[derive(Debug)]
71
+ /// # struct Name {};
72
+ /// # struct Transform {};
73
+ ///
74
+ /// fn print_add_name_component(query: Query<(&Name,), (Added<Name>,)>) {
75
+ /// for (name, ) in query.iter() {
76
+ /// println!("Named entity created: {:?}", name)
77
+ /// }
78
+ /// }
79
+ /// ```
37
80
pub struct Added < T > ( NonNull < ComponentFlags > , PhantomData < T > ) ;
38
81
39
82
/// Query transformer that retrieves components of type `T` that have either been mutated or added since the start of the frame.
83
+ /// This filter is useful as a performance optimization as it means that a system can be made to run only when
84
+ /// it needs to rather than every frame.
85
+ ///
86
+ /// Because the ordering of systems can change and this filter is only effective on changes before the query executes
87
+ /// you need to use explicit dependency ordering or ordered stages for these query filters to be useful.
88
+ ///
89
+ /// Also see the documentation for [`Mutated<T>`] and [`Added`] as this filter is a logical OR of them.
40
90
pub struct Changed < T > ( NonNull < ComponentFlags > , PhantomData < T > ) ;
41
91
42
92
impl QueryFilter for ( ) {
0 commit comments