#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 Definition");
}

XFxEffectDef::~XFxEffectDef()
{
    
}

void XFxEffectDef::Clear()
{
    
}

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

    qint32 elemDefsPtr;
    mFlags = aStream->ParseInt32(QString("%1 flags").arg(GetName()));
    mTotalSize = aStream->ParseInt32(QString("%1 total size").arg(GetName()));
    mMsecLoopingLife = aStream->ParseInt32(QString("%1 msec looping life").arg(GetName()));
    mElemDefCountLooping = aStream->ParseInt32(QString("%1 elem def count looping").arg(GetName()));
    mElemDefCountOneShot = aStream->ParseInt32(QString("%1 elem def count one shot").arg(GetName()));
    mElemDefCountEmission = aStream->ParseInt32(QString("%1 elem def count emission").arg(GetName()));
    elemDefsPtr = aStream->ParseInt32(QString("%1 elem defs ptr").arg(GetName()));

    mName.ParseData(aStream);

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


