Adventure Creator  1.68.2
An adventure game toolkit for Unity, by Chris Burton, ICEBOX Studios 2013-2018
AC.SaveSystem Class Reference
Inheritance diagram for AC.SaveSystem:

Public Member Functions

void SetGameplayReturnTime (float _gameplayInvokeTime)
 Sets the delay after loading a saved game before gameplay is resumed. This is useful in games with custom systems, e.g. weapons, where we want to prevent firing being possible immediately after loading. More...
 
void GatherSaveFiles ()
 
void GatherImportFiles (string projectName, string filePrefix, int boolID)
 Searches the filesystem for all available import files, and stores them in foundImportFiles. More...
 
string GetSaveExtension ()
 Gets the extension of the current save method. More...
 
void SetSelectiveLoadOptions (SelectiveLoad selectiveLoad)
 Sets the local instance of SelectiveLoad, which determines which save data is restored the next time (and only the next time) LoadGame is called. More...
 
void ClearAllData ()
 
void ReceiveDataToImport (SaveFile saveFile, string saveFileContents)
 Processes the save data requested by ImportSaveGame More...
 
void ReceiveDataToLoad (SaveFile saveFile, string saveFileContents)
 Processes the save data requested by LoadSaveGame More...
 
void OnFinishSaveRequest (SaveFile saveFile, bool wasSuccesful)
 Handles the what happens once a save file has been written More...
 
void SaveCurrentPlayerData ()
 Stores the PlayerData of the active Player.
 
bool DoImportCheck (string fileData, int boolID)
 Checks that another game's save file data is OK to import, by checking the state of a given boolean variable More...
 
string GenerateSaveSuffix (int saveID, int profileID=-1)
 Creates a suffix for save filenames based on a given save slot and profile More...
 
string GetSlotLabel (int elementSlot, int saveID, bool useSaveID, SaveFile[] saveFiles)
 Gets the label of a save file. More...
 
Texture2D GetScreenshot (int elementSlot, int saveID, bool useSaveID, SaveFile[] saveFiles)
 Gets the screenshot of a save file. More...
 
bool DoesPlayerDataExist (int ID, bool doSceneCheck=false)
 Checks if PlayerData for a given Player has been generated. More...
 
int GetPlayerScene (int ID)
 Gets the current scene number that a Player is in. More...
 
string GetPlayerSceneName (int ID)
 Gets the current scene nsmr that a Player is in. More...
 
void MoveInactivePlayerToCurrentScene (int ID, Transform newTransform, _Camera associatedCamera=null)
 Updates the internal record of an inactive Player's position to the current scene, provided that player-switching is allowed. If that Player has an Associated NPC, then it will be spawned or teleported to the Player's new position More...
 
void AssignPlayerAnimData (Player player)
 Updates a Player object with its associated saved animation data, if it exists. More...
 
void AssignPlayerAllData (Player player)
 Updates a Player object with its associated saved data, if it exists. More...
 
int AssignPlayerData (int ID, bool doInventory, bool doCamera, bool snapCamera=true)
 Unloads stored PlayerData back onto the Player object. More...
 
List< InvItemGetItemsFromPlayer (int _playerID)
 Returns a list of inventory items currently carried by a particular Player. More...
 
void AssignItemsToPlayer (List< InvItem > invItems, int _playerID)
 Re-assigns the inventory items currently carried by a particular Player. More...
 
void RenameSave (string newLabel, int saveIndex)
 Renames the label of a save game file. More...
 
void DeleteProfile (int profileIndex=-2, bool includeActive=true)
 Deletes a player profile by referencing its entry in a MenuProfilesList element. More...
 
void DeleteProfileID (int profileID)
 Deletes a player profile ID. More...
 
void DeleteSave (int elementSlot, int saveID, bool useSaveID)
 Deletes a save game file. More...
 
int GetNumSaves (bool includeAutoSaves=true)
 Gets the number of save game files found. More...
 

Static Public Member Functions

static bool DoesImportExist (int saveID)
 Checks if an import file with a particular ID number exists. More...
 
