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:
parent
55283bb115
commit
75e8e8c0f6
@ -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`],
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user