I’m looking for the recommended architecture for project where the UI is built with C++ and CommonUI, but the core game logic relies on Mass.
What is the most efficient way to bridge Mass fragments/entities with widgets? I want to maintain a clean separation of concerns while efficiently pulling data from the Mass to the UI. I’m considering using the MVVM plugin. Is using the plugin to sync Mass with UI a recommended approach?
[Attachment Removed]
We do not have any best practices for this currently. I do not know that anyone here has prototyped much around connecting Mass and CommonUI. It is something that myself and another colleague wish to explore, but I certainly could not give you any best practices for it at this time. You may wish to look at some of the MassDebugger code where we collect fragment values for UI, but those are done for all entities matching the query every tick.
I believe you could have a processor that uses an entity query that wants the fragments that contain the data you wish to display and some kind of special tag for being displayed in the UI (if you would like to display health for a currently selected entity). After the processor runs, you could use a batch command to remove the tag from the entities. If you wish to update the UI on value change for health, you could have your processor that affects the value add the UI tag so that the Mass processor runs again to collect those entities whose data has changed. Keep the data in a manager or subsystem that handles mapping entities to their place in the array, and when the array has a value that changed could notify the UI. This added tag could even make use of the new SparseFragment feature in 5.8 to not cause archetype shifting of the entity.
-James
[Attachment Removed]