mirror of
https://github.com/bevyengine/bevy
synced 2024-11-10 07:04:33 +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>,
|
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 a new issue