#pragma once
#include <render/core/buffer/frameBuffer.h>
#include "def.h"
#include <string>
#include <common.h>

namespace render{
namespace fx{
    class object
    {
    friend class effect;
    public:
        vec2f pos;
        std::string id;
        object() = default;
        object(effect *parent){_parent = parent;}
        virtual ~object();
        object(const object&) = delete;

        virtual void start() = 0;
        virtual void stop() = 0;

        virtual void update() noexcept = 0;
        void draw() noexcept;
        //virtual void draw() noexcept = 0;

        float time, workTime;
    protected:

        render::frameBuffer *fbo = 0;

        virtual void _draw() noexcept = 0;
        bool _running;
        float _oldTime;
        effect *_parent;
        collection *_root;
    };

    class objectInfo
    {
    public:
        vec2f pos;
        std::string id;
        collection *root;
        virtual object *create(float, effect*) = 0;

    };

    class objectRef
    {
    public:
        objectRef() = default;
        objectRef(const objectRef &r)
        {
            obj = r.obj;
            workTime = r.workTime;
            position = r.position;
            angle = r.angle;
        }
        ~objectRef()
        {
            delete obj;
        }
        object *obj = nullptr;
        float workTime;
        _loopedParam<vec2f> position;
        _loopedParam<float> angle;
    };

    class objectRefInfo
    {
    public:
        std::string id;
        float workTime;
        _emitterParam<vec2f> position;
        _emitterParam<float> angle;
    };
}}
