#include "xsunflare.h"

XSunFlare::XSunFlare()
    : XAsset()
    , mHasValidData(false)
    , mSpriteMaterial()
    , mFlareMaterial()
    , mSpriteSize(0.0f)
    , mFlareMinSize(0.0f)
    , mFlareMinDot(0.0f)
    , mFlareMaxSize(0.0f)
    , mFlareMaxDot(0.0f)
    , mFlareMaxAlpha(0.0f)
    , mFlareFadeInTime(0)
    , mFlareFadeOutTime(0)
    , mBlindMinDot(0.0f)
    , mBlindMaxDot(0.0f)
    , mBlindMaxDarken(0.0f)
    , mBlindFadeInTime(0)
    , mBlindFadeOutTime(0)
    , mGlareMinDot(0.0f)
    , mGlareMaxDot(0.0f)
    , mGlareMaxLighten(0.0f)
    , mGlareFadeInTime(0)
    , mGlareFadeOutTime(0)
    , mSunFxPosition()
{
    SetName("Sun Flare");
}

XSunFlare::~XSunFlare()
{
    
}

void XSunFlare::ParseData(XDataStream *aStream)
{
    *aStream
        >> mHasValidData;

    aStream->skipRawData(3);

    mSpriteMaterial.ParsePtr(aStream, false);
    mFlareMaterial.ParsePtr(aStream, false);

    *aStream
        >> mSpriteSize
        >> mFlareMinSize
        >> mFlareMinDot
        >> mFlareMaxSize
        >> mFlareMaxDot
        >> mFlareMaxAlpha
        >> mFlareFadeInTime
        >> mFlareFadeOutTime
        >> mBlindMinDot
        >> mBlindMaxDot
        >> mBlindMaxDarken
        >> mBlindFadeInTime
        >> mBlindFadeOutTime
        >> mGlareMinDot
        >> mGlareMaxDot
        >> mGlareMaxLighten
        >> mGlareFadeInTime
        >> mGlareFadeOutTime
        >> mSunFxPosition[0]
        >> mSunFxPosition[1]
        >> mSunFxPosition[2];

    mSpriteMaterial.ParseData(aStream);
    mFlareMaterial.ParseData(aStream);
}

void XSunFlare::Clear()
{
    mHasValidData = false;
    mSpriteMaterial.Clear();
    mFlareMaterial.Clear();
    mSpriteSize = 0.0f;
    mFlareMinSize = 0.0f;
    mFlareMinDot = 0.0f;
    mFlareMaxSize = 0.0f;
    mFlareMaxDot = 0.0f;
    mFlareMaxAlpha = 0.0f;
    mFlareFadeInTime = 0;
    mFlareFadeOutTime = 0;
    mBlindMinDot = 0.0f;
    mBlindMaxDot = 0.0f;
    mBlindMaxDarken = 0.0f;
    mBlindFadeInTime = 0;
    mBlindFadeOutTime = 0;
    mGlareMinDot = 0.0f;
    mGlareMaxDot = 0.0f;
    mGlareMaxLighten = 0.0f;
    mGlareFadeInTime = 0;
    mGlareFadeOutTime = 0;
    mSunFxPosition = QVector3D();
}
