Class SystemRegistry
ENGINE LAYER - Manages game system registration and initialization order
Responsibilities:
- Register all game systems
- Determine initialization order via topological sort
- Initialize systems in dependency order
- Detect circular dependencies
- Provide access to registered systems
Architecture:
- Pure mechanism, no game-specific knowledge
- Systems register themselves (or are registered by initializer)
- Dependency graph built from GameSystem.GetDependencies()
- Initialization order computed automatically
Usage: var registry = new SystemRegistry(); registry.Register(timeManager); registry.Register(economySystem); registry.InitializeAll(); // Initializes in dependency order
Benefits:
- No manual initialization order management
- Circular dependency detection at startup
- Missing dependency errors before runtime crashes
- Easy to add new systems (just register)
public class SystemRegistry
- Inheritance
-
objectSystemRegistry
Properties
IsInitialized
Get initialization status
public bool IsInitialized { get; }
Property Value
- bool
Methods
GetAllSystems()
Get all registered systems (for debugging)
public IReadOnlyList<GameSystem> GetAllSystems()
Returns
- IReadOnlyList<GameSystem>
GetSystem<T>()
Get a registered system by type Returns null if system not found
public T GetSystem<T>() where T : GameSystem
Returns
- T
Type Parameters
T
InitializeAll()
Initialize all registered systems in dependency order Uses topological sort to determine correct initialization order
public void InitializeAll()
IsRegistered<T>()
Check if a system is registered
public bool IsRegistered<T>() where T : GameSystem
Returns
- bool
Type Parameters
T
Register(GameSystem)
Register a system with the registry Must be called before InitializeAll()
public void Register(GameSystem system)
Parameters
systemGameSystem
ShutdownAll()
Shutdown all systems in reverse initialization order
public void ShutdownAll()