Hi there! You are currently browsing as a guest. Why not create an account? Then you get less ads, can thank creators, post feedback, keep a list of your favourites, and more!
Field Researcher
Original Poster
#1 Old 4th Mar 2010 at 2:32 AM
Default How do you safely create new property keys for object serialization?
I've finally gotten into creating new scripting classes for cloned objects, but I have one question I didn't see covered in the tutorials. My new object classes have some properties that need to be saved when the game is saved, and I see how this is done by overriding the ExportContent and ImportContent methods. What I am unsure of is how do you create new keys safely for your new properties? It looks to me like the EA ones are sequential, so I'm nervous about how to pick it. Do these keys need to be unique across all objects, or just ones your class inherits from?
Advertisement
Field Researcher
Original Poster
#2 Old 12th Mar 2010 at 6:30 PM
I've learned a bit since my last post, so I thought I'd update this thread. Previously I thought that the ImportContent and ExportContent methods were used to serialize during game saves and loads, but I no longer think this is the case. That's because some of my objects maintain their properties across saves even when I haven't encorporated them into these methods. So... I don't know what they are for... does anyone else know? Perhaps for when you package lots? Here's an example, for the incense holders. In this case it seems to be adding the ability to serialize whether the incense holder is lit or not: [pre2] public override bool ExportContent(ResKeyTable resKeyTable, ObjectIdTable objIdTable, IPropertyStreamWriter writer) { if (!base.ExportContent(resKeyTable, objIdTable, writer)) { return false; } writer.WriteBool(0x8b76421, this.mIsLit); return true; } public override bool ImportContent(ResKeyTable resKeyTable, ObjectIdTable objIdTable, IPropertyStreamReader reader) { if (!base.ImportContent(resKeyTable, objIdTable, reader)) { return false; } reader.ReadBool(0x8b76421, out this.mIsLit, false); this.UpdateVisualState(); this.UpdateBroadcaster(); return true; } [/pre2]
Top Secret Researcher
#3 Old 12th Mar 2010 at 8:20 PM
Quote: Originally posted by dolphin26
So... I don't know what they are for... does anyone else know? Perhaps for when you package lots?


Correct, they are used when exporting to the Bin... Either when exporting sims, households, or lots.

The functions are also used during the town-transition system, when switching between towns for vacation traveling purposes.

----

Serialization into the save-game itself is via .NET Reflection, and does not rely on those functions.

Cheers.

NRaas Industries: Sims 3 Mods for the Discerning Player, hosted by The Wikispaces.
Field Researcher
Original Poster
#4 Old 12th Mar 2010 at 9:29 PM
Quote: Originally posted by twallan
Correct, they are used when exporting to the Bin... Either when exporting sims, households, or lots.

The functions are also used during the town-transition system, when switching between towns for vacation traveling purposes.

----

Serialization into the save-game itself is via .NET Reflection, and does not rely on those functions.

Cheers.


Ah, the town transition system makes this vital for anything stored in the users inventory, thanks for bringing that up!

Twallan, do you know how to safely generate the key values? Do they just need to be unique for a given object class? So... do I need to go through my parent classes looking for them, and just pick something else... or is there a better way?
Back to top