FogEffectSerializer.cs 1.1 KB

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