In each of the scenes of my game there are a number of “Module” objects. Certain operations require a list of all Modules in the current scene. I dislike using some sort of “ModuleHolder” class to hold a reference to all Modules because this needlessly splits Module-related code across two separate classes. My solution has been to find all objects of type Module when the scene loads and store this in a static array in the Module class itself.
This works swimmingly with one caveat. As different scenes have different modules (and even reloading the same scene creates different instances of the same Modules) I need to reset the array holding all Modules on any scene change. This leaves me with a nagging feeling that I am using statics “incorrectly” in some way.
The fact that my current implementation just works may be paramount, but I was wondering if there was perhaps an alternative way to do this that I might be missing. Any thoughts (or reassurances that I am not, in fact, abusing the static property)?