#ifndef PROJECTILECOMPONENT_HPP
#define PROJECTILECOMPONENT_HPP

#include "TinyMath.hpp"
#include "RigidbodyComponent.hpp"
#include <string>

/**
 * A Component implementation to treat a GameObject as a projectile.
 */
class ProjectileComponent : public Component
{
public:
    /**
     * Construct a new Projectile Component object.
     *
     * @param _projectile the TransformComponent of the parent GameObject
     * @param _target the TransformComponent of the target the Projectile is fired at
     * @param _homing whether the ProjectileComponent will seek out the target
     * @param _var if homing, the speed of the projectile. Otherwise, the angle the ProjectileComponent is fired at
     */
    ProjectileComponent(TransformComponent *_projectile, TransformComponent *_target, bool _homing, float _var);

    /**
     * Destroy the Projectile Component object
     */
    ~ProjectileComponent();

    void Update(SDL_Event e, int frame, std::vector<std::string> broadcastList) override;

    void Render(SDL_Renderer *ren) override;

private:
    TransformComponent *projectile;
    TransformComponent *target; /** the TransformComponent being attacked */
    bool homing;
    float speed;
    float angle;

    float gravity = 10; /** the force of gravity used for initial firing of the ProjectileComponent */
};

#endif
