I'm writing a game, where a player controls a spaceship. It regenerates energy over time. So I need to make a little timer that adds certain amount of energy to the pool per second. My enemies also shoot at me, activate different abilities. I figured I can use separate timers for these too. But I see how this can quickly go out of hand, since I have different engines with different energy regeneration rates - will I need to replace the timer every time? Or if I have different energy - I have to manually track all the timers and set them anew.
I thought, maybe I can use some global singleton method that can handle all the timing in my game? It can update everything in the game, and when something new happens (like new enemy spawning) I can just send my singleton information about that object and it will handle all the timing for it?
Is this a good approach? Can I read up something about this somewhere? Maybe you have some experience with this?