mirror of
https://github.com/bevyengine/bevy
synced 2024-11-22 20:53:53 +00:00
add SystemIdMarker
Component
to enable filtering for SystemId
Entity
s (#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
1 changed files with 11 additions and 4 deletions
|
@ -12,6 +12,10 @@ struct RegisteredSystem<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.
|
||||
/// It contains the system and whether or not it has been initialized.
|
||||
///
|
||||
|
@ -125,10 +129,13 @@ impl World {
|
|||
) -> SystemId<I, O> {
|
||||
SystemId {
|
||||
entity: self
|
||||
.spawn(RegisteredSystem {
|
||||
.spawn((
|
||||
RegisteredSystem {
|
||||
initialized: false,
|
||||
system,
|
||||
})
|
||||
},
|
||||
SystemIdMarker,
|
||||
))
|
||||
.id(),
|
||||
marker: std::marker::PhantomData,
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue