Modding:Serialization (Saving/Loading): Difference between revisions

m
Note that this does not apply to lists of intrinsic types (strings, ints, etc)
imported>CaptainTechnicality54384
(Created page with "Category:Modding == What is Serialization? == Serialization is how games and other programs convert data into a file format, so that it can be stored between sessions. In...")
 
m (Note that this does not apply to lists of intrinsic types (strings, ints, etc))
Line 10: Line 10:
By default, Qud handles serialization of game objects by itself, so there's nothing you need to do to make it work. However, Qud's default serialization is not sufficient for certain classes, in those cases, you need to tell the game to let you serialize a field yourself. By putting the attribute <nowiki>[NonSerialized]</nowiki> above a field, it tells the game not to save that field. You can then add your own save behavior by overriding the save function.
By default, Qud handles serialization of game objects by itself, so there's nothing you need to do to make it work. However, Qud's default serialization is not sufficient for certain classes, in those cases, you need to tell the game to let you serialize a field yourself. By putting the attribute <nowiki>[NonSerialized]</nowiki> above a field, it tells the game not to save that field. You can then add your own save behavior by overriding the save function.


A common use for this is serializing lists, because Qud's serialization does not correctly handle lists, below is an example segment of code that shows how to serialize your lists.
A common use for this is serializing lists of objects, because Qud's serialization does not correctly handle object lists (lists of intrinsic types such as string or int usually do not require serialization).
 
Below is an example segment of code that shows how to serialize your lists.
<syntaxhighlight lang="csharp">
<syntaxhighlight lang="csharp">
...
...