add SystemIdMarker Component to enable filtering for SystemId Entitys (#14584)
				
					
				
			# Objective Enables writing queries like `Query<Entity, With<SystemIdMarker>>` to filter `Entity`s that are, or are not (with `Without`), `SystemId`s. ## Solution Simple unit struct `SystemIdMarker` added during `World::register_boxed_system`; `World::remove_system` already despawns the entity, removing the marker. ## Testing No tests, but happy to write some with direction. Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>
This commit is contained in:
		
							parent
							
								
									4ace888e4b
								
							
						
					
					
						commit
						c8d30edf1a
					
				| @ -12,6 +12,10 @@ struct RegisteredSystem<I, O> { | |||||||
|     system: BoxedSystem<I, O>, |     system: BoxedSystem<I, O>, | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | /// Marker [`Component`](bevy_ecs::component::Component) for identifying [`SystemId`] [`Entity`]s.
 | ||||||
|  | #[derive(Component)] | ||||||
|  | pub struct SystemIdMarker; | ||||||
|  | 
 | ||||||
| /// A system that has been removed from the registry.
 | /// A system that has been removed from the registry.
 | ||||||
| /// It contains the system and whether or not it has been initialized.
 | /// It contains the system and whether or not it has been initialized.
 | ||||||
| ///
 | ///
 | ||||||
| @ -125,10 +129,13 @@ impl World { | |||||||
|     ) -> SystemId<I, O> { |     ) -> SystemId<I, O> { | ||||||
|         SystemId { |         SystemId { | ||||||
|             entity: self |             entity: self | ||||||
|                 .spawn(RegisteredSystem { |                 .spawn(( | ||||||
|  |                     RegisteredSystem { | ||||||
|                         initialized: false, |                         initialized: false, | ||||||
|                         system, |                         system, | ||||||
|                 }) |                     }, | ||||||
|  |                     SystemIdMarker, | ||||||
|  |                 )) | ||||||
|                 .id(), |                 .id(), | ||||||
|             marker: std::marker::PhantomData, |             marker: std::marker::PhantomData, | ||||||
|         } |         } | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 databasedav
						databasedav