static bool DoesSaveExist (int elementSlot, int saveID, bool useSaveID)
 Checks if a save file with a particular ID number exists More...
 
static bool DoesSaveExist (int saveID)
 Checks if a save file with a particular ID number exists More...
 
static void LoadAutoSave ()
 
static void ImportGame (int elementSlot, int saveID, bool useSaveID)
 Imports a save file from another Adventure Creator game. More...
 
static void ContinueGame ()
 
static void LoadGame (int saveID)
 Loads a save game file. More...
 
static void LoadGame (int elementSlot, int saveID, bool useSaveID)
 Loads a save game file. More...
 
static void SaveNewGame (bool overwriteLabel=true, string newLabel="")
 Create a new save game file. More...
 
static void SaveAutoSave ()
 Overwrites the AutoSave file.
 
static void SaveGame (int saveID, bool overwriteLabel=true, string newLabel="")
 Saves the game. More...
 
static void SaveGame (int elementSlot, int saveID, bool useSaveID, bool overwriteLabel=true, string newLabel="")
 Saves the game. More...
 
static int GetNumImportSlots ()
 Gets the number of found import files. More...
 
static int GetNumSlots ()
 Gets the number of found save files. More...
 
static string GetImportSlotLabel (int elementSlot, int saveID, bool useSaveID)
 Gets the label of an import file. More...
 
static string GetSaveSlotLabel (int elementSlot, int saveID, bool useSaveID)
 Gets the label of a save file. More...
 
static Texture2D GetImportSlotScreenshot (int elementSlot, int saveID, bool useSaveID)
 Gets the screenshot of an import file. More...
 
static Texture2D GetSaveSlotScreenshot (int elementSlot, int saveID, bool useSaveID)
 Gets the screenshot of a save file. More...
 
static void AssignVariables (string runtimeVariablesData, bool fromOptions=false)
 Unloads stored global variable data back into the RuntimeVariables script. More...
 
static string CreateVariablesData (List< GVar > vars, bool isOptionsData, VariableLocation location)
 Condenses the values of a List of variables into a single string. More...
 
static List< GVarUnloadVariablesData (string data, List< GVar > existingVars, bool fromOptions=false)
 
static void DeleteSave (int saveID)
 Deletes a save game file. More...
 

Public Attributes

LoadingGame loadingGame
 
List< SaveFilefoundSaveFiles = new List<SaveFile>()
 
List< SaveFilefoundImportFiles = new List<SaveFile>()
 
const string pipe = "|"
 
const string colon = ":"
 

Properties

bool IsTakingSaveScreenshot [get]
 
static iSaveFileHandler SaveFileHandler [get, set]
 
static iFileFormatHandler FileFormatHandler [get, set]
 

Detailed Description

Processes save game data to and from scene objects.

Member Function Documentation

◆ AssignItemsToPlayer()

void AC.SaveSystem.AssignItemsToPlayer ( List< InvItem invItems,
int  _playerID 
)

Re-assigns the inventory items currently carried by a particular Player.

Parameters
invItemsA List of InvItem instances representing the inventory items
_playerIDThe ID number of the Player to assign the inventory of

◆ AssignPlayerAllData()

void AC.SaveSystem.AssignPlayerAllData ( Player  player)

Updates a Player object with its associated saved data, if it exists.

Parameters
playerThe Player to load animation data for

◆ AssignPlayerAnimData()

void AC.SaveSystem.AssignPlayerAnimData ( Player  player)

Updates a Player object with its associated saved animation data, if it exists.

Parameters
playerThe Player to load animation data for

◆ AssignPlayerData()

int AC.SaveSystem.AssignPlayerData ( int  ID,
bool  doInventory,
bool  doCamera,
bool  snapCamera = true 
)

Unloads stored PlayerData back onto the Player object.

Parameters
IDThe ID of the Player to affect
doInventoryIf True, updates the Player's inventory (both items and documents)
doCameraIf True, updates the Player's camera
snapCameraIf doCamera = True, then the camera will be snapped to
Returns
The Player's new scene number

