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

#pragma once

#include "glmTypes.h"
#include "glmIContext.h"

namespace glm
{
    /**
	* \brief Behavior Context -> init / updates / finish behaviors of an entity
	*
	* \author Golaem <dev@golaem.com>
	*/
    class BehaviorContext : public glm::IContext
    {

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

        BehaviorContext();
        virtual ~BehaviorContext();

        inline virtual bool registeredOnInitEntityType() override;
        virtual void onInitEntityType(int entityTypeIndex) override;

        inline virtual bool registeredOnInitGroupType() override;
        virtual void onInitGroupType(int groupTypeIndex) override;

        inline virtual bool registeredOnInitEntityComponent() override;
        virtual void onInitEntityComponent(int entityTypeIndex, int64_t entityIndex) override;

        inline virtual bool registeredOnUpdateEntityComponent() override;
        virtual void onUpdateEntityComponent(Time dt, int entityTypeIndex, int64_t entityIndex) override;

        inline virtual bool registeredOnFinishEntityComponent() override;
        virtual void onFinishEntityComponent(int entityTypeIndex, int64_t entityIndex) override;

        inline virtual bool registeredOnInitGroupComponent() override;
        virtual void onInitGroupComponent(int groupTypeIndex, int64_t groupIndex) override;

        inline virtual bool registeredOnUpdateGroupComponent() override;
        virtual void onUpdateGroupComponent(Time dt, int groupTypeIndex, int64_t groupIndex) override;

        inline virtual bool registeredOnFinishGroupComponent() override;
        virtual void onFinishGroupComponent(int groupTypeIndex, int64_t groupIndex) override;

        inline virtual bool registeredOnFinishEntityType() override;
        virtual void onFinishEntityType(int entityTypeIndex) override;

        inline virtual bool registeredOnFinishGroupType() override;
        virtual void onFinishGroupType(int groupTypeIndex) override;

        static ContextType::Value getStaticContextType();

    protected:
        virtual void setContextType() override;

    private:
        GLM_DISALLOW_COPY_AND_ASSIGN(BehaviorContext);

        //glm::PODArray<BehaviorGraph*> _entityTypeData; // should allocate the behaviorGraph at entityType creation. As we always have one, it is stored directly in EntityType
    };
    //-------------------------------------------------------------------------
    inline bool BehaviorContext::registeredOnInitEntityType()
    {
        return true;
    }

    //-------------------------------------------------------------------------
    inline bool BehaviorContext::registeredOnInitGroupType()
    {
        return true;
    }

    //-------------------------------------------------------------------------
    inline bool BehaviorContext::registeredOnInitEntityComponent()
    {
        return true;
    }

    //-------------------------------------------------------------------------
    inline bool BehaviorContext::registeredOnUpdateEntityComponent()
    {
        return true;
    }

    //-------------------------------------------------------------------------
    inline bool BehaviorContext::registeredOnFinishEntityComponent()
    {
        return true;
    }

    //-------------------------------------------------------------------------
    inline bool BehaviorContext::registeredOnInitGroupComponent()
    {
        return true;
    }

    //-------------------------------------------------------------------------
    inline bool BehaviorContext::registeredOnUpdateGroupComponent()
    {
        return true;
    }

    //-------------------------------------------------------------------------
    inline bool BehaviorContext::registeredOnFinishGroupComponent()
    {
        return true;
    }

    //-------------------------------------------------------------------------
    inline bool BehaviorContext::registeredOnFinishEntityType()
    {
        return true;
    }

    //-------------------------------------------------------------------------
    inline bool BehaviorContext::registeredOnFinishGroupType()
    {
        return true;
    }

    //-------------------------------------------------------------------------
    inline IContext::ContextType::Value BehaviorContext::getStaticContextType()
    {
        return ContextType::BEHAVIOR;
    }
} // namespace glm
