Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
I would like to ask how one would loop through a group while keeping units in the group without having to use ForGroup?
Perhaps something like a swap group, although I'm not really sure how to accomplish that.
The basic solution is a swap group. As long as you completely iterate the previous group you can add all units from the source group to another group and then at the end of the loop swap the source variable to use the new group. This is useful for performance critical systems that use groups and need to keep their contents.
It is not useable when the source of the group is not explicit such as a function parameter or a group referenced by multiple variables. In such a case the good old approach of ForGroup is probably best since you do not need to concern yourself about what references the group then.
One could technically abstract groups and implement a generic solution. If you make a struct "Group" then you could have multiple references references to a single explicit physical reference of the group so the swap group approach would work in all cases then. The extra abstraction does add overhead which may or may not be worth it.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.