Skip to content

Commit 75e8e8c

Browse files
Expose ObserverDescriptor fields (#17623)
# Objective Expose accessor functions to the `ObserverDescriptor`, so that users can use the `Observer` component to inspect what the observer is watching. This would be useful for me, I don't think there's any reason to hide these.
1 parent 55283bb commit 75e8e8c

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

crates/bevy_ecs/src/observer/mod.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,21 @@ impl ObserverDescriptor {
307307
.extend(descriptor.components.iter().copied());
308308
self.entities.extend(descriptor.entities.iter().copied());
309309
}
310+
311+
/// Returns the `events` that the observer is watching.
312+
pub fn events(&self) -> &[ComponentId] {
313+
&self.events
314+
}
315+
316+
/// Returns the `components` that the observer is watching.
317+
pub fn components(&self) -> &[ComponentId] {
318+
&self.components
319+
}
320+
321+
/// Returns the `entities` that the observer is watching.
322+
pub fn entities(&self) -> &[Entity] {
323+
&self.entities
324+
}
310325
}
311326

312327
/// Event trigger metadata for a given [`Observer`],

crates/bevy_ecs/src/observer/runner.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,11 @@ impl Observer {
312312
self.descriptor.events.push(event);
313313
self
314314
}
315+
316+
/// Returns the [`ObserverDescriptor`] for this [`Observer`].
317+
pub fn descriptor(&self) -> &ObserverDescriptor {
318+
&self.descriptor
319+
}
315320
}
316321

317322
impl Component for Observer {

0 commit comments

Comments
 (0)