DepthOfFieldEffectSerializer.cs 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. using System.IO;
  2. namespace COM3D2.MeidoPhotoStudio.Plugin
  3. {
  4. public class DepthOfFieldEffectSerializer : Serializer<DepthOfFieldEffectManager>
  5. {
  6. private const short version = 1;
  7. public override void Serialize(DepthOfFieldEffectManager effect, BinaryWriter writer)
  8. {
  9. writer.Write(DepthOfFieldEffectManager.header);
  10. writer.WriteVersion(version);
  11. writer.Write(effect.Active);
  12. writer.Write(effect.FocalLength);
  13. writer.Write(effect.FocalSize);
  14. writer.Write(effect.Aperture);
  15. writer.Write(effect.MaxBlurSize);
  16. writer.Write(effect.VisualizeFocus);
  17. }
  18. public override void Deserialize(DepthOfFieldEffectManager effect, BinaryReader reader, SceneMetadata metadata)
  19. {
  20. _ = reader.ReadVersion();
  21. var active = reader.ReadBoolean();
  22. effect.FocalLength = reader.ReadSingle();
  23. effect.FocalSize = reader.ReadSingle();
  24. effect.Aperture = reader.ReadSingle();
  25. effect.MaxBlurSize = reader.ReadSingle();
  26. effect.VisualizeFocus = reader.ReadBoolean();
  27. effect.SetEffectActive(active);
  28. }
  29. }
  30. }