/********************\
|  Copyright 2024,   |
|       Ulysse Cura  |
\********************/

////////////////////////////////////////////////////
//                                                //
//   Composant de transformation, sert a donner   //
// une position, dimension, etc... à une entitée. //
//                                                //
////////////////////////////////////////////////////

#ifndef TRANSFORM_HPP
#define TRANSFORM_HPP

#include "ECS.hpp"
#include "../Vector2D.hpp"

struct TransformComponent : public Component {
    TransformComponent()
    {
        position.zero();
    }

    TransformComponent(Vector2D<float> pos, Vector2D<int> dim, int sc, int spd) : position(pos), speed(spd), dimension(dim), scale(sc)
    {}

    void init() override
    {
        velocity.zero();
    }

    void update() override
    {
        position += (velocity * static_cast<float>(speed));

        entity->draw_priority = static_cast<int>(position.y + static_cast<float>(dimension.y * scale));
    }

    Vector2D<float> position;

    Vector2D<float> velocity;
    int speed {1};

    Vector2D<int> dimension {32, 32};
    int scale {1};
};

#endif
