-
Notifications
You must be signed in to change notification settings - Fork 0
Save Data Overview
The Sub Library has a robust save data system capable of supporting multiple save data variations across different prefabs in game, as well as saving arbitrary data.
Using this system will likely simplify your mod, and reduce the work you have to do to get persistent subs that players will enjoy.
In essence, there are 3 main parts to the save system:
- The Sub Serialization Manager
- The Data Class
- The Save Data Interfaces
This component goes on your sub prefab root and manages issuing the save data events to any save event listeners that are children of the root. The save data is dispatched based on PrefabIdentifier
id, so no 2 subs will use the same data. This process is automatic and requires no modder input.
These can take any form, but must inherit from SubLibrary.SaveData.BaseSubDataClass
. An example is given that holds some data for installed modules here.
These allow your scripts to access and modify the Sub's save data at key events such as after the scene has been loaded, or before it's about to save. There are also special events, such as one that only triggers after the game has deserialized all objects in the scene (ILateSaveDataListener). This means that objects such as a power cell in your power storage will actually be there, which would not be the case if you used the normal ISaveDataListener