ID:1713772
 
Keywords: for, group, list, regiment
(See the best response by Crazah.)
My previous battle system gets laggy all the time so I decided to change it and create a system similar to Total War regiment system. So how would I go for it? I thought creating a list that will contain all the mobs in the regiment and then use the for(i in list) to make them move or do something, but will all the mobs start executing this command instantaneously? and is this effective with 10-20 regiments??
Also guys if I have a list with 10 references and I delete an object that is being referenced by the list, is the reference in the list deleted or it simply remains there pointing to nothing.
eg
var/obj/o=new/obj()

var/list/l=new/list()
l+=o

del o

with this code I'm passing a reference to the list right??
Best response
You do exactly as you've said. Create a list with references to each unit, and iterate through them when you want to perform an operation on the whole regiment.

As for removing references, lists don't automatically update, so you'll have to sort through them and remove entries that point to null. There are some excellent resources for bubbleSort and other methods on the developer resources
Thanks for answering about the second point I'll just remove it from the list and then delete the object, that should work fine