public override void SerializeImpl(SerializerObject s) { s.SerializeBitValues <uint>((bitFunc) => { TileOffset = bitFunc(TileOffset, 24, name: nameof(TileOffset)); ExtraBytes = bitFunc(ExtraBytes, 8, name: nameof(ExtraBytes)); }); }
public override void SerializeImpl(SerializerObject s) { s.SerializeBitValues <short>(bitFunc => { InstanceIndex = (short)bitFunc(InstanceIndex, 11, name: nameof(InstanceIndex)); Count = bitFunc(Count, 5, name: nameof(Count)); }); }
public override void SerializeImpl(SerializerObject s) { s.SerializeBitValues <short>(bitFunc => { TrackObjectIndex = (short)bitFunc(TrackObjectIndex, 11, name: nameof(TrackObjectIndex)); Int0 = bitFunc(Int0, 5, name: nameof(Int0)); //Int1 = bitFunc(Int1, 3, name: nameof(Int1)); //Int2 = bitFunc(Int2, 1, name: nameof(Int2)); }); }
public override void SerializeImpl(SerializerObject s) { s.SerializeBitValues <byte>(bitFunc => { YDelta = (byte)bitFunc(YDelta, 3, name: nameof(YDelta)); XDelta = (byte)bitFunc(XDelta, 3, name: nameof(XDelta)); YDeltaSign = bitFunc(YDeltaSign ? 1 : 0, 1, name: nameof(YDeltaSign)) == 1; XDeltaSign = bitFunc(XDeltaSign ? 1 : 0, 1, name: nameof(XDeltaSign)) == 1; }); }
public override void SerializeImpl(SerializerObject s) { s.SerializeBitValues <ushort>(bitFunc => { TileIndex = (ushort)bitFunc(TileIndex, 10, name: nameof(TileIndex)); IsFlippedHorizontally = bitFunc(IsFlippedHorizontally ? 1 : 0, 1, name: nameof(IsFlippedHorizontally)) == 1; IsFlippedVertically = bitFunc(IsFlippedVertically ? 1 : 0, 1, name: nameof(IsFlippedHorizontally)) == 1; PaletteIndex = (byte)bitFunc(PaletteIndex, 4, name: nameof(PaletteIndex)); }); }
public override void SerializeImpl(SerializerObject s) { if (s.GameSettings.EngineVersion == EngineVersion.GBAIsometric_RHR) { Height = s.Serialize <byte>(Height, name: nameof(Height)); s.SerializeBitValues <byte>(serializeFunc => { Type = (CollisionType_RHR)serializeFunc((int)Type, 4, name: nameof(Type)); AddType = (AdditionalTypeFlags_RHR)serializeFunc((int)AddType, 4, name: nameof(AddType)); }); s.SerializeBitValues <ushort>(serializeFunc => { Layer1 = (byte)serializeFunc(Layer1, 4, name: nameof(Layer1)); Layer2 = (byte)serializeFunc(Layer2, 4, name: nameof(Layer2)); Layer3 = (byte)serializeFunc(Layer3, 4, name: nameof(Layer3)); Shape = (ShapeType_RHR)serializeFunc((int)Shape, 4, name: nameof(Shape)); }); } else if (s.GameSettings.EngineVersion == EngineVersion.GBAIsometric_Spyro3 || s.GameSettings.EngineVersion == EngineVersion.GBAIsometric_Spyro2 || s.GameSettings.EngineVersion == EngineVersion.GBAIsometric_Tron2) { if (s.GameSettings.EngineVersion == EngineVersion.GBAIsometric_Spyro2) { s.SerializeBitValues <byte>(bitFunc => { Height = (byte)bitFunc(Height, 6, name: nameof(Height)); HeightFlags = (byte)bitFunc(HeightFlags, 2, nameof(HeightFlags)); }); } else { Height = s.Serialize <byte>(Height, name: nameof(Height)); } Depth = s.Serialize <byte>(Depth, name: nameof(Depth)); s.SerializeBitValues <byte>(serializeFunc => { Shape_Spyro = (ShapeType_Spyro)serializeFunc((int)Shape_Spyro, 4, name: nameof(Shape_Spyro)); Unk_Spyro = (byte)serializeFunc(Unk_Spyro, 4, name: nameof(Unk_Spyro)); // Could be part of shape, or just padding }); s.SerializeBitValues <byte>(serializeFunc => { Type_Spyro = (CollisionType_Spyro)serializeFunc((int)Type_Spyro, 4, name: nameof(Type_Spyro)); AddType_Spyro = (AdditionalTypeFlags_Spyro)serializeFunc((int)AddType_Spyro, 4, name: nameof(AddType_Spyro)); }); } else { Data = s.SerializeArray <byte>(Data, 4, name: nameof(Data)); } }
public override void SerializeImpl(SerializerObject s) { s.SerializeBitValues <byte>(bitFunc => { PalIndex = (byte)bitFunc(PalIndex, 3, name: nameof(PalIndex)); TransparentColorIndex = (byte)bitFunc(TransparentColorIndex, 2, name: nameof(TransparentColorIndex)); HorizontalFlip = bitFunc(HorizontalFlip ? 1 : 0, 1, name: nameof(HorizontalFlip)) == 1; VerticalFlip = bitFunc(VerticalFlip ? 1 : 0, 1, name: nameof(VerticalFlip)) == 1; Unknown2 = bitFunc(Unknown2 ? 1 : 0, 1, name: nameof(Unknown2)) == 1; }); }
public override void SerializeImpl(SerializerObject s) { Count = s.Serialize <byte>(Count, name: nameof(Count)); s.SerializeBitValues <ushort>(bitFunc => { UShort1 = (ushort)bitFunc(UShort1, 7, name: nameof(UShort1)); UShort2 = (ushort)bitFunc(UShort2, 7, name: nameof(UShort2)); UShort3 = (ushort)bitFunc(UShort3, 2, name: nameof(UShort3)); }); Entries = s.SerializeObjectArray <Entry>(Entries, Count, name: nameof(Entries)); }
public override void SerializeImpl(SerializerObject s) { TileIndex = s.Serialize <ushort>(TileIndex, name: nameof(TileIndex)); Width = s.Serialize <byte>(Width, name: nameof(Width)); Height = s.Serialize <byte>(Height, name: nameof(Height)); s.SerializeBitValues <byte>(bitFunc => { UnkFlags = (byte)bitFunc(UnkFlags, 7, name: nameof(UnkFlags)); HasPatterns = bitFunc(HasPatterns ? 1 : 0, 1, name: nameof(HasPatterns)) == 1; }); NumPatterns = s.Serialize <byte>(NumPatterns, name: nameof(NumPatterns)); if (HasPatterns) { PatternsOffset = s.Serialize <ushort>(PatternsOffset, name: nameof(PatternsOffset)); } else { s.SerializeBitValues <ushort>(bitFunc => { SpriteSize = (byte)bitFunc(SpriteSize, 2, name: nameof(SpriteSize)); SpriteShape = (GBAIsometric_Spyro_AnimPattern.Shape)bitFunc((int)SpriteShape, 2, name: nameof(SpriteShape)); PalIndex = (byte)bitFunc(PalIndex, 4, name: nameof(PalIndex)); UnkPatternValue = (byte)bitFunc(UnkPatternValue, 8, name: nameof(UnkPatternValue)); }); } if (s.GameSettings.EngineVersion >= EngineVersion.GBAIsometric_Spyro3) { NumTiles = s.Serialize <byte>(NumTiles, name: nameof(NumTiles)); Bytes_09 = s.SerializeArray <byte>(Bytes_09, 7, name: nameof(Bytes_09)); } if (HasPatterns) { s.DoAt(Offset + 4 * PatternsOffset, () => { Patterns = s.SerializeObjectArray <GBAIsometric_Spyro_AnimPattern>(Patterns, NumPatterns, name: nameof(Patterns)); }); } }
/// <summary> /// Handles the data serialization /// </summary> /// <param name="s">The serializer object</param> public override void SerializeImpl(SerializerObject s) { if (s.GameSettings.GameModeSelection == GameModeSelection.MapperPC || s.GameSettings.EngineVersion == EngineVersion.R1_GBA || s.GameSettings.EngineVersion == EngineVersion.R1_DSi) { TileMapY = s.Serialize <ushort>(TileMapY, name: nameof(TileMapY)); TileMapX = 0; CollisionType = (byte)s.Serialize <ushort>((ushort)CollisionType, name: nameof(CollisionType)); } else if (s.GameSettings.EngineVersion == EngineVersion.R1_PC || s.GameSettings.EngineVersion == EngineVersion.R1_PC_Kit || s.GameSettings.EngineVersion == EngineVersion.R1_PC_Edu || s.GameSettings.EngineVersion == EngineVersion.R1_PS1_Edu || s.GameSettings.EngineVersion == EngineVersion.R1_PocketPC) { TileMapY = s.Serialize <ushort>(TileMapY, name: nameof(TileMapY)); TileMapX = 0; CollisionType = s.Serialize <byte>(CollisionType, name: nameof(CollisionType)); PC_Unk1 = s.Serialize <byte>(PC_Unk1, name: nameof(PC_Unk1)); PC_TransparencyMode = s.Serialize <R1_PC_MapTileTransparencyMode>(PC_TransparencyMode, name: nameof(PC_TransparencyMode)); PC_Unk2 = s.Serialize <byte>(PC_Unk2, name: nameof(PC_Unk2)); } else if (s.GameSettings.EngineVersion == EngineVersion.R1_PS1_JPDemoVol3 || s.GameSettings.EngineVersion == EngineVersion.R1_PS1_JPDemoVol6) { s.SerializeBitValues <int>(bitFunc => { TileMapX = (ushort)bitFunc(TileMapX, 10, name: nameof(TileMapX)); TileMapY = (ushort)bitFunc(TileMapY, 6, name: nameof(TileMapY)); CollisionType = (byte)bitFunc(CollisionType, 8, name: nameof(CollisionType)); }); } else if (s.GameSettings.EngineVersion == EngineVersion.R1_Saturn) { s.SerializeBitValues <ushort>(bitFunc => { TileMapX = (ushort)bitFunc(TileMapX, 4, name: nameof(TileMapX)); TileMapY = (ushort)bitFunc(TileMapY, 12, name: nameof(TileMapY)); }); CollisionType = s.Serialize <byte>(CollisionType, name: nameof(CollisionType)); s.Serialize <byte>(0, name: "Padding"); } else if (s.GameSettings.MajorEngineVersion == MajorEngineVersion.Rayman1_Jaguar) { s.SerializeBitValues <ushort>(bitFunc => { TileMapY = (ushort)bitFunc(TileMapY, 12, name: nameof(TileMapY)); CollisionType = (byte)bitFunc(CollisionType, 4, name: nameof(CollisionType)); }); TileMapX = 0; } else if (s.GameSettings.MajorEngineVersion == MajorEngineVersion.SNES) { s.SerializeBitValues <ushort>(bitFunc => { TileMapY = (ushort)bitFunc(TileMapY, 10, name: nameof(TileMapY)); HorizontalFlip = bitFunc(HorizontalFlip ? 1 : 0, 1, name: nameof(HorizontalFlip)) == 1; VerticalFlip = bitFunc(VerticalFlip ? 1 : 0, 1, name: nameof(VerticalFlip)) == 1; CollisionType = (byte)bitFunc(CollisionType, 4, name: nameof(CollisionType)); }); TileMapX = 0; } else if (s.GameSettings.MajorEngineVersion == MajorEngineVersion.GBA) { // TODO: Use SerializeBitValues if ((GBATileType == GBA_TileType.BGTile || GBATileType == GBA_TileType.FGTile) && s.GameSettings.EngineVersion != EngineVersion.GBA_SplinterCell_NGage && s.GameSettings.EngineVersion != EngineVersion.GBA_BatmanVengeance) { int numBits = Is8Bpp ? 9 : 10; if (s.GameSettings.EngineVersion <= EngineVersion.GBA_BatmanVengeance) { numBits = 8; }/*else if(s.GameSettings.EngineVersion >= EngineVersion.GBA_StarWarsTrilogy) { * numBits = Is8Bpp ? 9 : 10; * } else if (s.GameSettings.EngineVersion >= EngineVersion.GBA_SplinterCell) { * numBits = 9; * if (GBATileType == GBA_TileType.FGTile) numBits = 10; * }*/ ushort value = 0; value = (ushort)BitHelpers.SetBits(value, TileMapY, numBits, 0); //value = (ushort)BitHelpers.SetBits(value, VerticalFlip ? 1 : 0, 1, numBits); value = (ushort)BitHelpers.SetBits(value, HorizontalFlip ? 1 : 0, 1, numBits); value = (ushort)BitHelpers.SetBits(value, PaletteIndex, 4, 12); value = s.Serialize <ushort>(value, name: nameof(value)); TileMapY = (ushort)BitHelpers.ExtractBits(value, numBits, 0); TileMapX = 0; if (Is8Bpp) { IsFirstBlock = BitHelpers.ExtractBits(value, 1, 9) == 1; } HorizontalFlip = BitHelpers.ExtractBits(value, 1, 10) == 1; VerticalFlip = BitHelpers.ExtractBits(value, 1, 11) == 1; PaletteIndex = (byte)BitHelpers.ExtractBits(value, 4, 12); s.Log($"{nameof(TileMapY)}: {TileMapY}"); s.Log($"{nameof(HorizontalFlip)}: {HorizontalFlip}"); s.Log($"{nameof(IsFirstBlock)}: {IsFirstBlock}"); s.Log($"{nameof(PaletteIndex)}: {PaletteIndex}"); } else if (GBATileType == GBA_TileType.Mode7Tile) { ushort value = 0; value = (ushort)BitHelpers.SetBits(value, TileMapY, 9, 0); //value = (ushort)BitHelpers.SetBits(value, VerticalFlip ? 1 : 0, 1, numBits); value = (ushort)BitHelpers.SetBits(value, HorizontalFlip ? 1 : 0, 1, 9); value = s.Serialize <ushort>(value, name: nameof(value)); TileMapY = (ushort)BitHelpers.ExtractBits(value, 9, 0); TileMapX = 0; IsFirstBlock = BitHelpers.ExtractBits(value, 1, 9) == 1; HorizontalFlip = BitHelpers.ExtractBits(value, 1, 10) == 1; VerticalFlip = BitHelpers.ExtractBits(value, 1, 11) == 1; s.Log($"{nameof(TileMapY)}: {TileMapY}"); s.Log($"{nameof(HorizontalFlip)}: {HorizontalFlip}"); s.Log($"{nameof(IsFirstBlock)}: {IsFirstBlock}"); } else { int numBits = Is8Bpp ? 14 : 11; if (s.GameSettings.EngineVersion <= EngineVersion.GBA_BatmanVengeance) { numBits = 10; } else if (s.GameSettings.EngineVersion == EngineVersion.GBA_SplinterCell_NGage) { numBits = Is8Bpp ? 14 : 12; } else if (s.GameSettings.EngineVersion >= EngineVersion.GBA_SplinterCell) { numBits = Is8Bpp ? 14 : 12; } ushort value = 0; value = (ushort)BitHelpers.SetBits(value, TileMapY, numBits, 0); value = (ushort)BitHelpers.SetBits(value, HorizontalFlip ? 1 : 0, 1, numBits); value = (ushort)BitHelpers.SetBits(value, PaletteIndex, 4, 12); value = s.Serialize <ushort>(value, name: nameof(value)); TileMapY = (ushort)BitHelpers.ExtractBits(value, numBits, 0); if (s.GameSettings.EngineVersion == EngineVersion.GBA_SplinterCell_NGage && Is8Bpp) { TileMapY = (ushort)BitHelpers.ExtractBits(value, numBits - 1, 0); } TileMapX = 0; HorizontalFlip = BitHelpers.ExtractBits(value, 1, numBits) == 1; if (s.GameSettings.EngineVersion == EngineVersion.GBA_BatmanVengeance) { VerticalFlip = BitHelpers.ExtractBits(value, 1, numBits + 1) == 1; } if (!Is8Bpp) { if (s.GameSettings.EngineVersion >= EngineVersion.GBA_SplinterCell) { PaletteIndex = (byte)BitHelpers.ExtractBits(value, 3, 13); } else { PaletteIndex = (byte)BitHelpers.ExtractBits(value, 4, 12); } if (s.GameSettings.EngineVersion == EngineVersion.GBA_SplinterCell) { PaletteIndex += 8; } } else if (s.GameSettings.EngineVersion != EngineVersion.GBA_BatmanVengeance) { VerticalFlip = BitHelpers.ExtractBits(value, 1, numBits + 1) == 1; } s.Log($"{nameof(TileMapY)}: {TileMapY}"); s.Log($"{nameof(HorizontalFlip)}: {HorizontalFlip}"); s.Log($"{nameof(PaletteIndex)}: {PaletteIndex}"); } } else if (s.GameSettings.EngineVersion == EngineVersion.R1_PS1 || s.GameSettings.EngineVersion == EngineVersion.R2_PS1) { s.SerializeBitValues <ushort>(bitFunc => { TileMapX = (ushort)bitFunc(TileMapX, 4, name: nameof(TileMapX)); TileMapY = (ushort)bitFunc(TileMapY, 6, name: nameof(TileMapY)); CollisionType = (byte)bitFunc(CollisionType, 6, name: nameof(CollisionType)); }); } else if (s.GameSettings.EngineVersion == EngineVersion.R1_PS1_JP) { s.SerializeBitValues <ushort>(bitFunc => { TileMapX = (ushort)bitFunc(TileMapX, 9, name: nameof(TileMapX)); CollisionType = (byte)bitFunc(CollisionType, 7, name: nameof(CollisionType)); }); } else if (s.GameSettings.MajorEngineVersion == MajorEngineVersion.GBARRR) { if (GBARRRType == GBARRR_MapBlock.MapType.Collision) { CollisionType = s.Serialize <byte>(CollisionType, name: nameof(CollisionType)); } else if (GBARRRType == GBARRR_MapBlock.MapType.Tiles) { TileMapY = s.Serialize <ushort>(TileMapY, name: nameof(TileMapY)); } else if (GBARRRType == GBARRR_MapBlock.MapType.Foreground) { s.SerializeBitValues <ushort>(bitFunc => { TileMapY = (ushort)bitFunc(TileMapY, 10, name: nameof(TileMapY)); HorizontalFlip = bitFunc(HorizontalFlip ? 1 : 0, 1, name: nameof(HorizontalFlip)) == 1; VerticalFlip = bitFunc(VerticalFlip ? 1 : 0, 1, name: nameof(VerticalFlip)) == 1; PaletteIndex = (byte)bitFunc(PaletteIndex, 4, name: nameof(PaletteIndex)); //Unk = (byte)bitFunc(Unk, 4, name: nameof(Unk)); }); } else if (GBARRRType == GBARRR_MapBlock.MapType.Menu) { s.SerializeBitValues <ushort>(bitFunc => { TileMapY = (ushort)bitFunc(TileMapY, 8, name: nameof(TileMapY)); GBARRR_MenuUnk = (byte)bitFunc(GBARRR_MenuUnk, 2, name: nameof(GBARRR_MenuUnk)); HorizontalFlip = bitFunc(HorizontalFlip ? 1 : 0, 1, name: nameof(HorizontalFlip)) == 1; VerticalFlip = bitFunc(VerticalFlip ? 1 : 0, 1, name: nameof(VerticalFlip)) == 1; PaletteIndex = (byte)bitFunc(PaletteIndex, 4, name: nameof(PaletteIndex)); //Unk = (byte)bitFunc(Unk, 4, name: nameof(Unk)); }); } else if (GBARRRType == GBARRR_MapBlock.MapType.Mode7Tiles) { TileMapY = s.Serialize <byte>((byte)TileMapY, name: nameof(TileMapY)); } } }
/// <summary> /// Handles the data serialization /// </summary> /// <param name="s">The serializer object</param> public override void SerializeImpl(SerializerObject s) { // Serialize initial unknown values UShort_00 = s.Serialize <ushort>(UShort_00, name: nameof(UShort_00)); UShort_02 = s.Serialize <ushort>(UShort_02, name: nameof(UShort_02)); UShort_04 = s.Serialize <ushort>(UShort_04, name: nameof(UShort_04)); UShort_06 = s.Serialize <ushort>(UShort_06, name: nameof(UShort_06)); UShort_08 = s.Serialize <ushort>(UShort_08, name: nameof(UShort_08)); UShort_0A = s.Serialize <ushort>(UShort_0A, name: nameof(UShort_0A)); // Serialize pointers ObjParamsPointer = s.SerializePointer(ObjParamsPointer, name: nameof(ObjParamsPointer)); CollisionDataPointer = s.SerializePointer(CollisionDataPointer, name: nameof(CollisionDataPointer)); AnimGroupPointer = s.SerializePointer(AnimGroupPointer, name: nameof(AnimGroupPointer)); RuntimeHandlersPointer = s.Serialize <uint>(RuntimeHandlersPointer, name: nameof(RuntimeHandlersPointer)); // Serialize positions InitialXPosition = s.Serialize <short>(InitialXPosition, name: nameof(InitialXPosition)); InitialYPosition = s.Serialize <short>(InitialYPosition, name: nameof(InitialYPosition)); // Serialize state data InitialEtat = s.Serialize <byte>(InitialEtat, name: nameof(InitialEtat)); InitialSubEtat = s.Serialize <byte>(InitialSubEtat, name: nameof(InitialSubEtat)); InitialHitPoints = s.Serialize <byte>(InitialHitPoints, name: nameof(InitialHitPoints)); InitialDisplayPrio = s.Serialize <byte>(InitialDisplayPrio, name: nameof(InitialDisplayPrio)); MapLayer = s.Serialize <ObjMapLayer>(MapLayer, name: nameof(MapLayer)); Byte_25 = s.Serialize <byte>(Byte_25, name: nameof(Byte_25)); Flags = s.Serialize <PS1_R2Demo_EventFlags>(Flags, name: nameof(Flags)); Byte_27 = s.Serialize <byte>(Byte_27, name: nameof(Byte_27)); Float_XPos = s.Serialize <int>(Float_XPos, name: nameof(Float_XPos)); Float_YPos = s.Serialize <int>(Float_YPos, name: nameof(Float_YPos)); Unk2 = s.SerializeArray(Unk2, 8, name: nameof(Unk2)); // Two floats? RuntimeCurrentStatePointer = s.Serialize <uint>(RuntimeCurrentStatePointer, name: nameof(RuntimeCurrentStatePointer)); RuntimeCurrentAnimDescriptorPointer = s.Serialize <uint>(RuntimeCurrentAnimDescriptorPointer, name: nameof(RuntimeCurrentAnimDescriptorPointer)); EventIndex = s.Serialize <ushort>(EventIndex, name: nameof(EventIndex)); // Serialize the type EventType = s.Serialize <R1_R2EventType>(EventType, name: nameof(EventType)); XPosition = s.Serialize <short>(XPosition, name: nameof(XPosition)); YPosition = s.Serialize <short>(YPosition, name: nameof(YPosition)); ScreenXPosition = s.Serialize <short>(ScreenXPosition, name: nameof(ScreenXPosition)); ScreenYPosition = s.Serialize <short>(ScreenYPosition, name: nameof(ScreenYPosition)); Float_SpeedX = s.Serialize <short>(Float_SpeedX, name: nameof(Float_SpeedX)); Float_SpeedY = s.Serialize <short>(Float_SpeedY, name: nameof(Float_SpeedY)); Short_50 = s.Serialize <short>(Short_50, name: nameof(Short_50)); Byte_52 = s.Serialize <byte>(Byte_52, name: nameof(Byte_52)); RuntimeCurrentAnimIndex = s.Serialize <byte>(RuntimeCurrentAnimIndex, name: nameof(RuntimeCurrentAnimIndex)); RuntimeCurrentAnimFrame = s.Serialize <byte>(RuntimeCurrentAnimFrame, name: nameof(RuntimeCurrentAnimFrame)); Etat = s.Serialize <byte>(Etat, name: nameof(Etat)); SubEtat = s.Serialize <byte>(SubEtat, name: nameof(SubEtat)); HitPoints = s.Serialize <byte>(HitPoints, name: nameof(HitPoints)); Byte_58 = s.Serialize <byte>(Byte_58, name: nameof(Byte_58)); DisplayPrio = s.Serialize <byte>(DisplayPrio, name: nameof(DisplayPrio)); RuntimeCurrentCollisionType = s.Serialize <R2_TileCollisionType>(RuntimeCurrentCollisionType, name: nameof(RuntimeCurrentCollisionType)); Bytes_5B = s.SerializeArray(Bytes_5B, 9, name: nameof(Bytes_5B)); RuntimeMapLayer = s.Serialize <ObjMapLayer>(RuntimeMapLayer, name: nameof(RuntimeMapLayer)); Bytes_65 = s.SerializeArray(Bytes_65, 2, name: nameof(Bytes_65)); RuntimeFlags1 = s.Serialize <PS1_R2Demo_EventRuntimeFlags1>(RuntimeFlags1, name: nameof(RuntimeFlags1)); s.SerializeBitValues <byte>(bitFunc => { RuntimeFlipX = bitFunc(RuntimeFlipX ? 1 : 0, 1, name: nameof(RuntimeFlipX)) == 1; RuntimeUnkFlag = bitFunc(RuntimeUnkFlag ? 1 : 0, 1, name: nameof(RuntimeUnkFlag)) == 1; ZDCFlags = (byte)bitFunc(ZDCFlags, 6, name: nameof(ZDCFlags)); }); RuntimeFlags3 = s.Serialize <byte>(RuntimeFlags3, name: nameof(RuntimeFlags3)); Unk5 = s.SerializeArray(Unk5, 2, name: nameof(Unk5)); // Parse data from pointers // Serialize collision data if (CollisionDataPointer != null) { s.DoAt(CollisionDataPointer, () => CollisionData = s.SerializeObject <R1_R2EventCollision>(CollisionData, name: nameof(CollisionData))); } // Serialize object params s.DoAt(ObjParamsPointer, () => { if (EventType == R1_R2EventType.Gendoor || EventType == R1_R2EventType.Killdoor) { ParamsGendoor = s.SerializeObject <Params_Gendoor>(ParamsGendoor, name: nameof(ParamsGendoor)); } else if (EventType == R1_R2EventType.Trigger) { ParamsTrigger = s.SerializeObject <Params_Trigger>(ParamsTrigger, name: nameof(ParamsTrigger)); } else { ParamsGeneric = s.SerializeArray <byte>(ParamsGeneric, 44, name: nameof(ParamsGeneric)); // 44 bytes is the max length for object params } }); if (!s.FullSerialize || Offset.file is ProcessMemoryStreamFile) { return; } // Serialize the animation group data if (AnimGroupPointer != null) { s.DoAt(AnimGroupPointer, () => AnimGroup = s.SerializeObject <R1_R2EventAnimGroup>(AnimGroup, name: nameof(AnimGroup))); } }
/// <summary> /// Serializes the data /// </summary> /// <param name="s">The serializer object</param> public override void SerializeImpl(SerializerObject s) { if (s.GameSettings.EngineVersion == EngineVersion.R2_PS1) { UnkR2_1 = s.SerializeArray <byte>(UnkR2_1, 4, name: nameof(UnkR2_1)); AnimationIndex = s.Serialize <byte>(AnimationIndex, name: nameof(AnimationIndex)); UnkR2_2 = s.SerializeArray <byte>(UnkR2_2, 5, name: nameof(UnkR2_2)); LinkedEtat = s.Serialize <byte>(LinkedEtat, name: nameof(LinkedEtat)); LinkedSubEtat = s.Serialize <byte>(LinkedSubEtat, name: nameof(LinkedSubEtat)); UnkR2_3 = s.Serialize <byte>(UnkR2_3, name: nameof(UnkR2_3)); AnimationSpeed = s.Serialize <byte>(AnimationSpeed, name: nameof(AnimationSpeed)); UnkR2_4 = s.SerializeArray <byte>(UnkR2_4, 2, name: nameof(UnkR2_4)); } else { RightSpeed = s.Serialize <sbyte>(RightSpeed, name: nameof(RightSpeed)); if (s.GameSettings.EngineVersion == EngineVersion.R1_PS1_JPDemoVol3 || s.GameSettings.EngineVersion == EngineVersion.R1_PS1_JPDemoVol6) { UnkDemo1 = s.Serialize <byte>(UnkDemo1, name: nameof(UnkDemo1)); } LeftSpeed = s.Serialize <sbyte>(LeftSpeed, name: nameof(LeftSpeed)); if (s.GameSettings.EngineVersion == EngineVersion.R1_PS1_JPDemoVol3 || s.GameSettings.EngineVersion == EngineVersion.R1_PS1_JPDemoVol6) { UnkDemo2 = s.Serialize <byte>(UnkDemo2, name: nameof(UnkDemo2)); } AnimationIndex = s.Serialize <byte>(AnimationIndex, name: nameof(AnimationIndex)); if (s.GameSettings.EngineVersion == EngineVersion.R1_PS1_JPDemoVol3 || s.GameSettings.EngineVersion == EngineVersion.R1_PS1_JPDemoVol6) { UnkDemo3 = s.Serialize <byte>(UnkDemo3, name: nameof(UnkDemo3)); } LinkedEtat = s.Serialize <byte>(LinkedEtat, name: nameof(LinkedEtat)); LinkedSubEtat = s.Serialize <byte>(LinkedSubEtat, name: nameof(LinkedSubEtat)); if (s.GameSettings.EngineVersion == EngineVersion.R1_PS1_JPDemoVol3) { UnkDemo4 = s.Serialize <byte>(UnkDemo4, name: nameof(UnkDemo4)); } if (s.GameSettings.EngineVersion == EngineVersion.R1_Saturn) { s.SerializeBitValues <byte>(bitFunc => { Unk = (byte)bitFunc(Unk, 4, name: nameof(Unk)); AnimationSpeed = (byte)bitFunc(AnimationSpeed, 4, name: nameof(AnimationSpeed)); }); } else { s.SerializeBitValues <byte>(bitFunc => { AnimationSpeed = (byte)bitFunc(AnimationSpeed, 4, name: nameof(AnimationSpeed)); Unk = (byte)bitFunc(Unk, 4, name: nameof(Unk)); }); } if (s.GameSettings.EngineVersion == EngineVersion.R1_PS1_JPDemoVol3) { UnkDemo5 = s.Serialize <byte>(UnkDemo5, name: nameof(UnkDemo5)); UnkDemo6 = s.Serialize <byte>(UnkDemo6, name: nameof(UnkDemo6)); UnkDemo7 = s.Serialize <byte>(UnkDemo7, name: nameof(UnkDemo7)); UnkDemo8 = s.Serialize <byte>(UnkDemo8, name: nameof(UnkDemo8)); } else { if (s.GameSettings.EngineVersion == EngineVersion.R1_PS1_JPDemoVol6) { UnkDemo4 = s.Serialize <byte>(UnkDemo4, name: nameof(UnkDemo4)); } SoundIndex = s.Serialize <byte>(SoundIndex, name: nameof(SoundIndex)); ZDCFlags = s.Serialize <R1_ZDCFlags>(ZDCFlags, name: nameof(ZDCFlags)); } } }