public void Deserialize(SafeReader reader) { var recordVersion = reader.ReadInt32(); if (recordVersion > CurrentVersion) { throw new Exception($"Version {recordVersion} is not supported, last is {CurrentVersion}"); } var summaryData = reader.ReadBytes(); using (var memoryStream = new MemoryStream(summaryData, false)) { using (var r = new SafeReader(memoryStream, reader.CompatibleBinaryReader)) { Import(r, recordVersion); } } }
private void Import(SafeReader r, int recordVersion) { if (recordVersion >= 201812210) { DLCRequire = r.ReadIntList(); } PlayerIdentity = new SummaryPlayerIdentity( new Guid(r.ReadBytes()), new DateTime(r.ReadInt64())); PlayerName = r.ReadNullableString(); PlayerGender = recordVersion >= 201711280 ? (Gender)r.ReadInt32() : Gender.Male; PlayerLevel = r.ReadInt32(); PlayerMoney = r.ReadInt32(); if (recordVersion < 201711281) { WorkshopNameSet = false; WorkshopName = r.ReadString(); } else { WorkshopNameSet = r.ReadBoolean(); WorkshopName = r.ReadNullableString(); } if (recordVersion >= 201801150) { int length1 = r.ReadInt32(); appearUnitsEquipPaths = new string[length1]; for (int index = 0; index < length1; ++index) { appearUnitsEquipPaths[index] = recordVersion < 201810100 ? r.ReadString() : r.ReadNullableString(); } if (recordVersion >= 201810100) { int length2 = r.ReadInt32(); appearUnitsNudePaths = new string[length2]; for (int index = 0; index < length2; ++index) { appearUnitsNudePaths[index] = r.ReadNullableString(); } if (recordVersion >= 201812250) { for (int index = 0; index < 6; ++index) { SubModelIds[index] = r.ReadInt32(); } } else { for (int index = 0; index < 3; ++index) { SubModelIds[index] = -1; SubModelIds[index + 3] = r.ReadInt32(); } } } else { for (int index = 0; index < 3; ++index) { SubModelIds[index] = -1; } } appearData = new AppearData(); appearData.Deserialize(r); if (recordVersion >= 201812100) { Tattoo = r.ReadNullableString(); } } else { appearUnitsEquipPaths = null; appearData = null; } WorkshopLevel = r.ReadString(); GameTime = r.ReadInt64(); SystemTime = new DateTime(r.ReadInt64()); PlayedTime = new TimeSpan(r.ReadInt64()); if (recordVersion >= 201901040) { IsMainStoryDone = r.ReadBool(); } byte[] data = r.ReadBytes(); figurePreviewData = data == null || data.Length == 0 ? (FigurePreviewData)null : new FigurePreviewData(data); r.ReadBytes(); }