I have a class called GBody
It has many things inside like sprite, physics body, various required variables etc
I have a class called GGRoup
Group is a collection of GBodies, so I have a vector inside of GBodies
I have already added include GBody in GGroup
However, a GBody can possible be in N Groups and I cannot also include GGroup in GBody as causes error
I may have 100 Units on map.
20 and place in group 1
20 in group 2
20 in group 3
20 in group 4
20 in group 5
I have a group called “Selected” as when bodies are highlighted and selected they get placed in the selected body vector for
Each declared group has a function to select it such as a HUD button
Things that can happen
If I select group 5 button on HUD it highlights all group 5 bodies from its vector (Selected = group5)
If i drag my square selected over small parts of group clusters highlighting many bodies from many groups and tell them all move over somewhere, they all leave there group formation and form together where I told them
This is a standard strategy mechanic
Part of the problem is how I update every object. Cycle through all groups->cycling through all bodies to call update doesn’t seem best choice. Cycling through a world vector of objects to tell them update seems better. But then they may need to know what groups they are part of, but we cannot include group into body because body is already included in group. Bodies that are part of a group are to move together and require group center and group heading so seem that they require group info
Any tips of class structure please ? Looking for help as i am not sure. Project will be shared at the end
I have been thinking to have some kinda world vector for action groups. Once anything is selected and told move, they all get put into a new action group, and we update action groups bodies separately. Once group reaches target and formation control is not required, we can empty action group and delete.
My brain is melting