#pragma once

#define RECT_BASE typeid(TSE::RectBase).name()

#include "elements/BehaviourScript.hpp"
#include "Rect.hpp"
#include "Vector2.hpp"
#include "Mesh.hpp"

namespace TSE
{
    class RectBase : public BehaviourScript
    {
    private:
        Rect lastAnchors = Rect(0.5f, 0.5f, 0.5f, 0.5f);
        Vector2 lastSize = Vector2(0,0);
        Vector2 lastPivit = Vector2(0.5f,0.5f);
        Mesh meshCach;

        Vector2 tmpSize;

    public:
        Rect anchors = Rect(0.5f,0.5f, 0.5f, 0.5f); //streching in parent
        Vector2 size = Vector2(1,1); //size
        Vector2 pivit = Vector2(0.5f,0.5f); //positioning in parent

        RectBase();
        Mesh* GetMesh();
        void SetCustomUVs(const std::vector<Vector2>& uvs);

    private:
        void OnParentChanged(RectBase* parent);
        void RecalculateMesh(RectBase *parent);

    public:
        void OnUpdate() override;
        inline const char* GetName() override
        {
            return "Rect Base";
        }
    };
} // namespace TSE
