Save States
Working with save states.
Active Save State
It's important to understand what the active save state is before continuing. The active save state acts as a temporary copy that updates as the player progresses through the game. Instead of modifying the original save file directly, all changes are made to this active copy. The original save remains unchanged unless the player explicitly chooses to save, ensuring that it can be reloaded in its unedited state if needed.
Creating New Saves
New save states require a unique integer ID. That's all you really needβbut even that isn't necessary to manage yourself. Save state IDs are auto-incremented to ensure they are all unique. However, you can still create a save state with a specific ID.
Use the ESave.CreateSave
method to create a new save. If an ID parameter is not passed, the ID will be automatically generated.
This method returns a Save Operation (result type: SaveState
).
To create a new save state with a specific ID, simply pass it as a parameter. In the code below, a new save with the ID 0 will be created if an existing one with the ID doesn't exist. If there is another save with the same ID, the existing save will be returned instead.
Checking Existing Saves
Use the HasSave
method to simply check if a save with a specific ID exists.
Getting Save States
Active
You can get the active save state with the SaveState.active
field.
By ID
You can get a save state with the ESave.GetSaveState
method.
Getting All Save States
To get a list of all save states, use ESave.GetAllSaveStates
.
This method returns a Save Operation (result type: List<SaveState>
).
Loading Save States
You can load a save state by passing its ID in the ESave.Load
method. This will set the loaded save state as active.
This method returns a Save Operation (result type: SaveState
).
Saving Save States
To save all data of the active save state (the temporary copy) into the original save state, call ESave.Save
.
If an int
(save state ID) or SaveState
parameter is passed, the active save state will instead store its data into the save state of your choice. Either way, the targeted save state's data is completely overwritten by the active save state data.
This method returns a Save Operation (result type: SaveState
).
Last updated