mrrogge / rude

An ECS game engine built for LÖVE2D.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Accessing data across scenes

mrrogge opened this issue · comments

My original intention was to have scenes be independent from each other, however I'm starting to think it would be beneficial to allow a scene to access data from another scene. There are scenarios where this would be helpful, for example:

  • A scene that acts as a pause menu may want to access game data located in a "main" game scene
  • A scene may act as a "global repository" for state that is shared among multiple different scenes. That global scene could then be solely responsible for save file serialization, rather than managing that in all the other scenes.

It's worth noting that scenes can technically access each now by going through the engine, but it's not very elegant. I think adding a getComFromScene() method might be a cleaner way to control this access. If the scene doesn't exist we could return an exception, for example. Once a component table is returned, the system logic could then modify it however they want.