コード例 #1
0
    public void Save(string basePath, string currentSaveDir)
    {
        if (GameState == null)
        {
            throw new CorruptSaveException("Missing GameState.");
        }

        if (UiState == null)
        {
            throw new CorruptSaveException("Missing UiState.");
        }

        var serializedGameState = SavedGameState.Save(GameState, Co8State != null);

        var serializedUiState = SavedUiState.Save(UiState, Co8State != null);

        // Write the files to the current save directory so they are added to the save archive afterwards
        WriteStateToDirectory(serializedGameState, serializedUiState, currentSaveDir);

        try
        {
            ArchiveWriter.Compress(basePath + ".tfai", basePath + ".tfaf", currentSaveDir);
        }
        finally
        {
            DeleteStateFromDirectory(currentSaveDir);
        }
    }