How can I get all Actor(s) with specified tag in code?

Hello. How might I get all the Actors with a specified tag (e.g. Enemies, Player) from code and store that as an Actor variable/array?

This code is slow as it iterates over all actors but works:

    private static void Search(Actor a, List<Actor> list)
    {
        if (a.HasTag("Enemy"))
            list.Add(a);
        for (int i = 0; i < a.ChildrenCount; i++)
            Search(a.GetChild(i), list);
    }

    public override unsafe void OnStart()
    {
        var list = new List<Actor>();
        for (int i = 0; i < Level.ScenesCount; i++)
            Search(Level.GetScene(i), list);
        // use list...
}

There is a plan to add a more complex tags system for actors that would include some robust objects searching for tags.

Yeah, I bet this would run pretty slow and not be good for memory. So far, just getting a child actor from the Scene actor has worked just as good, so unless I run into a problem with my current method, I’ll keep using it.