For example:
I have a game where 100000000 black flys live in the forest. Normally each fly sits and does nothing, but if there is a man is in the forest, all flys should start following him and try to bite him.
So I need a system that does 2 things:
- check if man exists (query for the entity with [man] component and its [position])
- and if the man was found iterates on all flys and call MoveTowards(man.position) function
the problem is with “if”, how to make a conditional query?
if the man isn’t in the forest, the second costly query should not happen
Best idea I have is to split it into 2 systems: CheckForManSystem and MoveFlysSystem
and to make CheckForManSystem enable/disable MoveFlysSystem
What is the best way to organize this behavior in ECS?
Is it possible to skip the second query using only one system?