https://www.dropbox.com/s/9tmx9e0cqbgzp ... .capx?dl=0
First things first. Although they have nothing to do with your question.
To make a flawless example i had to decide if they can rotate towards the player or not.
Since they are dumb plants, i decided not to. But then they have 2 states, mirror or not.
And as a consequence, they need a LOS cone. And as a consequence of that, the default state must be aligned with the default zero angle in C2. Since i dont know how to (temp) mirror in the layout editor, i added a 3th animation to be able to design in the layout editor as i want to. That is why the animations now align with the default zero angle in C2. So you know where halve of the code comes from.
Back 2 your question.
As you can see i will try to avoid a 'for each' at all costs. A 'for each' (depending on how many sprites in the loop) will always weight on performance. In this case that is perfectly possible because ALL sprites that meet the LOS condition will 'attack' and ALL sprites that dont meet the condition will be 'idle'. So there is no 'personal' thing going on. It is a 'all or nothing' case.
I have never seen a 'Once while true' work as intended in a loop. So i will avoid that to.
Usually you can not bring a 'shoot situation', a 'move situation' and a 'change animation situation' under the same condition. Because they often have different 'sample rates'. Gosh, how to explain that. Say, it runs at certain ticks / second. Each tick we can measure something, in other words : take a sample. The LOS needs a sample every tick. The animation change needs a sample only when something happens.
Starting from those 'base rules', (my personal rules) the way to go is already paved.
Has LOS, change to attack, else change to idle. I always bring conditions that are paired with an 'else' under an empty (every tick) condition. That way they stay together when i drag them around with my dumb brain.
For the animation. Done in a different event for reasons explained above.
Now, if i use a 'for each' then i am stuck with a 'Once while true' in a loop. So i look for something to avoid this. At the same time i prefer a picklist that contains only one plant, just as in the 'for each'.
Usually there is a trigger for that, and luckily there is a trigger in this case.
Just have to add a little logic to the trigger.
Notice also how nice the 'attack' loops, yet not a loop in the properties.
Hope this helped you some, despite my bad english, despite (maybe weird) personal rules.