Skip to content
This repository was archived by the owner on Mar 25, 2020. It is now read-only.

Initialization

pointcache edited this page Jan 15, 2017 · 4 revisions

URSA is built around Global and Local controlled initialization sequences.

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

Clone this wiki locally