#include "xphyspreset.h"

XPhysPreset::XPhysPreset()
    : XAsset()
    , mName()
    , mType(0)
    , mMass(0)
    , mBounce(0)
    , mFriction(0)
    , mBulletForceScale(0)
    , mExplosiveForceScale(0)
    , mSndAliasPrefix()
    , mPiecesSpreadFraction(0)
    , mPiecesUpwardVelocity(0)
    , mTempDefaultToCylinder(false)
{
    SetType(ASSET_TYPE_PHYSPRESET);
    SetName("Phys Preset");
}

XPhysPreset::~XPhysPreset()
{
    
}

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

        *aStream
            >> mType
            >> mMass
            >> mBounce
            >> mFriction
            >> mBulletForceScale
            >> mExplosiveForceScale;

        mSndAliasPrefix.ParsePtr(aStream, false);

        *aStream
            >> mPiecesSpreadFraction
            >> mPiecesUpwardVelocity
            >> mTempDefaultToCylinder;

        mName.ParseData(aStream);
        mSndAliasPrefix.ParseData(aStream);
    }
}

void XPhysPreset::Clear()
{
    mName.Clear();
    mType = 0;
    mMass = 0;
    mBounce = 0;
    mFriction = 0;
    mBulletForceScale = 0;
    mExplosiveForceScale = 0;
    mSndAliasPrefix.Clear();
    mPiecesSpreadFraction = 0;
    mPiecesUpwardVelocity = 0;
    mTempDefaultToCylinder = false;
}
