-
Notifications
You must be signed in to change notification settings - Fork 5
Initialization
URSA is built around Global and Local controlled initialization sequences. Initialization sequence is the backbone of URSA, it is very important. InitializerSystem provides public events to which you can hook up to customize initialization.
Sequences are implemented in InitializerSystem that resides on Global Systems stack.
#Global start sequence
When we start the game and GlobalSystems start working this is what happens:
IEnumerator GlobalInitializationSequence() {
for (;;) {
OnGlobalLoadConfigs();
yield return null;
OnApplicationConfiguration();
yield return null;
OnInitialLoadPersistentData();
yield return null;
OnGlobalSystemsEnabled();
globalInitialized = true;
yield break;
}
}
OnGlobalLoadConfigs
is where we deserialize configuration files from disk.
OnApplicationConfiguration
- use those configs to setup our app, resolution, input etc.
OnInitialLoadPersistentData
- load whatever you need from disk here
OnGlobalSystemsEnabled
- activate the rest of global systems that rely on configs
#Local Start Sequence
IEnumerator LocalInitializationSequence() {
for (;;) {
while (!globalInitialized)
yield return null;
yield return null;
OnLoadLocalData();
yield return null;
OnLoadersEnabled();
yield return null;
OnSystemsEnabled();
//Launch game loop
Pool<InternalConfig>.First.UpdateAllowed.Value = true;
FullyInitialized = true;
OnUiEnabled();
yield break;
}
}
OnLoadLocalData
- Load Save files
OnLoadersEnabled
- activate Loaders and let them rebuild the scene from data
OnSystemsEnabled
- activate Systems