Make Scenes (More) Self-Contained
See original GitHub issueSummary
Duality is hardwired to always have one active Scene and some of its code is built on that assumption. Gradually move away from this by making Scenes self-contained / independent classes as a first step.
Analysis
- Internally, all Scenes share a single static physics
World
. Replace this with a Scene-local instance that is created on-demand and cleared / re-used. - Rename
scene.IsCurrent
toIsActive
to clear the way for future changes in behavior. - Find all references to
Scene.Current
and evaluate whether they can be removed or replaced withgameObj.ParentScene
. - Make
Render
andUpdate
API public and allow calling them when the Scene is not theCurrent
one.- Modify switch locking behavior to only trigger for the
Current
scene. - Write a unit test to verify whether Component methods for rendering and updates are properly called for non-
Current
scenes when called explicitly.
- Modify switch locking behavior to only trigger for the
- Replace the static
OnLeaving
andOnEntered
handlers with publicActivate
andDeactivate
methods for the scene class, allowing to properly activate and deactivate a secondary / non-Current
scene before calling update and render methods. - When done, consider going a step further and extracting
SceneManager
functionality fromScene
that would handle scene activity and (previously) static global events. This is a new issue that would have to be created afterwards.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:19 (19 by maintainers)
Top Results From Across the Web
1.1 – The Self Contained Emotional Statement
Being self-contained, the statement places you on solid ground without dictating the scene to your partners. Mick Napier urges us each to “take ......
Read more >How do you come up with scenes? : r/writing
Then each scene you write is based on the high level beats you've planned, so that every paragraph in the novel is on...
Read more >How to Write the Perfect Scene: 8 Elements of a Scene
The ability to craft great scenes is among the most valuable writing skills you can cultivate, whether you're involved in novel writing, ...
Read more >Scene Outline: How to Write Faster by Developing a List of ...
A scene outline can help you write faster—and a more coherent draft. ... A scene is usually a self-contained event, with its own...
Read more >Self-Contained: Scenes from a single life - Emma John
The book is an exploration of being lifelong single and what happens if you don't meet the right person, don't settle down with...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
For the overlap check methods, there isn’t really a big semantic difference between the instance and the static methods - they’re both asking “does X collide with (point or area) Y?” while either looking at all bodies, or just at a single one. It’s of course different for raycasts and broadphase queries, but still - not an unheard-of pattern to have a static method that finds instances of its class in a global scope.
Again, not saying the current approach is per se better, but that there’s a figurative score to be assigned to each approach, and a threshold to be crossed to switch from one to another - and that right now, it feels like that threshold is potentially reached, but without being an obvious case.
I’d probably just let that sink in for a bit and come back to it when it comes to actually updating the API. Sometimes you just have to play around with implementations and get some hands-on experience with either approach to see which is a better fit for the situation.
Reviewed the code in its current state and postponed further refactoring related to a potential
SceneManager
class in order to move forward with v3.0. Code looks fine so far, tests pass. Merged back, closing this.