#ifndef _H_GAMEACTOR_H
#define _H_GAMEACTOR_H

#include <memory>
#include <unordered_map>
#include <SDL_timer.h>
#include <optional>
#include <span>

#include "gameplay/entity.h"
#include "gameplay/weapons/weapon.h"
#include "utility/mousestate.h"

#include <utility/component.h>

class AI;
class ISceneContext;

// TODO: Add ammo system, then work on some basic UI design

class GameActor : public Entity
{
public:
	GameActor(ISceneContext* scene, const unsigned shaderID) : Entity(shaderID), sceneContext(scene) {}
	~GameActor();

	void addComponent(std::unique_ptr<Component> component);
	void pickupWeapon(std::unique_ptr<Weapon> weapon);
	void update(double deltaTime) override;
	void draw() override;

	Weapon* getHeldWeapon() const;
	std::span<Weapon*> getAllWeapons();

	void setRotation(const float& rotation) override;

	void moveUp();
	void moveDown();
	void moveLeft();
	void moveRight();

	// Top down shooter controls, mostly for the player to use in top down shooting sections
	void moveForward();
	void moveBackward();
	void strafeLeft();
	void strafeRight();
	void fireWeapon() const;
	void cycleUpWeapons();
	void cycleDownWeapons();
	void cycleWeapons(const MouseState&);
	void followMouse(const MouseState&);
private:
	std::vector<std::unique_ptr<Component>> components;
	std::vector<std::unique_ptr<Weapon>> weapons;
	std::vector<Weapon*> weaponCache;
	size_t currentWeaponIndex = 0;

	ISceneContext* sceneContext;
};

#endif //_H_GAMEACTOR_H
