#pragma once

#include "render/Renderer.h"
#include "render/TextureManager.h"
#include <memory>
#include "SparkEmitter.h"

namespace ZL {

	class Projectile {
	public:
		Projectile();
		~Projectile() = default;

		void init(const Vector3f& startPos, const Vector3f& startVel, float lifeMs, float size, std::shared_ptr<Texture> tex, Renderer& renderer);
		void update(float deltaMs, Renderer& renderer);
		void draw(Renderer& renderer) const;

		bool isActive() const { return active; }

		Vector3f getPosition() const { return pos; }
		void deactivate() { active = false; }

		SparkEmitter projectileEmitter;
	private:
		Vector3f pos;
		Vector3f vel;
		float life;
		float maxLife;
		bool active;
		float size;
		VertexRenderStruct mesh;
		std::shared_ptr<Texture> texture;

		void rebuildMesh(Renderer& renderer);
	};

} // namespace ZL