IEnumerator BackgroundThreadSave(string path, string jsonState) { bool atCheckpoint = false; if (!loading) { atCheckpoint = CheckKnotStitchChanged(); } try { if (atCheckpoint) { SaveSnapshot(PreCheckpointSaveSlot); } File.WriteAllText(path, jsonState); } catch (Exception e) { Debug.LogError("Autosave failed at final stage: " + e.Message); } finally { story.BackgroundSaveComplete(); if (atCheckpoint) { SaveSnapshot(CheckpointSaveSlot); } } yield return(null); }