Interface IPerPluginSavedState
- Namespace
- SkyrimForge
- Assembly
- SkyrimForge.dll
A plugin's state between sessions, stored in the SKSE co-save beside the player's save file rather than in a file of the plugin's own.
public interface IPerPluginSavedState : ISavedStateEntries
- Inherited Members
- Extension Methods
Remarks
The co-save follows its save wherever it goes: copied, renamed, or loaded on another character. It is written and read without any call from the plugin. Entries are per plugin, so two plugins using one key do not collide. Members can be called on any thread. The store is emptied when a new game starts or a save starts loading, and it has the loaded save's entries from OnSaveLoaded onward. Each member is atomic, and a read followed by a write is two calls, so a plugin writing a value derived from one it read, from handlers on more than one thread, acquires a lock of its own around both. A key that starts with "SkyrimForge." belongs to the framework, whose services store their state in this plugin's store and in each form's entries. GetStringKeys() and GetFormIdKeys() return those keys beside the plugin's own.
Methods
GetFormEntries(FormId<Form>)
Gives the part of this plugin's store belonging to one form, where state about a particular object goes.
ISavedStateEntries GetFormEntries(FormId<Form> formId)
Parameters
Returns
Remarks
The framework groups these entries under the form and maps it through the load order the save recorded, for the reason SetFormId(string, FormId<Form>?) gives, so a key built from the form's number is never needed. Entries under a form whose .esm, .esp, or .esl file is no longer loaded are dropped as the save is read.
ReadStringsFromSave(string)
Reads the text this plugin stored in a save, from that save's co-save file, without loading the save. It returns text alone because a stored form ID names a form only once SKSE has mapped it through the save's load order, which it does only as it reads the save.
IReadOnlyDictionary<string, string> ReadStringsFromSave(string saveFileName)
Parameters
saveFileNamestringThe save's file name, as FileName reports it, with or without the .ess extension.
Returns
- IReadOnlyDictionary<string, string>
Each key and its text as SetString(string, string?) stored them when the save was written, or empty where the save has no co-save or this plugin stored no text in it.
Remarks
Called during OnSaveLoading, this returns the save's text before the game reads the save. It reads only the text stored directly in this store. A form ID written into that text is the number the save recorded, unmapped.
Exceptions
- ArgumentNullException
saveFileNameisnull.- InvalidDataException
The co-save is not one SKSE wrote, or the framework's record in it does not decode at the version this build reads.
- IOException
The co-save file exists and could not be read.