-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Add named observers #18726
Copy link
Copy link
Closed
Labels
A-ECSEntities, components, systems, and eventsEntities, components, systems, and eventsC-FeatureA new feature, making something new possibleA new feature, making something new possibleD-ModestA "normal" level of difficulty; suitable for simple features or challenging fixesA "normal" level of difficulty; suitable for simple features or challenging fixesS-Needs-DesignThis issue requires design work to think about how it would best be accomplishedThis issue requires design work to think about how it would best be accomplishedX-ContentiousThere are nontrivial implications that should be thought throughThere are nontrivial implications that should be thought through
Metadata
Metadata
Assignees
Labels
A-ECSEntities, components, systems, and eventsEntities, components, systems, and eventsC-FeatureA new feature, making something new possibleA new feature, making something new possibleD-ModestA "normal" level of difficulty; suitable for simple features or challenging fixesA "normal" level of difficulty; suitable for simple features or challenging fixesS-Needs-DesignThis issue requires design work to think about how it would best be accomplishedThis issue requires design work to think about how it would best be accomplishedX-ContentiousThere are nontrivial implications that should be thought throughThere are nontrivial implications that should be thought through
Type
Fields
Give feedbackNo fields configured for issues without a type.
Projects
Status
Observer overhaul
What problem does this solve or what need does it fill?
Right now, when adding observers, they show up in the egui-inspector as
Observer (1v1),Observer (2v1)etc.With a large project, this can become quite cumbersome to read and understand, so I propose adding the ability to add names to observers.
What solution would you like?
Right now, you add observers with
app.add_observer(observer);, with no possiblity to specify different things.I propose to add
with_name(self, name: impl Into<String>)forIntoObserverSystem<E, B, M>, much likerun_if<M>(self, condition: impl Condition<M>)has been implemented forIntoScheduleConfigs<ScheduleSystem, M>.The final new api could look like this:
app.add_observer(observer.with_name("Custom Observer"));What alternative(s) have you considered?
None. While it is possible, to query for Observers, it is not possible to find out where they came from once they've been spawned, so while I could add a Name component after they've been spawned, I cannot know which one.
[edit]
@notmd mentioned, you could do
app.world_mut().add_observer(some_observer).insert(Name::new("Some observer"));, so for my project I'm going to write a functionadd_named_observer, which will be good enough for me.Additional context
I think this has been discussed in #16384, but was closed when the inspector added a default name for Observers.