I have the following problem:
I have a a class called Stage, that keeps an list of entities, which it iterates over every update loop, and updates them. One of these entities might be a weapon (PEW PEW!) that when updating spawns new entities (projectiles, KA-ZOOM, KER BANG!). How do I add these new entities to the list in of entities in Stage? Currently, I have Stage as an singleton with global access, so that the entities which in turn spawns entities just calls the instance of Stage's addEntity method, but that feels silly.
Stage -> Entity (weapon) -> Stage again?
I have a similar problem when creating enemies:
Stage -> Entity (enemy wave) -> Stage again
I've been thinking about passing the List into all entities that can create other entities, but then I'd have to change the update method for the base Entity class so that it takes this list, a list which most entities have no need of. Also, when adding an entity to Stage, Stage must be made aware of a number of graphics components for that entity, in order for Stage to be able to tell the renderer (which has an OpenGL context) to load the appropriate resources for those graphic components.
Any ideas what I should do? Am I doing it the wrong way now?
Also, while we're at it, why is Singletons so frowned upon?