Class SaveHandler
- Namespace
- TinyLife
- Assembly
- Tiny Life.dll
A utility class used by the game for various actions and information related to saving and loading.
public static class SaveHandler
- Inheritance
-
SaveHandler
- Inherited Members
Methods
CreateSerializer(EventHandler<ErrorEventArgs>)
Creates a new Newtonsoft.Json.JsonSerializer that uses the Newtonsoft.Json.JsonSerializerSettings returned in CreateSerializerSettings(EventHandler<ErrorEventArgs>).
public static JsonSerializer CreateSerializer(EventHandler<ErrorEventArgs> errorHandler = null)
Parameters
errorHandler
EventHandler<ErrorEventArgs>An optional error handler.
Returns
- JsonSerializer
A new Newtonsoft.Json.JsonSerializer with some default values set.
CreateSerializerSettings(EventHandler<ErrorEventArgs>)
Creates a new instance of Newtonsoft.Json.JsonSerializerSettings, initialized to some default values for saving and loading Map and, specifically, MapObject instances.
Additionally, an errorHandler
can optionally be attached to determine what should happen when a serialization error occurs.
public static JsonSerializerSettings CreateSerializerSettings(EventHandler<ErrorEventArgs> errorHandler)
Parameters
errorHandler
EventHandler<ErrorEventArgs>An optional error handler.
Returns
- JsonSerializerSettings
A new instance of Newtonsoft.Json.JsonSerializerSettings with some default values set.
GetGameDir()
Returns a DirectoryInfo that points to the game's data directory. For more information on where this directory is stored, see https://docs.tinylifegame.com/articles/game_dir.html.
public static DirectoryInfo GetGameDir()
Returns
- DirectoryInfo
The game's data directory.
GetSaveDir(string)
Returns a DirectoryInfo that points to the directory that a save with the given name
is or would be stored in.
This method returns a subdirectory of GetSavesDir().
public static DirectoryInfo GetSaveDir(string name)
Parameters
name
string
Returns
- DirectoryInfo
The directory for the given save.
GetSavesDir()
Returns a DirectoryInfo that points to the game's saves directory. This method returns a subdirectory of GetGameDir().
public static DirectoryInfo GetSavesDir()
Returns
- DirectoryInfo
The game's saves directory.
Events
OnGameLoaded
An event that is raised before and after the game is loaded.
public static event Action<GameImpl, EventPhase> OnGameLoaded
Event Type
OnGameSaved
An event that is raised before and after the game is saved.
public static event Action<GameImpl, EventPhase> OnGameSaved
Event Type
OnSaveDataCreated
An event that is raised when the game's SaveHandler.SaveData is loaded.
public static event Action<GameImpl, SaveHandler.SaveData> OnSaveDataCreated
Event Type
OnSaveDataLoaded
An event that is raised when the game's SaveHandler.SaveData is saved.
public static event Action<GameImpl, SaveHandler.SaveData> OnSaveDataLoaded
Event Type
OnSaveLoadError
An event that is raised when a Newtonsoft.Json.JsonSerializer or Newtonsoft.Json.JsonSerializerSettings created in CreateSerializer(EventHandler<ErrorEventArgs>) or CreateSerializerSettings(EventHandler<ErrorEventArgs>) is used for serialization or deserialization, and an error occurs. This event is a subscription to Newtonsoft.Json.JsonSerializerSettings.Error.
public static event EventHandler<(ErrorEventArgs, EventPhase)> OnSaveLoadError
Event Type
- EventHandler<(ErrorEventArgs, EventPhase)>