I often have a problem of the following kind:
Entity Human has a Profession and Profession has many GoodProduction.
Therefore Human (one to one) Profession (one to many) GoodProduction.
There will be a few hundred Professions and GoodProductions at most whereas I want the game to scale as big as possible in Humans.
The Human often needs to reevaluate which Good he should produce next. I have two options:
(A) Let the Human have a Profession component (linking to the Profession Entity) and the Profession have a GoodProduction-Buffer (not linking to entities but containing the actual data)
(B) Directly copy the GoodProductions to the Human Entity when he enters a certain profession. When the Human changes Profession, change this GoodProduction buffer.
The second option (B) allows me to have an actual linear data layout when I the “Evaluate which good to produce” system runs. On the other hand it will increase the Human Entity size by probably 8-24 bytes and will produce redunant data. Option (A) is more of a normalized (database) layout but I will always have to have random access to the Profession entities.
I have had similar decisions before**,** always of the kind “If my Entities share some data, should I copy it to the Entities or should they just link to another Entity that has their shared data.”
You only stuck at solving DOTS structure data layout.
Draw it in uml style visually might help https://www.draw.io/ or not
Go with B
Entity Human: Human tag, Profession tag, GoodProduction-dynamicbuffer (no need to worry about micro entity memory)
When change Profession, add ChangeProfessionTagToComponent to human and have a system query it then do whatever you want with dynamicbuffer
And do not use shared component data here. You only confuse and mix them up. Use Tag.
Yes. Basically (A) is how I think a database layout should look and how I avoid redunant data. (B) has linear access but makes the entities bigger.
I have also thought about this but I think I do not want to go down that route yet. If I now start using SharedComponent for Profession, I group them by profession. Later on maybe I want to also group them by the Village they live in (which makes other systems have linear access) or their corresponding “Wealth class”. I wanted to wait until the end to decide which systems are the heaviest and which components therefore will be SharedComponent. I do not want to use SharedComponent for everything, as then I will have very small chunk sizes.