PropInfoSerializer.cs 1.0 KB

123456789101112131415161718192021222324252627282930313233
  1. using System.IO;
  2. namespace COM3D2.MeidoPhotoStudio.Plugin
  3. {
  4. public class PropInfoSerializer : SimpleSerializer<PropInfo>
  5. {
  6. private const short version = 1;
  7. public override void Serialize(PropInfo info, BinaryWriter writer)
  8. {
  9. writer.WriteVersion(version);
  10. writer.Write((int) info.Type);
  11. writer.WriteNullableString(info.Filename);
  12. writer.WriteNullableString(info.SubFilename);
  13. writer.Write(info.MyRoomID);
  14. writer.WriteNullableString(info.IconFile);
  15. }
  16. public override PropInfo Deserialize(BinaryReader reader, SceneMetadata metadata)
  17. {
  18. _ = reader.ReadVersion();
  19. return new PropInfo ((PropInfo.PropType) reader.ReadInt32())
  20. {
  21. Filename = reader.ReadNullableString(),
  22. SubFilename = reader.ReadNullableString(),
  23. MyRoomID = reader.ReadInt32(),
  24. IconFile = reader.ReadNullableString()
  25. };
  26. }
  27. }
  28. }