Skip to content

Game.SceneFlow.SaveHelpers

Assembly: Assembly-CSharp (game executable)
Namespace: Game.SceneFlow

Type: static class

Base: System.Object

Summary:
Utility helpers related to save/load operations and save-game asset paths. Provides a constant task name used by save/load workflows, a helper to obtain a platform-aware AssetDataPath for a save, and a helper to delete a save (including cleaning up related last-save metadata and removing the asset from the global database). Intended for use by scene flow and save/load code in the game.


Fields

  • public const string kSaveLoadTaskName = "SaveLoadGame"
    Name of the save/load task used by the scene flow / task system. Can be referenced by code that schedules or identifies the save/load job.

Properties

  • None

Constructors

  • None (static class)

Methods

  • public static AssetDataPath GetAssetDataPath<T>(ILocalAssetDatabase database, string saveName)
    Returns an AssetDataPath representing where the save should be stored or looked up. Behavior:
  • By default returns the provided saveName wrapped as an AssetDataPath.
  • If the provided ILocalAssetDatabase is not using a remote storage source (dataSource.isRemoteStorageSource == false), it queries EnvPath.GetSpecialPath() for a special directory path associated with type T.
  • If EnvPath returns a non-null specialPath, an AssetDataPath is created via AssetDataPath.Create(specialPath, saveName) and returned instead.
  • Use T to indicate the kind of asset path you want (the EnvPath system maps types to platform/special folders).
  • This avoids using special local paths when the database points to remote/cloud storage.

  • public static void DeleteSaveGame(SaveGameMetadata saveGameMetadata)
    Deletes a save game and performs related cleanup:

  • If the game's current UserState (GameManager.instance.settings.userState) has lastSaveGameMetadata equal to the provided saveGameMetadata, that reference is cleared, the user state is applied and saved (userState.ApplyAndSave()), and Launcher.DeleteLastSaveMetadata() is called to remove launcher-side metadata.
  • Finally, AssetDatabase.global.DeleteAsset(saveGameMetadata) is called to remove the asset from the global asset database.
  • Side effects: modifies persistent user settings and removes the save asset. Ensure the caller handles any UI/state changes or confirmation prompts before calling.

Usage Example

// Get a platform-aware path for a save called "MyCitySave"
AssetDataPath path = SaveHelpers.GetAssetDataPath<SaveGameMetadata>(localDatabase, "MyCitySave");

// Delete a save and clean up last-save metadata if necessary
SaveHelpers.DeleteSaveGame(saveGameMetadata);

Notes: - The GetAssetDataPath method checks database.dataSource.isRemoteStorageSource to avoid using local-only special paths for cloud/remote databases. - DeleteSaveGame uses global game singletons (GameManager.instance, AssetDatabase.global, Launcher) and will persist changes to user settings. Use with care when called from editor/mod tools or headless contexts.