add exist check API for SaveSystemManager

Justus

Member
if there is not save data in target slot, following error will be reported.
1656492092617.png

Could you please add an API to check the existence of save file with target slot index?
 
I've added those two functions to the SaveSystemManager.
I hope that helps

Code:
/// <summary>
/// Checks if the manager has a save at the save index.
/// </summary>
/// <param name="saveIndex">The save file index.</param>
/// <returns>True if has save file.</returns>
public static bool HasSaveFile(int saveIndex)
{
    return Instance.HasSaveFileInternal(saveIndex);
}

Code:
/// <summary>
/// Check if the manager has a save file at the index provided.
/// </summary>
/// <param name="saveIndex">The save index.</param>
/// <returns>True if there is a save file.</returns>
protected virtual bool HasSaveFileInternal(int saveIndex)
{
    if (m_Saves == null || !m_Saves.ContainsKey(saveIndex)) {
        return false;
    }
    
    var saveData = ReadSaveDataFromDisk(saveIndex);
    if (saveData == null) {
        return false;
    }
    return true;
}
 
Top