So yeah, don't use 'For each' unnecessarily.
In the event where you are using foreach to pick associated objects by uid, do you know of more elegant solutions than the typical:
Foreach Character
Pick dictionary by UID (character.myDictionaryUID)
Pick collider by UID (character.myColliderUID)
etc...
Foreach element in myArray
pick Effect by uid (myArray.currentvalue)
For each effect, pick refferences objects by uid
In the past, I never had a need to think about the efficiency of all this foreach and picking stuff because it was only for dynamic characters (like npc and main player for example). Maybe you have 30 characters active in a scene. But now Iʻm trying to do a bullet hell and every bullet carries a dynamic list of effects (easily dozens) and those effects may further reference other objects, custom actions, etc.... So I find myself needing to do a foreach over a 1000 bullets (to pick ascociated objects) and then a foreach over an array of elements containing a reference to the list of effects that bullet is affected by. If the effect is a general effect, I can just do that without picking, but sometimes the effect also needs to pick other objects as well such as the object that fire the bullet.
All this picking seems to be required in order to maintain a system where projectiles and characters can be decorated by numerous effects and have many links to one another or characters in the scene.
Many times the effect list can be 0, so I can filter those out and not bother iterating and picking them. But other times, it can be every single bullet has a dozen effects that all need updated.
For every object that needs to pick another object by uid, I have to run a foreach on using this architecture.
This seemed to be the standard approach, but is there an updated way these days?