I'm writing a 2d game for Android in Java using LibGDX. The game consists many interactions between different types of objects. Most of them happen between enemies and bullets. At the beginning, I needed to check every moment if any enemy collide any bullet (if their masks overlaps each other). The code for checking overlap is clear to me. My question is how should I make the interactions be checked between everyone every moment?
What I did is creating a class called InteractionsManager which takes the array of all enemies and the array of bullets and checking in every step collision between each other (if collision happens, it calls the object's onCollision(Object object) method).
My problem got bigger when I needed to check other interactions types (like if enemy is in a specific distance from other type of object and other stuff like that).
I thought about passing to each object the InteractionsManager object and it should tell it whatever interaction it needs.