private void OnProviderLoaded(SavegameData savegameData) { isBusy = false; T savegame = new T(); savegame.Initialize(savegameData.Savegame, savegameData.Metadata); if (OnLoadComplete != null) { OnLoadComplete(savegame); } }
public virtual void Write <T> (SavegameData pData, Action OnComplete, Action <Exception, int> OnError) where T : ISavegame { if (!Directory.Exists(mPath)) { Directory.CreateDirectory(mPath); } UpdateMetadataList(pData.Metadata); WriteMetadata <T>(mPath + mMetadataFilename, null); string target = mPath + mFilenameTemplate; target = string.Format(target.ToString(), pData.Metadata.Id); WriteSavegame(target, pData.Savegame, OnComplete); }
void ReadSavegame(string pSource, int ID, Action <SavegameData> OnComplete) { var reader = new StreamReader(pSource); string result = reader.ReadToEnd(); reader.Close(); Metadata metadata = GetSavegameMetadata(ID); if (metadata == null) { throw new KeyNotFoundException("Metadata not found for ID: " + ID); } SavegameData sgData = new SavegameData(metadata, result); if (OnComplete != null) { OnComplete(sgData); } }
IEnumerator ReadSavegameAsync(string pSource, int ID, Action <SavegameData> OnComplete) { var progress = IOBridge.Storage.Load(pSource); while (!progress.IsDone) { yield return(true); } Metadata metadata = GetSavegameMetadata(ID); if (metadata == null) { throw new KeyNotFoundException("Metadata not found for ID: " + ID); } SavegameData sgData = new SavegameData(metadata, progress.GetContent()); if (OnComplete != null) { OnComplete(sgData); } }