#include "xfxeffectdef.h"

XFxEffectDef::XFxEffectDef()
    : XAsset()
    , mName()
    , mFlags(0)
    , mTotalSize(0)
    , mMsecLoopingLife(0)
    , mElemDefCountLooping(0)
    , mElemDefCountOneShot(0)
    , mElemDefCountEmission(0)
    , mElemDefs()
{
    SetType(ASSET_TYPE_FX);
    SetName("Effect Def");
}

XFxEffectDef::~XFxEffectDef()
{
    
}

void XFxEffectDef::Clear()
{
    
}

void XFxEffectDef::ParseData(QDataStream *aStream)
{
    mName.ParsePtr(aStream, false);

    qint32 elemDefsPtr;
    *aStream
        >> mFlags
        >> mTotalSize
        >> mMsecLoopingLife
        >> mElemDefCountLooping
        >> mElemDefCountOneShot
        >> mElemDefCountEmission
        >> elemDefsPtr;

    mName.ParseData(aStream);

    if (elemDefsPtr)
    {
        for (int i = 0; i < mElemDefCountEmission + mElemDefCountOneShot + mElemDefCountLooping; i++)
        {
            XFxElemDef newElemDef;
            newElemDef.ParseData(aStream);
            mElemDefs.append(newElemDef);
        }
    }
}
