public override void SerializeImpl(SerializerObject s)
        {
            MapTilesPointer = s.SerializePointer(MapTilesPointer, name: nameof(MapTilesPointer));
            TileMapPointer  = s.SerializePointer(TileMapPointer, name: nameof(TileMapPointer));
            LayerPrio       = s.Serialize <uint>(LayerPrio, name: nameof(LayerPrio));
            ScrollX         = s.Serialize <uint>(ScrollX, name: nameof(ScrollX));
            ScrollY         = s.Serialize <uint>(ScrollY, name: nameof(ScrollY));
            Uint_14         = s.Serialize <uint>(Uint_14, name: nameof(Uint_14));
            Uint_18         = s.Serialize <uint>(Uint_18, name: nameof(Uint_18));

            TileMap = s.DoAt(TileMapPointer, () => s.SerializeObject <GBAVV_Isometric_MapLayer>(TileMap, x => x.IsWorldMap = true, name: nameof(TileMap)));
            var mapTilesLength = TileMap.TileMapRows.SelectMany(x => x.Commands).Select(x => x.Params?.Max() ?? x.Param).Max() + 1;

            MapTiles = s.DoAt(MapTilesPointer, () => s.SerializeObjectArray <MapTile>(MapTiles, mapTilesLength * 4, x => x.GBAVV_IsWorldMap8bpp = Is8bpp, name: nameof(MapTiles)));
        }
Example #2
0
        public override void SerializeImpl(SerializerObject s)
        {
            NamePointer           = s.SerializePointer(NamePointer, name: nameof(NamePointer));
            MapWidth              = s.Serialize <ushort>(MapWidth, name: nameof(MapWidth));
            MapHeight             = s.Serialize <ushort>(MapHeight, name: nameof(MapHeight));
            TileSetCount_Total    = s.Serialize <ushort>(TileSetCount_Total, name: nameof(TileSetCount_Total));
            TileSetCount_4bpp     = s.Serialize <ushort>(TileSetCount_4bpp, name: nameof(TileSetCount_4bpp));
            TileSetPointer        = s.SerializePointer(TileSetPointer, name: nameof(TileSetPointer));
            MapTilesPointer       = s.SerializePointer(MapTilesPointer, name: nameof(MapTilesPointer));
            MapLayerPointers      = s.SerializePointerArray(MapLayerPointers, 4, name: nameof(MapLayerPointers));
            TilePalettePointer    = s.SerializePointer(TilePalettePointer, name: nameof(TilePalettePointer));
            CollisionWidth        = s.Serialize <ushort>(CollisionWidth, name: nameof(CollisionWidth));
            CollisionHeight       = s.Serialize <ushort>(CollisionHeight, name: nameof(CollisionHeight));
            CollisionMapPointer   = s.SerializePointer(CollisionMapPointer, name: nameof(CollisionMapPointer));
            CollisionTilesPointer = s.SerializePointer(CollisionTilesPointer, name: nameof(CollisionTilesPointer));
            CollisionTypePointers = s.SerializePointer(CollisionTypePointers, name: nameof(CollisionTypePointers));
            Pointer_38            = s.SerializePointer(Pointer_38, name: nameof(Pointer_38));
            Pointer_3C            = s.SerializePointer(Pointer_3C, name: nameof(Pointer_3C));
            Pointer_40            = s.SerializePointer(Pointer_40, name: nameof(Pointer_40));
            Pointer_44            = s.SerializePointer(Pointer_44, name: nameof(Pointer_44));
            Pointer_48            = s.SerializePointer(Pointer_48, name: nameof(Pointer_48));
            Pointer_4C            = s.SerializePointer(Pointer_4C, name: nameof(Pointer_4C));
            XPosition             = s.SerializeObject <FixedPointInt>(XPosition, name: nameof(XPosition));
            YPosition             = s.SerializeObject <FixedPointInt>(YPosition, name: nameof(YPosition));

            Name = s.DoAt(NamePointer, () => s.SerializeString(Name, name: nameof(Name)));

            if (!SerializeData)
            {
                return;
            }

            TileSet = s.DoAt(TileSetPointer, () => s.SerializeObject <GBAVV_Isometric_TileSet>(TileSet, x =>
            {
                x.TileSetCount_Total = TileSetCount_Total;
                x.TileSetCount_4bpp  = TileSetCount_4bpp;
            }, name: nameof(TileSet)));

            if (MapLayers == null)
            {
                MapLayers = new GBAVV_Isometric_MapLayer[MapLayerPointers.Length];
            }

            for (int i = 0; i < MapLayers.Length; i++)
            {
                MapLayers[i] = s.DoAt(MapLayerPointers[i], () => s.SerializeObject <GBAVV_Isometric_MapLayer>(MapLayers[i], name: $"{nameof(MapLayers)}[{i}]"));
            }

            var mapTilesLength = MapLayers.SelectMany(x => x.TileMapRows).SelectMany(x => x.Commands).Select(x => x.Params?.Max() ?? x.Param).Max() + 1;

            MapTiles    = s.DoAt(MapTilesPointer, () => s.SerializeObjectArray <MapTile>(MapTiles, mapTilesLength * 4, x => x.Is8Bpp = true, name: nameof(MapTiles)));
            TilePalette = s.DoAt(TilePalettePointer, () => s.SerializeObjectArray <RGBA5551Color>(TilePalette, 256, name: nameof(TilePalette)));

            CollisionMap   = s.DoAt(CollisionMapPointer, () => s.SerializeArray <ushort>(CollisionMap, CollisionWidth * CollisionHeight, name: nameof(CollisionMap)));
            CollisionTiles = s.DoAt(CollisionTilesPointer, () => s.SerializeObjectArray <GBAVV_Isometric_CollisionTile>(CollisionTiles, CollisionMap.Max() + 1, name: nameof(CollisionTiles)));
            CollisionTypes = s.DoAt(CollisionTypePointers, () => s.SerializeObjectArray <GBAVV_Isometric_CollisionType>(CollisionTypes, CollisionTiles.Max(x => x.TypeIndex) + 1, name: nameof(CollisionTypes)));

            s.DoAt(Pointer_4C, () =>
            {
                if (Pointer_4C_Structs == null)
                {
                    var objects = new List <GBAVV_Isometric_UnkStruct_0>();
                    var index   = 0;

                    while (true)
                    {
                        var obj = s.SerializeObject <GBAVV_Isometric_UnkStruct_0>(default, name: $"{nameof(Pointer_4C_Structs)}[{index++}]");