Facepunch / sbox-issues

176 stars 12 forks source link

Add FindAllWithTag/FindAllWithTags to GameObjectDirectory #4542

Open dch-GH opened 10 months ago

dch-GH commented 10 months ago

For?

S&Box

What can't you do?

Easily get a collection of GameObjects with a certain tags list.

How would you like it to work?

Seems like the only way to get a collection of GameObjects filtered by tags is either with a SceneTrace or by running a LINQ filter on Scene.GetAllObjects.

It would be great if the GameObjectDirectory provided an optimized lookup for us.

What have you tried?

.

Additional context

No response

garrynewman commented 10 months ago

Would it return child objects containing the tag, or just objects that directly contain the tag?

dch-GH commented 10 months ago

Would it return child objects containing the tag, or just objects that directly contain the tag?

I'd like to hear what others think, but it would be fair if it only returned root objects if returning root + children makes it overly complex. Guess you could have an argument like you do with getting components, https://asset.party/api/Sandbox.FindMode. Maybe just "bool includeChildren" in this case would suffice?