protected override IEnumerator MakeRequestCoroutine(Action <WorldSimulationState> onComplete, Action onError) { yield return(0); WorldSimulationState state = null; _getRequest.AddRequest((worldSimulationState) => { state = worldSimulationState; }, () => { }); yield return(new WaitUntil(() => state != null)); string filepath = String.Join(DataConfig.DirectoryDelimiter, _indexGenerator.RootPath(Application.persistentDataPath), SimulationConfiguration.IndexFilename); var request = new SaveSimulationStateJob.SaveSimulationStateJobRequest(filepath, state); SaveSimulationStateJob savejob = new SaveSimulationStateJob(request); savejob.Start(); yield return(new WaitUntil(() => savejob.IsDone)); onComplete(state); ClearCache(); }
protected override IEnumerator MakeRequestCoroutine(Action <WorldSimulationState> onComplete, Action onError) { WorldSimulationState state = null; WorldIndex worldIndex = null; _worldPersistanceService.Load((index) => worldIndex = index, () => { }); yield return(new WaitUntil(() => worldIndex != null)); string filepath = String.Join(DataConfig.DirectoryDelimiter, _indexGenerator.RootPath(Application.persistentDataPath), SimulationConfiguration.IndexFilename); var request = new LoadSimulationStateJob.LoadSimulationStateJobRequest(filepath); LoadSimulationStateJob loadJob = new LoadSimulationStateJob(request); loadJob.Start(); yield return(new WaitUntil(() => loadJob.IsDone)); if (loadJob.Output == null) { state = _simulationConfiguration.GenerateSimulationState(worldIndex); } else { state = loadJob.Output; } onComplete(state); }