Ejemplo n.º 1
0
    public void Load(SaveGame saved, string voosFilePath = null)
    {
        StartCoroutine(PerformDeferredBehaviorUpgrades(saved.version));

        bool removeUnusedBehaviors = saved.version < FirstVersionAllowingUnusedBehaviors;
        var  usedBrainIds          = VoosEngine.GetUsedBrainIds(saved.voosEngineState.actors);

        if (saved.version < FirstVersionWithLegacyWarning)
        {
            behaviors.returnEmptyForMissingBuiltinBehaviors = true;
        }
        behaviors.LoadDatabase(saved.behaviorDatabase, removeUnusedBehaviors, usedBrainIds);

        engine.SetPersistedState(saved.voosEngineState);
        // Load stage before terrain..dependency there for world size. Not sure if good...shouldn't terrain just have its own size?
        stage.Load(saved.stage);
        terrain.SetPersistedState(stage.GetGroundSize(), saved.gridState);

        sojoSystem.Reset();
        if (saved.version >= FirstVersionWithSojoDatabase)
        {
            sojoSystem.LoadDatabase(saved.sojoDatabase);
        }
        if (saved.cardPacks != null)
        {
            behaviors.LoadCardPacks(saved.cardPacks);
        }
        if (saved.actorPacks != null)
        {
            sceneActorLibrary.LoadActorPacks(saved.actorPacks);
        }

        if (saved.version < FirstVersionWithLegacyWarning && !SuppressLegacyWarning)
        {
            popups.ShowTwoButtons(OLD_SAVE_MESSAGE,
                                  "Open Project Location", () => { Application.OpenURL("file://" + System.IO.Path.GetDirectoryName(voosFilePath)); },
                                  "OK", null, 800f);
        }
    }