#pragma once
#include "Def.h"

namespace Generated
{
    struct PuzzleElementType
    {
        static constexpr int32_t EntryCount = 8;
        enum Enum : int32_t
        {
            None,
            WaterIn,
            WaterGoal,
            WaterChannel,
            ElectricIn,
            ElectricGoal,
            Blocked,
            Bridge,
        };
        static constexpr char EntryNames[EntryCount][64]
        {
            "None",
            "WaterIn",
            "WaterGoal",
            "WaterChannel",
            "ElectricIn",
            "ElectricGoal",
            "Blocked",
            "Bridge",
        };
        static constexpr char GameName[EntryCount][64]
        {
            "Empty",
            "Water Source",
            "Water Goal",
            "Water Channel",
            "Electricity Source",
            "Electricity Goal",
            "Blocked",
            "Bridge",
        };
    };
    struct PuzPos
    {
        int8_t X = {};
        int8_t Y = {};
    };
    struct ElemPos
    {
        PuzPos Position = {};
        uint8_t ElemIdx = {};
    };
    struct PuzzleNode
    {
        PuzzleElementType::Enum PlacedTypes[4] = {};
    };
    struct StaticPuzzleCard
    {
        PuzzleNode Nodes[4] = {};
        uint16_t ModelHandle = {};
    };
    struct StaticPuzzleCardHandle
    {
        uint16_t Idx = UINT16_MAX;
    };
    struct StaticPuzzleData
    {
        StaticPuzzleCard Cards[64] = {};
    };
    struct PuzzleCardStack
    {
        StaticPuzzleCardHandle RefCard = {};
        uint8_t MaxAvailableCount = {};
        uint8_t UsedCount = {};
    };
    struct PlacedPuzzleCard
    {
        StaticPuzzleCardHandle RefCard = {};
        PuzPos Position = {};
        uint8_t Rotation = {};
        bool IsLocked = {};
    };
    struct PuzzleData
    {
        uint8_t WidthTiles = {};
        uint8_t HeightTiles = {};
        uint32_t AvailableCardCount = {};
        PuzzleCardStack AvailableCards[16] = {};
        uint32_t PlacedCardCount = {};
        PlacedPuzzleCard PlacedCards[256] = {};
        PuzzleNode PlacedNodes[1024] = {};
        uint32_t GoalPositionCount = {};
        ElemPos GoalPositions[16] = {};
        char PuzzleName[64] = {};
    };
    bool Save(const PuzzleElementType::Enum* obj, uint32_t count, Serializer& serializer);
    bool Save(const PuzPos* obj, uint32_t count, Serializer& serializer);
    bool Save(const ElemPos* obj, uint32_t count, Serializer& serializer);
    bool Save(const PuzzleNode* obj, uint32_t count, Serializer& serializer);
    bool Save(const StaticPuzzleCard* obj, uint32_t count, Serializer& serializer);
    bool Save(const StaticPuzzleCardHandle* obj, uint32_t count, Serializer& serializer);
    bool Save(const StaticPuzzleData* obj, uint32_t count, Serializer& serializer);
    bool Save(const PuzzleCardStack* obj, uint32_t count, Serializer& serializer);
    bool Save(const PlacedPuzzleCard* obj, uint32_t count, Serializer& serializer);
    bool Save(const PuzzleData* obj, uint32_t count, Serializer& serializer);
}
