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

#pragma once

#include "glmSDKAPI.h"
#include <glmAbstractTrigger.h>

namespace glm
{
    class PlayAnimationBehavior;

    class GLM_SDK_API MotionTimeTrigger : public AbstractTrigger
    {
    public:
        typedef SmartPointer<MotionTimeTrigger> SP;

    private:
        glm::GlmString _triggerName;
		const PlayAnimationBehavior* _playAnimationBe;

        double _percent;      //!< Time representation in percent of the motion duration (between [0., +infinite[)
        Time _seconds;        //!< Time representation in seconds
        unsigned int _frames; //!< Time representation in keyframe number

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

        MotionTimeTrigger();
        MotionTimeTrigger(const PlayAnimationBehavior* playAnimationBe, const double& percent, const Time& seconds, unsigned int frames);
        virtual ~MotionTimeTrigger();
		virtual bool isShareable() override;

    protected:
        // cloning
        friend class CloneFactory;
        inline virtual MotionTimeTrigger* create() const override;

        virtual bool doCall(int64_t index, AbstractBehavior* behavior, BehaviorGraph& behaviorGraph, bool isAttached) override;
    };

    //-------------------------------------------------------------------------
    inline MotionTimeTrigger* MotionTimeTrigger::create() const
    {
        MotionTimeTrigger* myNewMotionTimeTrigger = GLM_NEW(MotionTimeTrigger, myNewMotionTimeTrigger, getClassMemoryStatId());
        return myNewMotionTimeTrigger;
    }
} // namespace glm
