BSN: scene.spawn() system ergonomics#23868
Conversation
|
Why not use a .pipe(spawn) approach? That would be much simpler, both internally and in terms of teaching. |
There was a problem hiding this comment.
When first seeing this, I thought and posted in discord that perhaps we could just use piping with a generic function provided by the ECS. app.add_systems(Startup, scene.pipe(scene_spawner))
Although I quickly realized that would just end up with a scene_spawner per scene, which is equivalent to this, but this is on a trait impled on the scene function, so its even better. 👍
Edit: ninja'd by alice
|
Another proposed alternative: make a system generating function that works like our run conditions, then pass in your functions that return scenes to that :) |
This is an interesting thought. However I don't think we're ready to start training people to think of "scene functions" as "systems":
With reactivity, we might be able to start thinking about scenes this way, but the mechanism there is still very TBD. I think training people to think of "scene functions" as systems themselves would be a mistake at this stage, and we might never want to do this.
Do you mean something like |
|
Okay, agreed that we should rule out the first. For the second, call it I think that that's a simpler pattern and something that users can comfortably learn from and modify. |
One downside of this is that we need two different functions for this: The method-style approach also means we don't need to have |
Should be easy enough to solve with a I think I've made my case though; I'll defer to your judgement here! |
I'd argue that this is what my current |
Objective
Spawning a scene on startup is a common pattern. Lets make it easier to do so!
Solution
SpawnSystemandSpawnListSystemtraits that are implemented for functions that return scenes / scene lists, and return a system that spawns the scene / handles errors.Before
After
This cuts out some boilerplate. It also further encourages people to define standalone "scene functions" rather than embedding them in code, which is generally a good pattern.