コード例 #1
0
    public static bool CanLoadSave()
    {
        bool   flag = true;
        string activeSaveFilePath = SaveLoader.GetActiveSaveFilePath();

        flag = WorldGen.CanLoad(activeSaveFilePath);
        if (!flag)
        {
            SaveLoader.SetActiveSaveFilePath(null);
            flag = WorldGen.CanLoad(WorldGen.SIM_SAVE_FILENAME);
        }
        return(flag);
    }
コード例 #2
0
    protected override void OnSpawn()
    {
        string activeSaveFilePath = GetActiveSaveFilePath();

        if (WorldGen.CanLoad(activeSaveFilePath))
        {
            Sim.SIM_Initialize(Sim.DLL_MessageHandler);
            SimMessages.CreateSimElementsTable(ElementLoader.elements);
            SimMessages.CreateDiseaseTable();
            loadedFromSave  = true;
            loadedFromSave  = Load(activeSaveFilePath);
            saveFileCorrupt = !loadedFromSave;
            if (!loadedFromSave)
            {
                SetActiveSaveFilePath(null);
                if (mustRestartOnFail)
                {
                    MoveCorruptFile(activeSaveFilePath);
                    Sim.Shutdown();
                    App.LoadScene("frontend");
                    return;
                }
            }
        }
        if (!loadedFromSave)
        {
            Sim.Shutdown();
            if (!string.IsNullOrEmpty(activeSaveFilePath))
            {
                DebugUtil.LogArgs("Couldn't load [" + activeSaveFilePath + "]");
            }
            if (saveFileCorrupt)
            {
                MoveCorruptFile(activeSaveFilePath);
            }
            bool flag = WorldGen.CanLoad(WorldGen.SIM_SAVE_FILENAME);
            if (!flag || !LoadFromWorldGen())
            {
                DebugUtil.LogWarningArgs("Couldn't start new game with current world gen, moving file");
                if (flag)
                {
                    KMonoBehaviour.isLoadingScene = true;
                    MoveCorruptFile(WorldGen.SIM_SAVE_FILENAME);
                }
                App.LoadScene("frontend");
            }
        }
    }