#include "xpathnodedynamic.h"

XPathNodeDynamic::XPathNodeDynamic()
    : XAsset()
    , mOwner()
    , mFreeTime(0)
    , mValidTime(3)
    , mPlayerLostTime(0)
    , mLinkCount(0)
    , mOverlapCount(0)
    , mTurretEntNumber(0)
    , mUserCount(0)
{
    SetName("Path Node Dynamic");
}

XPathNodeDynamic::~XPathNodeDynamic()
{

}

void XPathNodeDynamic::ParseData(XDataStream *aStream) {
    if (GetPtr() == -1) {
        mOwner.ParseData(aStream);

        mFreeTime = aStream->ParseInt32(QString("%1 free time").arg(GetName()));

        mValidTime[0] = aStream->ParseInt32(QString("%1 valid time 0").arg(GetName()));
        mValidTime[1] = aStream->ParseInt32(QString("%1 valid time 1").arg(GetName()));
        mValidTime[2] = aStream->ParseInt32(QString("%1 valid time 2").arg(GetName()));

        mPlayerLostTime = aStream->ParseInt32(QString("%1 player lost time").arg(GetName()));

        mLinkCount = aStream->ParseInt16(QString("%1 link count").arg(GetName()));
        mOverlapCount = aStream->ParseInt16(QString("%1 overlap count").arg(GetName()));
        mTurretEntNumber = aStream->ParseInt16(QString("%1 turret ent number").arg(GetName()));
        mUserCount = aStream->ParseInt16(QString("%1 user count").arg(GetName()));
    }
}

void XPathNodeDynamic::Clear()
{
    mFreeTime = 0;
    mValidTime = QVector<int>();
    mPlayerLostTime = 0;
    mLinkCount = 0;
    mOverlapCount = 0;
    mTurretEntNumber = 0;
    mUserCount = 0;
}