◆ AssignVariables()

static void AC.SaveSystem.AssignVariables ( string  runtimeVariablesData,
bool  fromOptions = false 
)
static

Unloads stored global variable data back into the RuntimeVariables script.

Parameters
runtimeVariablesDataThe values of all global variables, combined into a stingle string
fromOptionsIf true, only global variables that are linked to OptionsData will be affected

◆ ClearAllData()

void AC.SaveSystem.ClearAllData ( )

Clears all save data stored in the SaveData class.

◆ ContinueGame()

static void AC.SaveSystem.ContinueGame ( )
static

Loads the last-recorded save game file.

◆ CreateVariablesData()

static string AC.SaveSystem.CreateVariablesData ( List< GVar vars,
bool  isOptionsData,
VariableLocation  location 
)
static

Condenses the values of a List of variables into a single string.

Parameters
varsA List of variables (see GVar) to condense
isOptionsDataIf True, only global variables that are linked to OptionsData will be included
locationThe variables' location (Local, Variable)
Returns
The variable's values, condensed into a single string

◆ DeleteProfile()

void AC.SaveSystem.DeleteProfile ( int  profileIndex = -2,
bool  includeActive = true 
)

Deletes a player profile by referencing its entry in a MenuProfilesList element.

Parameters
profileIndexThe index in the MenuProfilesList element that represents the profile to delete. If it is set to its default, -2, the active profile will be deleted
includeActiveIf True, then the MenuProfilesList element that the profile was selected from also displays the active profile

◆ DeleteProfileID()

void AC.SaveSystem.DeleteProfileID ( int  profileID)

Deletes a player profile ID.

Parameters
profileIDThe profile ID to delete

◆ DeleteSave() [1/2]

static void AC.SaveSystem.DeleteSave ( int  saveID)
static

Deletes a save game file.

Parameters
saveIDThe save ID of the file to load

◆ DeleteSave() [2/2]

void AC.SaveSystem.DeleteSave ( int  elementSlot,
int  saveID,
bool  useSaveID 
)

Deletes a save game file.

Parameters
elementSlotThe slot index of the MenuProfilesList element that was clicked on
saveIDThe save ID to delete
useSaveIDIf True, the saveID overrides the elementSlot to determine which file to delete

◆ DoesImportExist()

static bool AC.SaveSystem.DoesImportExist ( int  saveID)
static

Checks if an import file with a particular ID number exists.

Parameters
saveIDThe import ID to check for
Returns
True if an import file with a matching ID number exists

◆ DoesPlayerDataExist()

bool AC.SaveSystem.DoesPlayerDataExist ( int  ID,
bool  doSceneCheck = false 
)

Checks if PlayerData for a given Player has been generated.

Parameters
IDThe ID number of the Player to check
doSceneCheckIf True, the check will only be successful if the Player is currently within a scene
Returns
True if PlayerData for the given Player exists

◆ DoesSaveExist() [1/2]

static bool AC.SaveSystem.DoesSaveExist ( int  elementSlot,
int  saveID,
bool  useSaveID 
)
static

Checks if a save file with a particular ID number exists

Parameters
elementSlotThe slot index of the MenuSavesList element
saveIDThe save ID to check for
useSaveIDIf True, the saveID overrides the elementSlot to determine which file to check for
Returns
True if a save file with a matching ID number exists

◆ DoesSaveExist() [2/2]

static bool AC.SaveSystem.DoesSaveExist ( int  saveID)
static

Checks if a save file with a particular ID number exists

Parameters
saveIDThe save ID to check for
Returns
True if a save file with a matching ID number exists

◆ DoImportCheck()

bool AC.SaveSystem.DoImportCheck ( string  fileData,
int  boolID 
)

Checks that another game's save file data is OK to import, by checking the state of a given boolean variable

Parameters
fileDataThe de-serialized data string from the file
boolIDThe ID number of the Boolean Global Variable that must be True in the fileData for the import check to pass
Returns
True if the other game's save file data is OK to import

