I'm wondering what the best way of optimizing code for a number of different AI would be.. currently using
on EnemyFamily created [general enemy initialization code]
on Enemy1 created [enemy specific initialization code]
on Enemy2 created [enemy specific initialization code]
on Enemy3 created [enemy specific initialization code]
if Enemy1.count > 0
[Enemy1 specific AI code]
if Enemy2.count > 0
[Enemy2 specific AI code]
if Enemy3.count > 0
[Enemy3 specific AI code]
... etc for 40 or so different enemies. Already using families to group most of the similar code but there's quite a few unique things to each enemy (e.g., teleportation, spell casting, etc.). Profiler tells me my enemy code is still using a good chunk of CPU time even when there are no enemies spawned. Wondering if there is a better way to segment off enemy specific code so it doesn't keep checking to run if nothing is spawned. For example, is it better to check if the enemy sprite is visible? Or have a Global variable increase if there is that type of enemy spawned?
Thanks for any help guys!