/// <summary> /// Serializes the current game state to a string /// </summary> public static string Serialize() { Instance.CurrentVersion = CoreParams.GetCurrentVersion(); return(JsonConvert.SerializeObject(Instance, Formatting.Indented, CoreParams.DefaultJsonSerializerSettings)); }
//our first "migration": sets LastMigratedVersion if not already set private static void MigrateLastMigratedVersion(GameState gs) { if (gs.LastMigratedVersion == null) { gs.LastMigratedVersion = CoreParams.GetCurrentVersion(); Debug.Log($"[GameState] Migrated to {gs.LastMigratedVersion} ({nameof(MigrateLastMigratedVersion)})"); } }
//our first "migration": sets LastMigratedVersion if not already set private static void MigrateLastMigratedVersion(ConfigState cs) { if (cs.LastMigratedVersion == null) { cs.LastMigratedVersion = CoreParams.GetCurrentVersion(); Debug.Log($"[ConfigState] Migrated to {cs.LastMigratedVersion} ({nameof(MigrateLastMigratedVersion)})"); } }
//our first "migration": sets LastMigratedVersion if not already set private static void MigrateLastMigratedVersion(PersistState ps) { if (ps.LastMigratedVersion == null) { ps.LastMigratedVersion = CoreParams.GetCurrentVersion(); Debug.Log($"[PersistState] Migrated to {ps.LastMigratedVersion} ({nameof(MigrateLastMigratedVersion)})"); } }
public static void Save() { Instance.CurrentVersion = CoreParams.GetCurrentVersion(); CoreUtils.SaveExternalJson(Path, Instance); }