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

#pragma once

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

namespace glm
{
    class GLM_SDK_API BoolTrigger : public AbstractTrigger
    {
    public:
        bool _value;

        typedef SmartPointer<BoolTrigger> SP;

        GLM_CLASS_STAT_ID( glm::MemoryStatIds::Simulation);

        BoolTrigger(bool value = true);
        virtual ~BoolTrigger();

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

    protected:
        inline virtual bool doCall(int64_t /*index*/, AbstractBehavior* /*behavior*/, BehaviorGraph& /*behaviorGraph*/, bool /*isAttached*/);

        // cloning
        friend class CloneFactory;
        virtual void cloneImpl(AbstractTrigger* clone, CloneFactory* factory) const override;
        inline virtual BoolTrigger* create() const override;
    };

    //-------------------------------------------------------------------------
    inline bool BoolTrigger::doCall(int64_t /*index*/, AbstractBehavior* /*behavior*/, BehaviorGraph& /*behaviorGraph*/, bool /*isAttached*/)
    {
        return _value;
    }

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