@@ -810,105 +810,6 @@ unsafe impl<T: FromWorld + Send + 'static> SystemParamState for LocalState<T> {
810
810
}
811
811
}
812
812
813
- <<<<<<< HEAD
814
- /// A [`SystemParam`] that grants access to the entities that had their `T` [`Component`] removed.
815
- ///
816
- /// Note that this does not allow you to see which data existed before removal.
817
- /// If you need this, you will need to track the component data value on your own,
818
- /// using a regularly scheduled system that requests `Query<(Entity, &T), Changed<T>>`
819
- /// and stores the data somewhere safe to later cross-reference.
820
- ///
821
- /// If you are using `bevy_ecs` as a standalone crate,
822
- /// note that the `RemovedComponents` list will not be automatically cleared for you,
823
- /// and will need to be manually flushed using [`World::clear_trackers`]
824
- ///
825
- /// For users of `bevy` and `bevy_app`, this is automatically done in `bevy_app::App::update`.
826
- /// For the main world, [`World::clear_trackers`] is run after the main schedule is run and after
827
- /// `SubApp`'s have run.
828
- ///
829
- /// # Examples
830
- ///
831
- /// Basic usage:
832
- ///
833
- /// ```
834
- /// # use bevy_ecs::component::Component;
835
- /// # use bevy_ecs::system::IntoSystem;
836
- /// # use bevy_ecs::system::RemovedComponents;
837
- /// #
838
- /// # #[derive(Component)]
839
- /// # struct MyComponent;
840
- ///
841
- /// fn react_on_removal(removed: RemovedComponents<MyComponent>) {
842
- /// removed.iter().for_each(|removed_entity| println!("{:?}", removed_entity));
843
- /// }
844
- ///
845
- /// # bevy_ecs::system::assert_is_system(react_on_removal);
846
- /// ```
847
- pub struct RemovedComponents < ' a , T : Component > {
848
- world: & ' a World ,
849
- component_id: ComponentId ,
850
- marker: PhantomData <T >,
851
- }
852
-
853
- impl <' a, T : Component > RemovedComponents <' a, T > {
854
- /// Returns an iterator over the entities that had their `T` [`Component`] removed.
855
- pub fn iter( & self ) -> std:: iter:: Cloned < std:: slice:: Iter < ' _ , Entity > > {
856
- self . world. removed_with_id( self . component_id)
857
- }
858
- }
859
-
860
- impl <' a, T : Component > IntoIterator for & ' a RemovedComponents <' a, T > {
861
- type Item = Entity ;
862
- type IntoIter = std:: iter:: Cloned < std:: slice:: Iter < ' a , Entity > > ;
863
-
864
- fn into_iter( self ) -> Self :: IntoIter {
865
- self . iter( )
866
- }
867
- }
868
-
869
- // SAFETY: Only reads World components
870
- unsafe impl <' a, T : Component > ReadOnlySystemParam for RemovedComponents <' a, T > { }
871
-
872
- /// The [`SystemParamState`] of [`RemovedComponents<T>`].
873
- #[ doc( hidden) ]
874
- pub struct RemovedComponentsState <T > {
875
- component_id: ComponentId ,
876
- marker: PhantomData <T >,
877
- }
878
-
879
- impl <' a, T : Component > SystemParam for RemovedComponents <' a, T > {
880
- type State = RemovedComponentsState <T >;
881
- }
882
-
883
- // SAFETY: no component access. removed component entity collections can be read in parallel and are
884
- // never mutably borrowed during system execution
885
- unsafe impl <T : Component > SystemParamState for RemovedComponentsState <T > {
886
- type Item <' w, ' s> = RemovedComponents <' w, T >;
887
-
888
- fn init( world: & mut World , _system_meta: & mut SystemMeta ) -> Self {
889
- Self {
890
- component_id: world. init_component:: <T >( ) ,
891
- marker: PhantomData ,
892
- }
893
- }
894
-
895
- #[ inline]
896
- unsafe fn get_param<' w, ' s>(
897
- state: & ' s mut Self ,
898
- _system_meta: & SystemMeta ,
899
- world: & ' w World ,
900
- _change_tick: u32 ,
901
- ) -> Self :: Item < ' w , ' s > {
902
- RemovedComponents {
903
- world,
904
- component_id: state. component_id,
905
- marker: PhantomData ,
906
- }
907
- }
908
- }
909
-
910
- =======
911
- >>>>>>> 0 a7b6378e ( Not working yet, replace with an events for removed components)
912
813
/// Shared borrow of a non-[`Send`] resource.
913
814
///
914
815
/// Only `Send` resources may be accessed with the [`Res`] [`SystemParam`]. In case that the
0 commit comments