一.存档
通过将游戏中Party状态,坐标等字段进行序列化后保存至sav文件,即游戏存档。
存档文件.sav文件:
C:\Users\taohu\Documents\Mount and Blade II Bannerlord\Game Saves\save001.sav
二.声明需要存储的信息
<1.声明存储对象对应的类:
实现SaveableTypeDefiner中DefineClassTypes方法,添加对应的类名,例如需要将Student学生类进行序列化并存储:
public class MySaveContextTypeDefiner : SaveableTypeDefiner
{
public MySaveContextTypeDefiner() : base(980000)
{
}
protected override void DefineClassTypes()
{
AddClassDefinition(typeof(Student), 1, null);
}
}
<2.声明存储对象对应的字段:
在类上添加SaveableProperty注解,声明字段的saveID,例如要将学生Student的年龄Age和身高Height进行存储。