#include "gameplay/weapons/bullet.h"
#include "utility/component.h"

#include "utility/logger.h"

void Bullet::addComponent(Component* component)
{
	components.push_back(component);
}

void Bullet::update(double deltaTime)
{
	Entity::update(deltaTime);

	deltaPosition.x += direction.x * bulletSpeed;
	deltaPosition.y += direction.y * bulletSpeed;

	//LOG(INFO, "( {}, {}, {} )", deltaPosition.x, deltaPosition.y, deltaPosition.z);
	//physics->rigidBody.position = position;

	for (auto& component : components)
		component->update();
}

void Bullet::draw()
{
	Entity::draw();

	for (auto& component : components)
	{
		component->play();
		component->bind();
		component->render();
	}
}

Bullet::~Bullet()
{
	components.clear();
}
