#include "Generated.h"

namespace Generated
{
    bool Save(const PuzzleElementType::Enum* obj, uint32_t count, Serializer& serializer)
    {
        bool isOk = true;
        for (uint32_t i = 0; i < count; ++i)
        {
            auto val = (int32_t)obj[i];
            isOk = Save(&val, 1, serializer) && isOk;
        }
        return isOk;
    }
    bool Load(PuzzleElementType::Enum* obj, uint32_t count, Deserializer& serializer)
    {
        bool isOk = true;
        for (uint32_t i = 0; i < count; ++i)
        {
            int32_t& val = (int32_t&)obj[i];
            isOk = Load(&val, 1, serializer) && isOk;
        }
        return isOk;
    }
    bool Save(const Vec2* obj, uint32_t count, Serializer& serializer)
    {
        bool isOk = true;
        for (uint32_t i = 0; i < count; ++i)
        {
            isOk = Save(&obj[i].X, 1, serializer) && isOk;
            isOk = Save(&obj[i].Y, 1, serializer) && isOk;
        }
        return isOk;
    }
    bool Load(Vec2* obj, uint32_t count, Deserializer& serializer)
    {
        bool isOk = true;
        for (uint32_t i = 0; i < count; ++i)
        {
            isOk = Load(&obj[i].X, 1, serializer) && isOk;
            isOk = Load(&obj[i].Y, 1, serializer) && isOk;
        }
        return isOk;
    }
    bool Save(const Vec3* obj, uint32_t count, Serializer& serializer)
    {
        bool isOk = true;
        for (uint32_t i = 0; i < count; ++i)
        {
            isOk = Save(&obj[i].X, 1, serializer) && isOk;
            isOk = Save(&obj[i].Y, 1, serializer) && isOk;
            isOk = Save(&obj[i].Z, 1, serializer) && isOk;
        }
        return isOk;
    }
    bool Load(Vec3* obj, uint32_t count, Deserializer& serializer)
    {
        bool isOk = true;
        for (uint32_t i = 0; i < count; ++i)
        {
            isOk = Load(&obj[i].X, 1, serializer) && isOk;
            isOk = Load(&obj[i].Y, 1, serializer) && isOk;
            isOk = Load(&obj[i].Z, 1, serializer) && isOk;
        }
        return isOk;
    }
    bool Save(const Vec4* obj, uint32_t count, Serializer& serializer)
    {
        bool isOk = true;
        for (uint32_t i = 0; i < count; ++i)
        {
            isOk = Save(&obj[i].X, 1, serializer) && isOk;
            isOk = Save(&obj[i].Y, 1, serializer) && isOk;
            isOk = Save(&obj[i].Z, 1, serializer) && isOk;
            isOk = Save(&obj[i].W, 1, serializer) && isOk;
        }
        return isOk;
    }
    bool Load(Vec4* obj, uint32_t count, Deserializer& serializer)
    {
        bool isOk = true;
        for (uint32_t i = 0; i < count; ++i)
        {
            isOk = Load(&obj[i].X, 1, serializer) && isOk;
            isOk = Load(&obj[i].Y, 1, serializer) && isOk;
            isOk = Load(&obj[i].Z, 1, serializer) && isOk;
            isOk = Load(&obj[i].W, 1, serializer) && isOk;
        }
        return isOk;
    }
    bool Save(const Mat3* obj, uint32_t count, Serializer& serializer)
    {
        bool isOk = true;
        for (uint32_t i = 0; i < count; ++i)
        {
            isOk = Save(obj[i].M, 9, serializer) && isOk;
        }
        return isOk;
    }
    bool Load(Mat3* obj, uint32_t count, Deserializer& serializer)
    {
        bool isOk = true;
        for (uint32_t i = 0; i < count; ++i)
        {
            isOk = Load(obj[i].M, 9, serializer) && isOk;
        }
        return isOk;
    }
    bool Save(const Mat4* obj, uint32_t count, Serializer& serializer)
    {
        bool isOk = true;
        for (uint32_t i = 0; i < count; ++i)
        {
            isOk = Save(obj[i].M, 16, serializer) && isOk;
        }
        return isOk;
    }
    bool Load(Mat4* obj, uint32_t count, Deserializer& serializer)
    {
        bool isOk = true;
        for (uint32_t i = 0; i < count; ++i)
        {
            isOk = Load(obj[i].M, 16, serializer) && isOk;
        }
        return isOk;
    }
    bool Save(const AssetHandle* obj, uint32_t count, Serializer& serializer)
    {
        bool isOk = true;
        for (uint32_t i = 0; i < count; ++i)
        {
            isOk = Save(&obj[i].Idx, 1, serializer) && isOk;
        }
        return isOk;
    }
    bool Load(AssetHandle* obj, uint32_t count, Deserializer& serializer)
    {
        bool isOk = true;
        for (uint32_t i = 0; i < count; ++i)
        {
            isOk = Load(&obj[i].Idx, 1, serializer) && isOk;
        }
        return isOk;
    }
    bool Save(const ModelHandle* obj, uint32_t count, Serializer& serializer)
    {
        bool isOk = true;
        for (uint32_t i = 0; i < count; ++i)
        {
            isOk = Save(&obj[i].ModelIdx, 1, serializer) && isOk;
            isOk = Save(&obj[i].Asset, 1, serializer) && isOk;
        }
        return isOk;
    }
    bool Load(ModelHandle* obj, uint32_t count, Deserializer& serializer)
    {
        bool isOk = true;
        for (uint32_t i = 0; i < count; ++i)
        {
            isOk = Load(&obj[i].ModelIdx, 1, serializer) && isOk;
            isOk = Load(&obj[i].Asset, 1, serializer) && isOk;
        }
        return isOk;
    }
    bool Save(const TextureHandle* obj, uint32_t count, Serializer& serializer)
    {
        bool isOk = true;
        for (uint32_t i = 0; i < count; ++i)
        {
            isOk = Save(&obj[i].TextureIdx, 1, serializer) && isOk;
            isOk = Save(&obj[i].Asset, 1, serializer) && isOk;
        }
        return isOk;
    }
    bool Load(TextureHandle* obj, uint32_t count, Deserializer& serializer)
    {
        bool isOk = true;
        for (uint32_t i = 0; i < count; ++i)
        {
            isOk = Load(&obj[i].TextureIdx, 1, serializer) && isOk;
            isOk = Load(&obj[i].Asset, 1, serializer) && isOk;
        }
        return isOk;
    }
    bool Save(const PuzPos* obj, uint32_t count, Serializer& serializer)
    {
        bool isOk = true;
        for (uint32_t i = 0; i < count; ++i)
        {
            isOk = Save(&obj[i].X, 1, serializer) && isOk;
            isOk = Save(&obj[i].Y, 1, serializer) && isOk;
        }
        return isOk;
    }
    bool Load(PuzPos* obj, uint32_t count, Deserializer& serializer)
    {
        bool isOk = true;
        for (uint32_t i = 0; i < count; ++i)
        {
            isOk = Load(&obj[i].X, 1, serializer) && isOk;
            isOk = Load(&obj[i].Y, 1, serializer) && isOk;
        }
        return isOk;
    }
    bool Save(const StaticPuzzleCard* obj, uint32_t count, Serializer& serializer)
    {
        bool isOk = true;
        for (uint32_t i = 0; i < count; ++i)
        {
            isOk = Save(obj[i].Elements, 4, serializer) && isOk;
            isOk = Save(&obj[i].ModelHandle, 1, serializer) && isOk;
            isOk = Save(&obj[i].BoardTextureHandle, 1, serializer) && isOk;
        }
        return isOk;
    }
    bool Load(StaticPuzzleCard* obj, uint32_t count, Deserializer& serializer)
    {
        bool isOk = true;
        for (uint32_t i = 0; i < count; ++i)
        {
            isOk = Load(obj[i].Elements, 4, serializer) && isOk;
            isOk = Load(&obj[i].ModelHandle, 1, serializer) && isOk;
            isOk = Load(&obj[i].BoardTextureHandle, 1, serializer) && isOk;
        }
        return isOk;
    }
    bool Save(const StaticPuzzleCardHandle* obj, uint32_t count, Serializer& serializer)
    {
        bool isOk = true;
        for (uint32_t i = 0; i < count; ++i)
        {
            isOk = Save(&obj[i].Idx, 1, serializer) && isOk;
        }
        return isOk;
    }
    bool Load(StaticPuzzleCardHandle* obj, uint32_t count, Deserializer& serializer)
    {
        bool isOk = true;
        for (uint32_t i = 0; i < count; ++i)
        {
            isOk = Load(&obj[i].Idx, 1, serializer) && isOk;
        }
        return isOk;
    }
    bool Save(const StaticPuzzleData* obj, uint32_t count, Serializer& serializer)
    {
        bool isOk = true;
        for (uint32_t i = 0; i < count; ++i)
        {
            isOk = Save(obj[i].Cards, 64, serializer) && isOk;
        }
        return isOk;
    }
    bool Load(StaticPuzzleData* obj, uint32_t count, Deserializer& serializer)
    {
        bool isOk = true;
        for (uint32_t i = 0; i < count; ++i)
        {
            isOk = Load(obj[i].Cards, 64, serializer) && isOk;
        }
        return isOk;
    }
    bool Save(const PuzzleCardStack* obj, uint32_t count, Serializer& serializer)
    {
        bool isOk = true;
        for (uint32_t i = 0; i < count; ++i)
        {
            isOk = Save(&obj[i].RefCard, 1, serializer) && isOk;
            isOk = Save(&obj[i].MaxAvailableCount, 1, serializer) && isOk;
            isOk = Save(&obj[i].UsedCount, 1, serializer) && isOk;
        }
        return isOk;
    }
    bool Load(PuzzleCardStack* obj, uint32_t count, Deserializer& serializer)
    {
        bool isOk = true;
        for (uint32_t i = 0; i < count; ++i)
        {
            isOk = Load(&obj[i].RefCard, 1, serializer) && isOk;
            isOk = Load(&obj[i].MaxAvailableCount, 1, serializer) && isOk;
            isOk = Load(&obj[i].UsedCount, 1, serializer) && isOk;
        }
        return isOk;
    }
    bool Save(const PlacedPuzzleCard* obj, uint32_t count, Serializer& serializer)
    {
        bool isOk = true;
        for (uint32_t i = 0; i < count; ++i)
        {
            isOk = Save(&obj[i].RefCard, 1, serializer) && isOk;
            isOk = Save(&obj[i].Position, 1, serializer) && isOk;
            isOk = Save(&obj[i].Rotation, 1, serializer) && isOk;
            isOk = Save(&obj[i].IsLocked, 1, serializer) && isOk;
        }
        return isOk;
    }
    bool Load(PlacedPuzzleCard* obj, uint32_t count, Deserializer& serializer)
    {
        bool isOk = true;
        for (uint32_t i = 0; i < count; ++i)
        {
            isOk = Load(&obj[i].RefCard, 1, serializer) && isOk;
            isOk = Load(&obj[i].Position, 1, serializer) && isOk;
            isOk = Load(&obj[i].Rotation, 1, serializer) && isOk;
            isOk = Load(&obj[i].IsLocked, 1, serializer) && isOk;
        }
        return isOk;
    }
    bool Save(const PuzzleData* obj, uint32_t count, Serializer& serializer)
    {
        bool isOk = true;
        for (uint32_t i = 0; i < count; ++i)
        {
            isOk = Save(&obj[i].ID, 1, serializer) && isOk;
            isOk = Save(obj[i].PuzzleName, 64, serializer) && isOk;
            isOk = Save(&obj[i].WidthTiles, 1, serializer) && isOk;
            isOk = Save(&obj[i].HeightTiles, 1, serializer) && isOk;
            isOk = Save(&obj[i].AvailableCardCount, 1, serializer) && isOk;
            isOk = Save(obj[i].AvailableCards, 16, serializer) && isOk;
            isOk = Save(obj[i].PlacedCards, 256, serializer) && isOk;
            isOk = Save(obj[i].BackgroundTiles, 1024, serializer) && isOk;
            isOk = Save(&obj[i].GoalPositionCount, 1, serializer) && isOk;
            isOk = Save(obj[i].GoalPositions, 16, serializer) && isOk;
        }
        return isOk;
    }
    bool Load(PuzzleData* obj, uint32_t count, Deserializer& serializer)
    {
        bool isOk = true;
        for (uint32_t i = 0; i < count; ++i)
        {
            isOk = Load(&obj[i].ID, 1, serializer) && isOk;
            isOk = Load(obj[i].PuzzleName, 64, serializer) && isOk;
            isOk = Load(&obj[i].WidthTiles, 1, serializer) && isOk;
            isOk = Load(&obj[i].HeightTiles, 1, serializer) && isOk;
            isOk = Load(&obj[i].AvailableCardCount, 1, serializer) && isOk;
            isOk = Load(obj[i].AvailableCards, 16, serializer) && isOk;
            isOk = Load(obj[i].PlacedCards, 256, serializer) && isOk;
            isOk = Load(obj[i].BackgroundTiles, 1024, serializer) && isOk;
            isOk = Load(&obj[i].GoalPositionCount, 1, serializer) && isOk;
            isOk = Load(obj[i].GoalPositions, 16, serializer) && isOk;
        }
        return isOk;
    }
}
