#ifndef _H_GAMEACTOR_H
#define _H_GAMEACTOR_H

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

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

class Component;
class AI;
class Weapon;
class EventManager;

// TODO: Finish weapon cycling code and add default weapon to every actor
// TODO: Add ammo system, then work on some basic UI design

class GameActor : public Entity
{
public:
	GameActor(const std::shared_ptr<Shader>& shader) : Entity(shader) {}
	~GameActor();

	void addComponent(std::shared_ptr<Component> component);
	void pickupWeapon(std::shared_ptr<Weapon> weapon);
	void hookEventManager(std::shared_ptr<EventManager> eventManager);
	void update(float deltaTime) override;
	void render(const std::shared_ptr<Camera>& camera) override;

	const std::optional<std::shared_ptr<Weapon>> getHeldWeapon() const;

	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:
	using component_vector_t = std::vector<std::shared_ptr<Component>>;
	using weapon_vector_t = std::vector<std::shared_ptr<Weapon>>;

	component_vector_t components;
	weapon_vector_t weapons;
	size_t currentWeaponIndex = 0;
	std::shared_ptr<EventManager> eventManager;
};

#endif //_H_GAMEACTOR_H