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

#pragma once

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

namespace glm
{
    // Boolean callback which returns true depending on a probability
    class GLM_SDK_API FadeTrigger : public AbstractTrigger
    {
    public:
        typedef SmartPointer<FadeTrigger> SP;

    private:
        Ramp _fadeRamp; //!< Fade function
        float _fadeDuration;

        glm::PODArray<float> _internalCounter; //!< Per entity counter
    public:
		GLM_CLASS_STAT_ID( glm::MemoryStatIds::Simulation);

        FadeTrigger();
        FadeTrigger(const Ramp& fadeRamp, int fadeDuration);
        virtual ~FadeTrigger();

        virtual void allocate(BehaviorGraph& behaviorGraph) override;
        virtual void resize(BehaviorGraph& behaviorGraph) override;
		virtual bool isShareable() override;

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

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

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