/// <summary> /// Serializes the data /// </summary> /// <param name="s">The serializer object</param> public override void SerializeImpl(SerializerObject s) { // Serialize the header base.SerializeImpl(s); // Serialize the pointers bool allowInvalid = s.GameSettings.EngineVersion == EngineVersion.R1_PocketPC || s.GameSettings.GameModeSelection == GameModeSelection.RaymanClassicMobile; EventBlockPointer = s.SerializePointer(EventBlockPointer, allowInvalid: allowInvalid, name: nameof(EventBlockPointer)); TextureBlockPointer = s.SerializePointer(TextureBlockPointer, allowInvalid: allowInvalid, name: nameof(TextureBlockPointer)); // Serialize the level defines if (s.GameSettings.EngineVersion == EngineVersion.R1_PC_Kit || s.GameSettings.EngineVersion == EngineVersion.R1_PC_Edu) { KitLevelDefines = s.SerializeObject <R1_PC_KitLevelDefinesBlock>(KitLevelDefines, name: nameof(KitLevelDefines)); } // Serialize the map data MapData = s.SerializeObject <R1_PC_MapBlock>(MapData, name: nameof(MapData)); // Serialize the background data if (s.GameSettings.EngineVersion == EngineVersion.R1_PC || s.GameSettings.EngineVersion == EngineVersion.R1_PocketPC) { // Serialize the background data BackgroundIndex = s.Serialize <byte>(BackgroundIndex, name: nameof(BackgroundIndex)); ParallaxBackgroundIndex = s.Serialize <byte>(ParallaxBackgroundIndex, name: nameof(ParallaxBackgroundIndex)); BackgroundSpritesDES = s.Serialize <int>(BackgroundSpritesDES, name: nameof(BackgroundSpritesDES)); } // Serialize the rough tile textures if (s.GameSettings.EngineVersion == EngineVersion.R1_PC) { RoughTileTextureData = s.SerializeObject <R1_PC_RoughTileTextureBlock>(RoughTileTextureData, name: nameof(RoughTileTextureData)); } else { LeftoverRoughTextureBlock = s.SerializeArray <byte>(LeftoverRoughTextureBlock, TextureBlockPointer.FileOffset - s.CurrentPointer.FileOffset, name: nameof(LeftoverRoughTextureBlock)); } // At this point the stream position should match the texture block offset if (s.CurrentPointer != TextureBlockPointer) { Debug.LogError("Texture block offset is incorrect"); } // Serialize the tile textures TileTextureData = s.SerializeObject <R1_PC_TileTextureBlock>(TileTextureData, name: nameof(TileTextureData)); // At this point the stream position should match the event block offset (ignore the Pocket PC version here since it uses leftover pointers from PC version) if (s.GameSettings.EngineVersion != EngineVersion.R1_PocketPC && s.CurrentPointer != EventBlockPointer) { Debug.LogError("Event block offset is incorrect"); } // Serialize the event data EventData = s.SerializeObject <R1_PC_EventBlock>(EventData, name: nameof(EventData)); // Serialize the profile define data (only on By his Fans and 60 Levels) if (s.GameSettings.GameModeSelection == GameModeSelection.RaymanByHisFansPC || s.GameSettings.GameModeSelection == GameModeSelection.Rayman60LevelsPC) { ProfileDefine = s.SerializeObject <R1_PC_ProfileDefine>(ProfileDefine, name: nameof(ProfileDefine)); } // Serialize alpha data (only on EDU) if (s.GameSettings.EngineVersion == EngineVersion.R1_PC_Edu) { EDU_AlphaChecksum = s.DoChecksum(new Checksum8Calculator(false), () => { if (EDU_Alpha == null) { EDU_Alpha = new byte[480][]; } for (int i = 0; i < EDU_Alpha.Length; i++) { EDU_Alpha[i] = s.SerializeArray <byte>(EDU_Alpha[i], 256, name: $"{nameof(EDU_Alpha)}[{i}]"); } }, ChecksumPlacement.Before, name: nameof(EDU_AlphaChecksum)); } }