/***************************************************************************
*                                                                          *
*  Copyright (C) Golaem S.A.  All Rights Reserved.                         *
*                                                                          *
****************************************************************************/

#pragma once

#include "glmRTTI.h"
#include "glmCoreAPI.h"
#include "glmAccessorsAttribute.h"

#include <glmGolaemCharacterDeclarations.h> // GolaemCharacter declarations

namespace glm
{
    struct AssetUnitV2;
    struct AssetGroupV3;

    class GLM_CORE_API AssetUnitV3
    {
        GLM_RTTI("0ff8b69b-c393-4729-83fb-8319a00fc24b", AssetUnitV3, addAttributes);

    public:
        GLM_CLASS_STAT_ID( glm::MemoryStatIds::GolaemShared);

        int _meshAssetIdx;
        int _assetGroupIdx;
        int _skeletonOverrideIdx;
        int _blindDataOverrideIdx;
		int _physicsOverrideIdx;
        int _deepDeformerAssetIdx;

		AssetUnitV3();
        ~AssetUnitV3();

        void createFromV2(const AssetUnitV2& assetUnitV2);

    protected:
        /**
		* \brief Inspection needed method declaring the inspectable attributes.
		*/
        static void addAttributes();
    };

    /**
	* \brief Group of assets
	*/
    class GLM_CORE_API AssetGroupV4
    {
        GLM_RTTI("eb022dbd-570e-4546-96bc-de8a639fa0df", AssetGroupV4, addAttributes);

    public:
        GLM_CLASS_STAT_ID( glm::MemoryStatIds::GolaemShared);

        /// The name of the group
        glm::GlmString _name;

        /// The children
        glm::Array<AssetUnitV3> _children;

        AssetGroupWeightType::Value _weightType;
        glm::GlmString _weightAttributeName;

        glm::PODArray<float> _weights; // if weights are empty all the children are selected

        glm::Array<AssetUnitV3> _excludedAssets;

		AssetGroupV4();
        ~AssetGroupV4();

        void createFromV3(const AssetGroupV3& AssetGroupV3);

        /**
		* \brief Erases a child from this group
		*/
        void eraseChild(unsigned int childIndex);

        void getAllMeshAssets(glm::PODArray<int>& meshAssets, const GolaemCharacter& character) const;

    protected:
        /**
		* \brief Inspection needed method declaring the inspectable attributes.
		*/
        static void addAttributes();

        int getWeightTypeAsInt() const;
        void setWeightTypeFromInt(int value);
    };
} // namespace glm
