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

void Bullet::addComponent(std::shared_ptr<Component> component)
{
	components.push_back(component);
}

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

	deltaPosition.x += direction.x * bulletSpeed;
	deltaPosition.y += direction.y * bulletSpeed;
	//physics->rigidBody.position = position;

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

void Bullet::render(const std::shared_ptr<Camera>& camera)
{
	Entity::render(camera);

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

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