So, I’m a pretty big fan of the package right now, but there’s not a lot of information out there, so I have a question about one part of my situation that I’m thinking about.
Would a collection of frequently-updating ‘things’ of multiple OOP-style classes - sharing a base data structure but with dev-defined per-class behaviour - benefit from DOTS in any direct/indirect way, or would I be better off just putting them in a managed list and enumerating each element?
The data structure of the main ‘things’ has ~20 fields, containing variable length arrays of smaller, similar ‘things’ with each of their own per-class behaviours that are triggered according to events(key presses mostly).
I’m not certain about it from what I know now. Maybe there’s some performance bonus to be had with the multi-threading, but the large and variable nature of the data structure of these objects seems like it might interfere with the implementation or performance of this system.
(also, I screwed up the post name somehow)
One way to restructure your main things is to ask what are you frequently accessing/modifying when updating. It surely can’t be the whole big thing. Those few variables that you frequently update is a candidate to be its own component with some systems updating it. Once you have refactored this, you repeat this again in other parts until all your data is translated into ECS.
Hi, IMO, your base data structure should be splited in IComponentData and each of your “per-class” behavior can be different system taht operates on entity with a certain set of component. You can use component tag to define exclusive behaviors.
A davenirline said, you need to take it step by step, focus on one behavior, think about hte data you need for that behavior only and convert it to IComponentdata and a System? Iterate the same process until you code is fully DOTS.
You will gain in perf with jobs and burst. You will gain in maintainability by splitting data from behavior and IMO system make it simpler to enforce the single responsibility principle.
So yes you will benefit from it i nhte long run but it also require a new mind set and some practice.
Over time, you’ll see some pattern emerge like behavior injection through generic system and struct defined in derived systems, command/event like pattern using native containers, reactive systems and so on.