Save System
Warning!
As of e1.0.10/e1.1.0 when defining custom data that inherits the game's basic types, be extra careful.
If the data will be saved to the game's internal storage, upon removing your mod the save won't be able to load because of your missing custom data.
This will be the case when definining custom LogEntry
types and passing them to the game (LogEntry.AddLogEntry(customLog);
.
As a workaround, you should either include a feature to fully remove your custom data from the game or provide a mod for it.
SaveableTypeDefiner
For defining custom classes and structs, implement your own TaleWorlds.SaveSystem.SaveableTypeDefiner
.
You don't need to register it somewhere, the game will find it itself via reflection.
SaveableField and SaveableProperty
To mark data in your custom class/struct as savable, use TaleWorlds.SaveSystem.SaveableFieldAttribute
and TaleWorlds.SaveSystem.SaveablePropertyAttribute
.
It seems that there is noreal difference between SaveableField
and SaveableProperty
, but if you used one of them, stick to the type. They are not interchangeable and the data won't be loaded if types awe swicthed.
CampaignBehaviorBase.SyncData
There is also "shared data" that could be used between one/miltiple CampaignBehaviorBase
.
With it you can store custom container data, such as:
Array
List
Dictionary
Queue
Notes:
The community should decide how to handle saveBaseId
collisions.
Last updated