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.
This commit is contained in:
Periwink 2025-02-02 15:10:37 -05:00 committed by GitHub
parent 55283bb115
commit 75e8e8c0f6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 20 additions and 0 deletions

View File

@ -307,6 +307,21 @@ impl ObserverDescriptor {
.extend(descriptor.components.iter().copied());
self.entities.extend(descriptor.entities.iter().copied());
}
/// Returns the `events` that the observer is watching.
pub fn events(&self) -> &[ComponentId] {
&self.events
}
/// Returns the `components` that the observer is watching.
pub fn components(&self) -> &[ComponentId] {
&self.components
}
/// Returns the `entities` that the observer is watching.
pub fn entities(&self) -> &[Entity] {
&self.entities
}
}
/// Event trigger metadata for a given [`Observer`],

View File

@ -312,6 +312,11 @@ impl Observer {
self.descriptor.events.push(event);
self
}
/// Returns the [`ObserverDescriptor`] for this [`Observer`].
pub fn descriptor(&self) -> &ObserverDescriptor {
&self.descriptor
}
}
impl Component for Observer {