//##############################################################################################
    // Handle the sequential asynchronous loading of neighbor levels, and the unloading of old
    // levels. Also, if needed, perform a saveload.
    //##############################################################################################
    void Update()
    {
        if (!finishedLoading)
        {
            // If there are any levels left to load, mark ourselves as working, and load the scene
            // asynchronously. We do this async, so framerate isn't interrupted for the further
            // distant neighbor levels. Make sure to mark it as loaded, as well.
            if (loadQueue.Count > 0)
            {
                Level nextLevelToLoad = loadQueue.Peek();

                if (!currentlyWorking)
                {
                    currentlyWorking = true;
                    SceneManager.LoadSceneAsync((int)(nextLevelToLoad), LoadSceneMode.Additive);
                    levelIsLoaded[(int)(nextLevelToLoad)] = true;
                }
                else
                {
                    if (LevelCurrentlyLoaded(nextLevelToLoad))
                    {
                        loadQueue.Dequeue();
                        currentlyWorking = false;
                    }
                }
                // Once we've finished loading, begin unloading the previous, unneeded levels, much the
                // same way as above.
            }
            else if (unloadQueue.Count > 0)
            {
                Level nextLevelToUnload = unloadQueue.Peek();

                if (!currentlyWorking)
                {
                    currentlyWorking = true;
                    SceneManager.UnloadSceneAsync((int)(nextLevelToUnload));
                    levelIsLoaded[(int)(nextLevelToUnload)] = false;
                }
                else
                {
                    if (!LevelCurrentlyLoaded(nextLevelToUnload))
                    {
                        unloadQueue.Dequeue();
                        currentlyWorking = false;
                    }
                }
            }

            // Mark ourselves as all done
            finishedLoading = loadQueue.Count == 0 && unloadQueue.Count == 0;

            // Kick off queued saveload
            saveLoadQueued = WAIT_FRAMES_FOR_SAVELOAD;
        }

        // Wait a few frames to let level loading settle down
        if (saveLoadQueued > 0 && finishedLoading)
        {
            saveLoadQueued--;

            if (saveLoadQueued == 0)
            {
                // Only partially apply save
                SaveLoadManagerComponent.Instance().ApplySave(SaveLoadManagerComponent.SaveApplicationMode.PerLevel);
            }
        }
    }
 //##############################################################################################
 // Setup the instance, and create a new empty save
 //##############################################################################################
 void Start()
 {
     instance = this;
     save     = new Save();
 }