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

#pragma once

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

namespace glm
{
    class AbstractBehavior;

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

    private:
        const AbstractBehavior* _behavior; //!< Source behavior
        Time _behaviorTime;          //!< Time representation in seconds
    public:
        GLM_CLASS_STAT_ID( glm::MemoryStatIds::Simulation);

        BehaviorTimeTrigger();
        BehaviorTimeTrigger(const AbstractBehavior* behavior, const Time& behaviorTime);
        virtual ~BehaviorTimeTrigger();

		virtual bool isShareable() override;

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

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

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