Changes

Jump to navigation Jump to search
Line 105: Line 105:  
When you want to save data, override and populate the WriteDictionary with values in the '''Serialize(WriteDictionary data, GameReader.LoadMode mode)''' method, this will then be returned when a save is loaded in the '''Deserialize(WriteDictionary data, GameReader.LoadMode mode)''' method. If you wanted to save a setting you can write '''data["Notifications"] = true''' and load it back with '''Notifications = data.Get("Notifications", true)'''
 
When you want to save data, override and populate the WriteDictionary with values in the '''Serialize(WriteDictionary data, GameReader.LoadMode mode)''' method, this will then be returned when a save is loaded in the '''Deserialize(WriteDictionary data, GameReader.LoadMode mode)''' method. If you wanted to save a setting you can write '''data["Notifications"] = true''' and load it back with '''Notifications = data.Get("Notifications", true)'''
   −
There is also a '''LoadMode''' parameter, which tells you whether it was a full save, a build mode save or a company save (Usually used when the player is moving to another map or during multiplayer synchronization), which will allow you to only save data needed for each type. E.g. you probably don't have to save player preferences for a build mode save.
+
There is also a '''LoadMode''' parameter, which tells you whether it was a full save, a build mode save or a company save (Usually used when the player is moving to another map or during multiplayer synchronization), which will allow you to only save data needed for each type. In most cases it's best to avoid saving anything for a build mode save.
    
You can also override the serialization methods in the ModMeta class to take complete control of saving data. Returning null will make the mod not save any data. To help you with serializing data from your ModBehaviours, the ModMeta class has a '''ModBehaviours''' list of all active ModBehaviours that were creating when the mod was first loaded. However, the default behaviour is to call Serialize and Deserialize on your ModBehaviours in turn and check if they saved any data, so just leaving it as is will work in most cases.
 
You can also override the serialization methods in the ModMeta class to take complete control of saving data. Returning null will make the mod not save any data. To help you with serializing data from your ModBehaviours, the ModMeta class has a '''ModBehaviours''' list of all active ModBehaviours that were creating when the mod was first loaded. However, the default behaviour is to call Serialize and Deserialize on your ModBehaviours in turn and check if they saved any data, so just leaving it as is will work in most cases.

Navigation menu