IEnumerator SimulationSuccess() { // send this to the server first string upload_data = "filename\t" + filename + "\ntimestamp\t" + DateTime.Now.ToString("yyyyMMddHHmmss") + "\n\n" + System.IO.File.ReadAllText(filename); if (GameManager.Instance.tracker.remote_tracking_enabled) { GameManager.Instance.tracker.UploadData(upload_data); } UnityEngine.Debug.Log("It's now time to load " + filename); StreamReader reader = new StreamReader(filename); if (simulationMode == SimulationTypes.PCG) { GameManager.Instance.GetSaveManager().currentSave.AddNewPCGLevel(reader.ReadToEnd()); } _lastPCGLevelGenerated = reader.ReadToEnd(); GameManager.Instance.GetSaveManager().UpdateSave(); bool restartPhase = (simulationMode == SimulationTypes.PCG); GameManager.Instance.TriggerLoadLevel(restartPhase, DataManager.LoadType.FILEPATH, filename); //in case it takes time to load larger levels while (GameManager.Instance.gamePhase != GameManager.GamePhases.PlayerInteraction) { yield return(new WaitForEndOfFrame()); } simulationFeedback = SimulationFeedback.success; }
IEnumerator externalNonBlockingWait() { // ExitCode = 0: OK // ExitCode = 1: System Errors // ExitCode = 2: Errors parsing input, use support.validate to check input // ExitCode = 3: Search budget depleted, no results, try a bigger budget // ExitCode = 4: No results found, search space exhausted (other search errors) // ExitCode = 5: Wrong arguments // ExitCode = 6: Other exception within the ME Java code SimulationFeedback simulationFeedback = SimulationFeedback.none; if (externalProcess == null) { UnityEngine.Debug.Log("Process is null"); } else { while (!externalProcess.HasExited) { yield return(null); } int ExitCode = externalProcess.ExitCode; string mpout = ""; string line = null; string filename = ""; while ((line = externalProcess.StandardOutput.ReadLine()) != null) { filename = line; mpout += line + "\n"; } mpout += "Exit code: " + ExitCode.ToString(); UnityEngine.Debug.Log("Java finished here..."); if (ExitCode == 0) { UnityEngine.Debug.Log("It's now time to load " + filename); GameManager.Instance.TriggerLoadLevel(filename); //in case it takes time to load larger levels while (GameManager.Instance.gamePhase != GameManager.GamePhases.PlayerInteraction) { yield return(new WaitForEndOfFrame()); } simulationFeedback = SimulationFeedback.success; } else { UnityEngine.Debug.LogError(mpout); UnityEngine.Debug.LogError(externalProcess.StartInfo.Arguments); simulationFeedback = SimulationFeedback.failure; } GameManager.Instance.tracker.CreateEventExt("SimulationFeedback", externalProcess.ExitCode.ToString()); externalProcess = null; } UnityEngine.Debug.Log("Finished waiting."); if (OnSimulationCompleted != null) { OnSimulationCompleted(simulationFeedback); } }