#include "xcomprimarylight.h"

XComPrimaryLight::XComPrimaryLight()
    : XAsset()
    , mType(-1)
    , mCanUseShadowMap(-1)
    , mExponent(-1)
    , mUnused(-1)
    , mColor(0, 0, 0)
    , mDir(0, 0, 0)
    , mOrigin(0, 0, 0)
    , mRadius(0.0)
    , mCosHalfFovOuter(0.0)
    , mCosHalfFovInner(0.0)
    , mCosHalfFovExpanded(0.0)
    , mRotationLimit(0.0)
    , mTranslationLimit(0.0)
    , mDefName(new XString())
{

}

XComPrimaryLight::~XComPrimaryLight()
{

}

void XComPrimaryLight::Clear()
{
    delete mDefName;
}

XComPrimaryLightArray *XComPrimaryLight::ParseArray(QDataStream *aStream, int aCount)
{
    XComPrimaryLightArray* result = new XComPrimaryLightArray();

    for (int i = 0; i < aCount; i++)
    {
        XComPrimaryLight* comPrimaryLight = new XComPrimaryLight();
        comPrimaryLight->ParseData(aStream);

        result->append(comPrimaryLight);
    }

    return result;
}

void XComPrimaryLight::ParseData(QDataStream *aStream)
{
    *aStream
        >> mType
        >> mCanUseShadowMap
        >> mExponent
        >> mUnused
        >> mColor
        >> mDir
        >> mOrigin
        >> mRadius
        >> mCosHalfFovOuter
        >> mCosHalfFovInner
        >> mCosHalfFovExpanded
        >> mRotationLimit
        >> mTranslationLimit;

    mDefName->ParseData(aStream);
}

quint8 XComPrimaryLight::GetType() const
{
    return mType;
}

quint8 XComPrimaryLight::GetCanUseShadowMap() const
{
    return mCanUseShadowMap;
}

quint8 XComPrimaryLight::GetExponent() const
{
    return mExponent;
}

quint8 XComPrimaryLight::GetUnused() const
{
    return mUnused;
}

QColor XComPrimaryLight::GetColor() const
{
    return mColor;
}

QVector3D XComPrimaryLight::GetDir() const
{
    return mDir;
}

QVector3D XComPrimaryLight::GetOrigin() const
{
    return mOrigin;
}

float XComPrimaryLight::GetRadius() const
{
    return mRadius;
}

float XComPrimaryLight::GetCosHalfFovOuter() const
{
    return mCosHalfFovOuter;
}

float XComPrimaryLight::GetCosHalfFovInner() const
{
    return mCosHalfFovInner;
}

float XComPrimaryLight::GetCosHalfFovExpanded() const
{
    return mCosHalfFovExpanded;
}

float XComPrimaryLight::GetRotationLimit() const
{
    return mRotationLimit;
}

float XComPrimaryLight::GetTranslationLimit() const
{
    return mTranslationLimit;
}

XString* XComPrimaryLight::GetDefName() const
{
    return mDefName;
}

void XComPrimaryLight::SetType(quint8 aType)
{
    mType = aType;
}

void XComPrimaryLight::SetCanUseShadowMap(quint8 aCanUseShadowMap)
{
    mCanUseShadowMap = aCanUseShadowMap;
}

void XComPrimaryLight::SetExponent(quint8 aExponent)
{
    mExponent = aExponent;
}

void XComPrimaryLight::SetUnused(quint8 aUnused)
{
    mUnused = aUnused;
}

void XComPrimaryLight::SetColor(const QColor aColor)
{
    mColor = aColor;
}

void XComPrimaryLight::SetDir(const QVector3D aDir)
{
    mDir = aDir;
}

void XComPrimaryLight::SetOrigin(const QVector3D aOrigin)
{
    mOrigin = aOrigin;
}

void XComPrimaryLight::SetRadius(float aRadius)
{
    mRadius = aRadius;
}

void XComPrimaryLight::SetCosHalfFovOuter(float aCosHalfFovOuter)
{
    mCosHalfFovOuter = aCosHalfFovOuter;
}

void XComPrimaryLight::SetCosHalfFovInner(float aCosHalfFovInner)
{
    mCosHalfFovInner = aCosHalfFovInner;
}

void XComPrimaryLight::SetCosHalfFovExpanded(float aCosHalfFovExpanded)
{
    mCosHalfFovExpanded = aCosHalfFovExpanded;
}

void XComPrimaryLight::SetRotationLimit(float aRotationLimit)
{
    mRotationLimit = aRotationLimit;
}

void XComPrimaryLight::SetTranslationLimit(float aTranslationLimit)
{
    mTranslationLimit = aTranslationLimit;
}

void XComPrimaryLight::SetDefName(XString* aDefName)
{
    mDefName = aDefName;
}

void XComPrimaryLight::SetDefName(const QString aDefName)
{
    if (mDefName != nullptr) {
        mDefName->SetString(aDefName);
    }
}
