Hi,
Here are two methods. The first only saves the quest journal. The second uses the full Quest Machine save system, which allows you to save the info on quest givers, spawners, etc., as well as the full set of save system savers (DestructibleSaver, ActiveSaver, PositionSaver, etc.).
Method 1:
Before leaving the old scene, get the quest journal data as a string:
Code: Select all
string s = yourQuestJournal.RecordData();
After loading the new scene, apply the saved data to the quest journal in the new scene:
Code: Select all
string s = yourOtherQuestJournal.ApplyData(s);
I'll skip the details since you'll probably want to go with method 2:
Method 2:
Set up Quest Machine's Save System as indicated in the save system manual. (GameObject with SaveSystem and JsonDataSerializer components. Untick the Save System component's Save Current Scene checkbox if you'll use TDE to save/load the player into the right scene.)
Before changing scenes, call PixelCrushers.SaveSystem.BeforeSceneChange() and RecordSavedGameData().
After loading the new scene, call PixelCrushers.SaveSystem.ApplySavedGameData().
For example, make a subclass of GoToLevelEntryPoint and override GoToNextLevel:
Code: Select all
public GoToNextEntryPointWithSave : GoToNextEntryPoint
{
public override void GoToNextLevel()
{
PixelCrushers.SaveSystem.OnBeforeSceneChange();
PixelCrushers.SaveSystem.RecordSavedGameData();
base.GoToNextLevel ();
}
}
Make a subclass of LoadingSceneManager that overrides LoadingComplete:
Code: Select all
public class LoadingSceneManagerWithSave : LoadingSceneManager
{
protected override void LoadingComplete()
{
base.LoadingComplete();
PixelCrushers.SaveSystem.ApplySavedGameData();
}
}
Saved Games
You'll probably also want to include this info in TDE saved games. To save:
Code: Select all
using PixelCrushers; // (Saves having to type the namespace below.)
string s = SaveSystem.Serialize(SaveSystem.RecordSavedGameData());
MMSaveLoadManager.Save(s, fileName, folderName);
To load:
Code: Select all
string s = (string)MMSaveLoadManager.Load(typeof(string), fileName, folderName);
SaveSystem.ApplySavedGameData(SaveSystem.Deserialize<SavedGameData>(s));