◆ GatherImportFiles()

void AC.SaveSystem.GatherImportFiles ( string  projectName,
string  filePrefix,
int  boolID 
)

Searches the filesystem for all available import files, and stores them in foundImportFiles.

Parameters
projectNameThe project name of the game whose save files we're looking to import
filePrefixThe "save filename" of the game whose save files we're looking to import, as set in the Settings Manager
boolIDIf >= 0, the ID of the boolean Global Variable that must be True for the file to be considered valid for import

◆ GatherSaveFiles()

void AC.SaveSystem.GatherSaveFiles ( )

Searches the filesystem for all available save files, and stores them in foundSaveFiles.

◆ GenerateSaveSuffix()

string AC.SaveSystem.GenerateSaveSuffix ( int  saveID,
int  profileID = -1 
)

Creates a suffix for save filenames based on a given save slot and profile

Parameters
saveIDThe ID of the save slot
profileIDThe ID of the profile

<return>A save file suffix based on the slot and profile

◆ GetImportSlotLabel()

static string AC.SaveSystem.GetImportSlotLabel ( int  elementSlot,
int  saveID,
bool  useSaveID 
)
static

Gets the label of an import file.

Parameters
elementSlotThe slot index of the MenuProfilesList element that was clicked on
saveIDThe save ID to import
useSaveIDIf True, the saveID overrides the elementSlot to determine which file to import
Returns
The label of the import file.

◆ GetImportSlotScreenshot()

static Texture2D AC.SaveSystem.GetImportSlotScreenshot ( int  elementSlot,
int  saveID,
bool  useSaveID 
)
static

Gets the screenshot of an import file.

Parameters
elementSlotThe slot index of the MenuSavesList element that was clicked on
saveIDThe save ID to get the screenshot of
useSaveIDIf True, the saveID overrides the elementSlot to determine which file to look for
Returns
The import files's screenshots as a Texture2D. If the save file is not found, null is returned.

◆ GetItemsFromPlayer()

List<InvItem> AC.SaveSystem.GetItemsFromPlayer ( int  _playerID)

Returns a list of inventory items currently carried by a particular Player.

Parameters
_playerIDThe ID number of the Player to check the inventory of
Returns
A List of InvItem instances representing the inventory items

◆ GetNumImportSlots()

static int AC.SaveSystem.GetNumImportSlots ( )
static

Gets the number of found import files.

Returns
The number of found import files

◆ GetNumSaves()

int AC.SaveSystem.GetNumSaves ( bool  includeAutoSaves = true)

Gets the number of save game files found.

Parameters
includeAutoSavesIf True, then autosave files will be included in the result
Returns
The number of save games found

◆ GetNumSlots()

static int AC.SaveSystem.GetNumSlots ( )
static

Gets the number of found save files.

Returns
The number of found save files

◆ GetPlayerScene()

int AC.SaveSystem.GetPlayerScene ( int  ID)

Gets the current scene number that a Player is in.

Parameters
IDThe ID number of the Player to check
Returns
The current scene number that the Player is in. If the Player is not found, the currently-open scene number will be returned.

◆ GetPlayerSceneName()

string AC.SaveSystem.GetPlayerSceneName ( int  ID)

Gets the current scene nsmr that a Player is in.

Parameters
IDThe ID number of the Player to check
Returns
The current scene name that the Player is in. If the Player is not found, the currently-open scene name will be returned.

◆ GetSaveExtension()

string AC.SaveSystem.GetSaveExtension ( )

Gets the extension of the current save method.

Returns
The extension of the current save method

◆ GetSaveSlotLabel()

static string AC.SaveSystem.GetSaveSlotLabel ( int  elementSlot,
int  saveID,
bool  useSaveID 
)
static

Gets the label of a save file.

Parameters
elementSlotThe slot index of the MenuSavesList element that was clicked on
saveIDThe save ID to save
useSaveIDIf True, the saveID overrides the elementSlot to determine which file to save
Returns
The label of the save file. If the save file is not found, an empty string is returned.

