This page describes the classes and interfaces in InitializationSystem, how they interact with each other, and how they connect to the messaging and signal classes they depend on. This system defines no event or data classes of its own.
InitializationManager
Role: scene-level bootstrapper. Attach it to a GameObject in the first scene by creating a concrete subclass.
What it does:
- In
Awake, builds aBusRegistrycontaining aQueryBus,CommandBus,EventBus,SignalBus, andRequestDispatcher, and passes it toServiceLocator.Initialize. - In
Awake, calls the abstractRegisterSystemshook. Derived classes callSafeRegisterfrom there. - In
Start, creates anInitializationOrchestrator, runs the sync phase, awaits the async phase, clears the registry, and callsBusUtility.Raisewith aSignalforSaffronLibrarySignals.SystemsReady.
Interactions with dependencies:
BusRegistryandServiceLocatorreceive the buses it creates. Other systems retrieve them fromServiceLocatorafter this point.BusUtilityis used only to raise theSystemsReadysignal.
InitializationOrchestrator
Role: executes the initialization sequence. It is created and driven by InitializationManager.Start.
What it does:
InitializeSyncSystemsrunsIniton the event receivers, then on the other sync components. It does not catch exceptions.InitializeAsyncSystemsstartsInitAsyncon every async component at once, wraps each call so its failure is logged without faulting the others, and returns a task that completes when all have finished.
Interactions:
- Reads
InitializationRegistry.SyncInitializableEventReceivers,InitializationRegistry.SyncInitializables, andInitializationRegistry.AsyncInitializablesdirectly. It does not hold its own copies. - Does not interact with the bus or signal dependencies.
InitializationRegistry
Role: static holding area for components between registration and initialization.
What it does:
- Holds the sync and async component lists.
Register(sync overload) sorts sync components into the event receiver list or the general list.Register(async overload) adds async components.RegisterInitializableadds an object to each list it qualifies for, so one object can be in both.Clearempties all lists after initialization.
Interactions:
- Called by
InitializationManager.SafeRegisterduringAwake. - Called directly by scene components that register themselves in their own
Awake. - Its classification step is meant to check the
IEventReceiverinterface from the events dependency.
IInitializable
Role: contract for synchronous setup.
Implemented by any component that needs its Init method called during startup. Registered through SafeRegister or InitializationRegistry.
IAsyncInitializable
Role: contract for asynchronous setup.
Implemented by any component that needs to await work, such as loading external resources, during startup. The orchestrator runs these after all sync components and awaits them together. A failure in one is logged and does not stop the rest.
Dependency connections
| Dependency | How this system uses it |
|---|---|
BusRegistry | Created by InitializationManager and given to ServiceLocator. |
ServiceLocator | Receives the BusRegistry during Awake, so later code can reach the buses. |
BusUtility | Used in Start to raise the SystemsReady signal. |
SaffronLibrarySignals.SystemsReady | The signal raised once initialization completes. |
Signal | Created to carry the SystemsReady key when it is raised. |
IEventReceiver | Intended to mark sync components that should initialize first. |