Component in the game that exposes save/load functions for player data. It defines a save filename and two static methods that write and read PlayerSaveData to the sandboxed FileSystem.Data as JSON.
using Sandbox;
using System;
public sealed class SaveLoadSystem : Component
{
[Property] public ChickenControls chicken { get; set; }
private const string SaveGameFile = "SaveGameFile.json";
public static void SaveGame(PlayerSaveData data )
{
FileSystem.Data.WriteJson( SaveGameFile, data );
}
public static PlayerSaveData LoadGame()
{
return FileSystem.Data.ReadJson<PlayerSaveData>( SaveGameFile );
}
}