Change SceneInstanceReady to trigger an observer.#13859
Conversation
@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! |
alice-i-cecile
left a comment
There was a problem hiding this comment.
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 |
alice-i-cecile
left a comment
There was a problem hiding this comment.
Fantastic work: I'm quite pleased with the end result.
Objective
The
SceneInstanceReadyevent 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
InstanceIdshould be included in the event.Testing
Modified the
scene_spawner::tests::eventtest to use the new mechanism.Changelog
SceneInstanceReadyto trigger an entity observer rather than be written to an event queue.SceneInstanceReadyto carry theInstanceIdof the scene.Migration Guide
If you have a system which read
SceneInstanceReadyevents: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: