#include "xmodelpieces.h"

XModelPieces::XModelPieces()
    : XAsset()
    , mName()
    , mNumPieces(0)
    , mPieces()
{
    SetType(ASSET_TYPE_XMODELPIECES);
    SetName("Model Pieces");
}

XModelPieces::~XModelPieces()
{
    
}

void XModelPieces::ParseData(QDataStream *aStream)
{
    if (GetPtr() == -1)
    {
        mName.ParsePtr(aStream, false);

        qint32 piecesPtr;
        *aStream
            >> mNumPieces
            >> piecesPtr;

        mName.ParseData(aStream);

        if (piecesPtr)
        {
            for (int i = 0; i < mNumPieces; i++)
            {
                XModelPiece newPiece;
                newPiece.ParseData(aStream);
                mPieces.append(newPiece);
            }
        }
    }
}

void XModelPieces::Clear()
{
    mName.Clear();
    mNumPieces = 0;
    mPieces.clear();
}
