I’ve been looking around a little and can’t find any posts discussing any best practices for dependency injection in MonoGame. I would like to avoid passing arounds rarely loaded objects like the player, I have looked at this approach using autofac: http://bendetat.com/adding-dependency-injection-to-a-monogame-application.html
Can anyone recommend any other method for creating injectable singletons in your monogame project?
There is basic DI built into MonoGame. Every game includes a GameServicesContainer where you can add/access objects via type. Singletons are an antipattern, so its an easy way of accessing the same instance of an object throughout your game similar to a singleton.
so the way I see it now, I can instantiate a GameServicesContainer in my game class, attach services to it and either 1. create a static class where I can access it or 2. pass it through constructor to any given class where I need it. Or is there some better way?