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??
ID:1713772
|
|
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 |
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??