I have based my game on the NetworkStateManagement sample. I am writing a Sound Engine that handles background music and sound effects. Since this engine needed an Update method to be called at all times, I decided to implement it as a GameComponent.
I know that for game service there is a
Services.GetService(typeof(XXX))
But for game components I have not found an elegant way of doing it. Since I had to reference it from the GamePlay screen, I had to do this:
soundEngine = (SoundEngine)ScreenManager.Game.Components[3];
Which I don't like.
So my question is, is there a nice way of getting a reference to a GameComponent without passing the reference all the way across different screens? I would have used a Game Service but I really need the Update(GameTime) method to be constantly called.