// IAEngine: 2D Game Engine by IA
// Copyright (C) 2025 IASoft (PVT) LTD (oss@iasoft.dev)
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <https://www.gnu.org/licenses/>.

#pragma once

#include <IAEngine/Components/IComponent.hpp>

namespace ia::iae
{
    class TextureComponent : public IComponent
    {
      public:
        TextureComponent(IN Node2D *node);

      public:
        VIRTUAL VOID Draw();
        VIRTUAL VOID DebugDraw();
        
        VIRTUAL VOID Update();
        VIRTUAL VOID FixedUpdate();

      public:
        VOID SetTexture(IN Handle image);

        Handle GetTexture() CONST
        {
            return m_texture;
        }

        Vec2 &PositionOffset()
        {
            return m_positionOffset;
        }

        Vec2 &ScaleOffset()
        {
            return m_scaleOffset;
        }

        FLOAT32 &RotationOffset()
        {
            return m_rotationOffset;
        }

        Vec2 &TextureOffset()
        {
            return m_textureOffset;
        }

        Color &ColorOverlay()
        {
            return m_colorOverlay;
        }

        BOOL &IsFlippedH()
        {
            return m_isFlippedH;
        }

        BOOL &IsFlippedV()
        {
            return m_isFlippedV;
        }

        BOOL &IsCameraRelative()
        {
            return m_isCameraRelative;
        }

        Vec2 &DrawnSize()
        {
            return m_drawnSize;
        }

      private:
        BOOL m_isFlippedH{};
        BOOL m_isFlippedV{};
        BOOL m_isCameraRelative{true};
        Vec2 m_positionOffset{};
        Vec2 m_textureOffset{};
        Vec2 m_scaleOffset{1.0f, 1.0f};
        FLOAT32 m_rotationOffset{};
        Color m_colorOverlay{};
        Vec2 m_drawnSize{};

        Vec2 m_textureExtent{};
        Handle m_texture{0};
    };
} // namespace ia::iae