◆ GetSaveSlotScreenshot()

static Texture2D AC.SaveSystem.GetSaveSlotScreenshot ( int  elementSlot,
int  saveID,
bool  useSaveID 
)
static

Gets the screenshot of a save file.

Parameters
elementSlotThe slot index of the MenuSavesList element that was clicked on
saveIDThe save ID to get the screenshot of
useSaveIDIf True, the saveID overrides the elementSlot to determine which file to look for

<return>The save files's screenshots as a Texture2D. If the save file is not found, null is returned.

◆ GetScreenshot()

Texture2D AC.SaveSystem.GetScreenshot ( int  elementSlot,
int  saveID,
bool  useSaveID,
SaveFile []  saveFiles 
)

Gets the screenshot of a save file.

Parameters
elementSlotThe slot index of the MenuSavesList element that was clicked on
saveIDThe save ID to get the screenshot of
useSaveIDIf True, the saveID overrides the elementSlot to determine which file to look for
saveFilesAn array of SaveFile instances that the save file to retrieve is assumed to be in
Returns
The save files's screenshots as a Texture2D. If the save file is not found, null is returned.

◆ GetSlotLabel()

string AC.SaveSystem.GetSlotLabel ( int  elementSlot,
int  saveID,
bool  useSaveID,
SaveFile []  saveFiles 
)

Gets the label of a save file.

Parameters
elementSlotThe slot index of the MenuSavesList element that was clicked on
saveIDThe save ID to save
useSaveIDIf True, the saveID overrides the elementSlot to determine which file to save
saveFilesAn array of SaveFile instances that the save file to retrieve is assumed to be in
Returns
The label of the save file. If the save file is not found, an empty string is returned.

◆ ImportGame()

static void AC.SaveSystem.ImportGame ( int  elementSlot,
int  saveID,
bool  useSaveID 
)
static

Imports a save file from another Adventure Creator game.

Parameters
elementSlotThe slot index of the MenuProfilesList element that was clicked on
saveIDThe save ID to import
useSaveIDIf True, the saveID overrides the elementSlot to determine which file to import

◆ LoadAutoSave()

static void AC.SaveSystem.LoadAutoSave ( )
static

Loads the AutoSave save file. If multiple save profiles are used, the current profiles AutoSave will be loaded.

◆ LoadGame() [1/2]

static void AC.SaveSystem.LoadGame ( int  saveID)
static

Loads a save game file.

Parameters
saveIDThe save ID of the file to load

◆ LoadGame() [2/2]

static void AC.SaveSystem.LoadGame ( int  elementSlot,
int  saveID,
bool  useSaveID 
)
static

Loads a save game file.

Parameters
elementSlotThe slot index of the MenuSavesList element that was clicked on
saveIDThe save ID to load
useSaveIDIf True, the saveID overrides the elementSlot to determine which file to load

◆ MoveInactivePlayerToCurrentScene()

void AC.SaveSystem.MoveInactivePlayerToCurrentScene ( int  ID,
Transform  newTransform,
_Camera  associatedCamera = null 
)

Updates the internal record of an inactive Player's position to the current scene, provided that player-switching is allowed. If that Player has an Associated NPC, then it will be spawned or teleported to the Player's new position

Parameters
IDThe ID number of the Player to affect, as set in the Settings Manager's list of Player prefabs
newTransformA Transform to use as the basis for the Player's new position and rotation
associatedCameraThe _Camera that should be active when the Player is next made active. This can be null, but the camera will need to be manually set after switching to this Player if so

◆ OnFinishSaveRequest()

void AC.SaveSystem.OnFinishSaveRequest ( SaveFile  saveFile,
bool  wasSuccesful 
)

Handles the what happens once a save file has been written

Parameters
saveFileA data container for information about the save file to that was loaded. Its saveID and profileID need to match up with that requested in the iSaveFileHandler's Save function in order for the data to be processed
wasSuccesfulTrue if the file saving was succesful

◆ ReceiveDataToImport()

