-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Change SceneInstanceReady
to trigger an observer.
#13859
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes a lot of sense. Could you add some documentation to SceneInstanceReady
describing how to interact with it now?
@janhohenheim Good idea. I feel that "triggered" is the right verb for observers instead of "emitted". I added
Alternatively, this just occurred to me, I could rewrite it as follows and work the word "observer" in there but I think it's a bit more cumbersome:
|
@alice-i-cecile do we have some guideline for how to document something triggering observers? |
Not yet! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree: observers are a much nicer pattern here.
@komadori merge conflicts are non-trivial. Can you please resolve them and then ping me? <3 I'd like to merge this in. |
@alice-i-cecile I've merged in main. The conflicts were caused by #11741 adding more situations in which the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fantastic work: I'm quite pleased with the end result.
Objective
The
SceneInstanceReady
event would be more ergonomic (and potentially efficient) if it could be delivered to listeners attached to the scene entities becoming ready rather than into a World-global queue.This is an evolution of @Shatur's work in #9313.
Solution
The scene spawner is changed to trigger observers on the scene entity when it is ready rather than enqueue an event with
EventWriter
.This addresses the two outstanding feature requests mentioned on #2218, that i) the events should be "scoped" in some way and ii) that the
InstanceId
should be included in the event.Testing
Modified the
scene_spawner::tests::event
test to use the new mechanism.Changelog
SceneInstanceReady
to trigger an entity observer rather than be written to an event queue.SceneInstanceReady
to carry theInstanceId
of the scene.Migration Guide
If you have a system which read
SceneInstanceReady
events:It must be rewritten as an observer:
Or, if you were expecting the event in relation to a specific entity or entities, as an entity observer: