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