void AC.SaveSystem.ReceiveDataToImport ( SaveFile  saveFile,
string  saveFileContents 
)

Processes the save data requested by ImportSaveGame

Parameters
saveFileA data container for information about the save file to import. Its saveID and profileID need to match up with that requested in the iSaveFileHandler's Import function in order for the data to be processed
saveFileContentsThe file contents of the save file. This is empty if the import failed.

◆ ReceiveDataToLoad()

void AC.SaveSystem.ReceiveDataToLoad ( SaveFile  saveFile,
string  saveFileContents 
)

Processes the save data requested by LoadSaveGame

Parameters
saveFileA data container for information about the save file to load. Its saveID and profileID need to match up with that requested in the iSaveFileHandler's Load function in order for the data to be processed
saveFileContentsThe file contents of the save file. This is empty if the load failed.

◆ RenameSave()

void AC.SaveSystem.RenameSave ( string  newLabel,
int  saveIndex 
)

Renames the label of a save game file.

Parameters
newLabelThe new label to give the save game file
saveIndexThe index of the foundSaveFiles List that represents the save file to affect

◆ SaveGame() [1/2]

static void AC.SaveSystem.SaveGame ( int  saveID,
bool  overwriteLabel = true,
string  newLabel = "" 
)
static

Saves the game.

Parameters
saveIDThe save ID to save
overwriteLabelTrue if the label should be updated
newLabelThe new label, if it can be set. If blank, a default label will be generated.

◆ SaveGame() [2/2]

static void AC.SaveSystem.SaveGame ( int  elementSlot,
int  saveID,
bool  useSaveID,
bool  overwriteLabel = true,
string  newLabel = "" 
)
static

Saves the game.

Parameters
elementSlotThe slot index of the MenuSavesList element that was clicked on
saveIDThe save ID to save
useSaveIDIf True, the saveID overrides the elementSlot to determine which file to save
overwriteLabelTrue if the label should be updated
newLabelThe new label, if it can be set. If blank, a default label will be generated.

◆ SaveNewGame()

static void AC.SaveSystem.SaveNewGame ( bool  overwriteLabel = true,
string  newLabel = "" 
)
static

Create a new save game file.

Parameters
overwriteLabelTrue if the label should be updated
newLabelThe new label, if it can be set

◆ SetGameplayReturnTime()

void AC.SaveSystem.SetGameplayReturnTime ( float  _gameplayInvokeTime)

Sets the delay after loading a saved game before gameplay is resumed. This is useful in games with custom systems, e.g. weapons, where we want to prevent firing being possible immediately after loading.

<param name = "The new delay time, in seconds

◆ SetSelectiveLoadOptions()

void AC.SaveSystem.SetSelectiveLoadOptions ( SelectiveLoad  selectiveLoad)

Sets the local instance of SelectiveLoad, which determines which save data is restored the next time (and only the next time) LoadGame is called.

Parameters
selectiveLoadAn instance of SelectiveLoad the defines what elements to load

Member Data Documentation

◆ foundImportFiles

List<SaveFile> AC.SaveSystem.foundImportFiles = new List<SaveFile>()

A List of SaveFile variables, storing all available import files.

◆ foundSaveFiles

List<SaveFile> AC.SaveSystem.foundSaveFiles = new List<SaveFile>()

An List of SaveFile variables, storing all available save files.

◆ loadingGame

LoadingGame AC.SaveSystem.loadingGame

What type of load is being performed (No, InNewScene, InSameScene, JustSwitchingPlayer)

Property Documentation

◆ FileFormatHandler

iFileFormatHandler AC.SaveSystem.FileFormatHandler
staticgetset

The iFileFormatHandler class that handles the serialization and deserialzation of data

◆ IsTakingSaveScreenshot

bool AC.SaveSystem.IsTakingSaveScreenshot
get

If True, then a save-game screenshot is being taken

◆ SaveFileHandler

iSaveFileHandler AC.SaveSystem.SaveFileHandler
staticgetset

The iSaveFileHandler class that handles the creation, loading, and deletion of save files