API ServiceManager - shmellyorc/Box GitHub Wiki

ServiceManager

Manages registration, retrieval, initialization, and per-frame updates of application services.

This singleton container provides O(1) lookups for any GameService by its concrete type, automatically initializes new services, and maintains a list of UpdatableService instances to drive their Update(dt) on each frame.


Properties

Property Type Description
Instance ServiceManager Singleton instance of the service container.
Services IEnumerable<GameService> Read-only snapshot of all registered services.

Methods

Method Signature Description
RegisterService<T> void RegisterService<T>(T service)
where T : GameService
Registers and initializes a single service of type T;
throws if service is null or already exists.
RegisterManyServices void RegisterManyServices(params GameService[] services) Registers and initializes multiple services at once;
ignores empty input and throws on duplicates.
HasService<T> bool HasService<T>()
where T : GameService
Returns true if a service of type T is registered.
TryGetService<T> bool TryGetService<T>(out T service)
where T : GameService
Attempts to retrieve a registered service of type T;
returns false with service = null if absent.
GetService<T> T? GetService<T>()
where T : GameService
Retrieves a registered service of type T, or null if none is found.
⚠️ **GitHub.com Fallback** ⚠️