@@ -574,6 +574,30 @@ macro_rules! impl_flag_filter {
574
574
575
575
impl_flag_filter ! (
576
576
/// Filter that retrieves components of type `T` that have been added since the start of the frame
577
+ ///
578
+ /// This filter is useful as a performance optimization as it means that a system can be made to run only when
579
+ /// it needs to rather than every frame.
580
+ ///
581
+ /// Because the ordering of systems can change and this filter is only effective on changes before the query executes
582
+ /// you need to use explicit dependency ordering or ordered stages for these query filters to be useful.
583
+ ///
584
+ ///
585
+ /// Example:
586
+ /// ```
587
+ /// # use bevy_ecs::system::Query;
588
+ /// # use bevy_ecs::query::Added;
589
+ /// #
590
+ /// # #[derive(Debug)]
591
+ /// # struct Name {};
592
+ /// # struct Transform {};
593
+ /// #
594
+ /// fn print_add_name_component(query: Query<&Name, Added<Name>>) {
595
+ /// for name in query.iter() {
596
+ /// println!("Named entity created: {:?}", name)
597
+ /// }
598
+ /// }
599
+ /// ```
600
+
577
601
Added ,
578
602
AddedState ,
579
603
AddedFetch ,
@@ -583,6 +607,29 @@ impl_flag_filter!(
583
607
impl_flag_filter ! (
584
608
/// Filter that retrieves components of type `T` that have been mutated since the start of the frame.
585
609
/// Added components do not count as mutated.
610
+ ///
611
+ /// This filter is useful as a performance optimization as it means that a system can be made to run only when
612
+ /// it needs to rather than every frame.
613
+ ///
614
+ /// Because the ordering of systems can change and this filter is only effective on changes before the query executes
615
+ /// you need to use explicit dependency ordering or ordered stages for these query filters to be useful.
616
+ ///
617
+ /// Example:
618
+ /// ```
619
+ /// # use bevy_ecs::system::Query;
620
+ /// # use bevy_ecs::query::Mutated;
621
+ /// #
622
+ /// # #[derive(Debug)]
623
+ /// # struct Name {};
624
+ /// # struct Transform {};
625
+ /// #
626
+ /// fn print_moving_objects_system(query: Query<&Name, Mutated<Transform>>) {
627
+ /// for name in query.iter() {
628
+ /// println!("Entity Moved: {:?}", name)
629
+ /// }
630
+ /// }
631
+ /// ```
632
+
586
633
Mutated ,
587
634
MutatedState ,
588
635
MutatedFetch ,
@@ -591,6 +638,15 @@ impl_flag_filter!(
591
638
592
639
impl_flag_filter ! (
593
640
/// Filter that retrieves components of type `T` that have been added or mutated since the start of the frame
641
+ ///
642
+ /// This filter is useful as a performance optimization as it means that a system can be made to run only when
643
+ /// it needs to rather than every frame.
644
+ ///
645
+ /// Because the ordering of systems can change and this filter is only effective on changes before the query executes
646
+ /// you need to use explicit dependency ordering or ordered stages for these query filters to be useful.
647
+ ///
648
+ /// Also see the documentation for [`Mutated<T>`] and [`Added`] as this filter is a logical OR of them.
649
+
594
650
Changed ,
595
651
ChangedState ,
596
652
ChangedFetch ,
0 commit comments