I have many subsystems of my game. They can use each other. Earlier I was initializing and storing subsystems references into static Game object instead of making singleton. Now I see that Game has too many references to other classes and looks confusing:
public static PlayerSettings PlayerSettings { get { return _playerSettings; } }
public static CommunityClient Community { get; private set; }
public static DatabaseConnectionWrapper Database { get; set; }
public static LoginConnectionWrapper LoginProtocolConnection { get; set; }
public static WorldEmulatorConnection WorldEmulatorConnection { get; set; }
public static WorldPlayerConnection WorldPlayerConnection { get; set; }
public static WorldConnection WorldConnection { get { return IsEmulatorMode ? (WorldConnection)WorldEmulatorConnection : WorldPlayerConnection; } }
public static MusicManager MusicManager { get; private set; }
public static SkyboxManager SkyboxManager { get; private set; }
public static VKInfo VK { get; private set; }
What can I deal with it? I don't need abstraction for those subsystems. And I don't think singleton is nice for this situation - architecture looks splitted to pieces. I want to initialize all my subsytems in correct order from one place. But there are too many classes referenced...
ADDED
Looking at DI - I can send dependences to class constructor and initialize every class in static factory. This is what I'm looking for.
But I've just realized that my problem that when I'm trying using Unity3D object-component architecture I can't send dependences to constructor because class initialization is invoked from UnityEngine.
So in this case I need Singleton or Blob to keep references. if I throw Unity architecture out then I'll obtain all dependences from constructor and no singletons or blob is needed.
I need to rework my architecture that UnityEngine will not create objects which need to obtain references to subsystems but create these classes from my code and let them create and manage their UnityEngine "gameobjects".
Looking at DI - I can send dependences to class constructor and initialize every class in static factory. This is what I'm looking for. But I've just realized that my problem that when I'm trying using Unity3D object-component architecture I can't send dependences to constructor because class initialization is invoked from UnityEngine. So in this case I need Singleton or Blob to keep references. if I throw Unity architecture out then I'll obtain all dependences from constructor and no singletons or blob is needed. I need to rework my architecture that UnityEngine will not create objects which need to obtain references to subsystems but create these classes from my code and let them create and manage their UnityEngine "gameobjects".