For an RTS game, lets say I have individual units, and unit_groups which store information which all of the units in the group share.
So for example, I select a group with a mouse, and then click somewhere. The group will store a position, and all of the units of this group will move to that position.
Can I store a list of all the units in the group entity in one of its components? This is so that in a job, I could just go ForEach(Unit_Group), and then loop through all of the units in the group and move them.
Inside a job:
// For each unit group
// For each unit associated with this group
// Do some work on this unit
For reference, I am trying to replicate what the Total War series does with their unit groups and individual units.
What I think I’ll do is just make a separate IComponentData for each group, and just have a separate job for each group as that way I can easily filter out the groups I dont need, at the cost of extra repetitive code.
have a system that takes player input, runs some calculations to see the area the clicks/drags affects
the system from 1 affects the entities in the area and attaches a component to them (let’s call it Input, or Selected or whatever you feel). This system also always runs to update this component we attach; so it has a job selecting the entities with the Input component and updates that component with player Input actions because this component contains some data fields that retain the needed data from the Input (something like public float3 RightClickPointInWorld)
have a system running on the entities with the Translation and Input/Selected/your component name; The do a ForEach that reads from Input and writes to Translation. So you take the meaningful Input data (e.g clickInWorldWhereINeedToGo) and then act on the entity Translation by further calculations
This is the way I understand data design at the moment (which might not be optimal and will keep an eye for other suggestions here) and I hope it’s useful for you.