You may implement these in your ScriptObject
class to save/load additional data.
void Load(Deserializer&);
void Save(Serializer&);
void ReadNetworkUpdate(Deserializer&);
void WriteNetworkUpdate(Serializer&);
Otherwise you basically just write a function to save your things to Serializer
and read them from Deserializer
and use those functions in your Load/Save implementations
ie:
// reusable function to write an array of DamageInfo to serializer
void SaveDamageInfo(Array<DamageInfo> infos, Serializer&in dest)
{
dest.WriteUInt(infos.length);
for (uint i = 0; i < infos.length; ++i)
{
dest.WriteUInt(infos[i].damageKind);
dest.WriteFloat(infos[i].damageModifier);
}
}
// reusable function to read said info from a deserializer
Array<DamageInfo> LoadDamageInfo(Deserializer& src)
{
Array<DamageInfo> retList;
uint ct = src.ReadUInt();
for (uint i = 0; i < ct; ++i)
{
DamageInfo info;
info.damageKind = src.ReadUInt();
info.damageModifier = src.ReadFloat();
retList.Push(info);
}
return retList;
}
// ScriptObject interface implementation
class MyGameObject : ScriptObject
{
Array<DamageInfo> myDamageInfo;
// called when our ScriptInstance is read from a file
void Load(Deserializer& src) { myDamageInfo = LoadDamageInfo(src); }
// called when our ScriptInstance is written to a file
void Save(Serializer& dest) { SaveDamageInfo(myDamageInfo, dest); }
}
Does that make sense?