/**
 *  Triangles
 *  Copyright (C) 2016 POSITIVE MENTAL ATTITUDE
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, version 3 of the License.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#pragma once

#include <SFML/Audio.hpp>
#include "Triangle.hpp"
#include "InputTarget.hpp"
#include "Utility.hpp"
#include "Bullet.hpp"
#include "Collidable.hpp"
#include "Context.hpp"
#include "Particle.hpp"
#include "Circle.hpp"
#include "Lantern.hpp"

/**
 * @class Player
 * @author POSITIVE MENTAL ATTITUDE
 * @date 06/09/16
 * @file Player.hpp
 * @brief TODO Player class is in fact a class for everything related to a moving triangles.
 * This has to be moved to an Entity class or something
 * and leave the camera and input stuff to the Player class.
 */
class Player: public Triangle, public InputTarget<int>, public Collidable, public Lantern
{
	public:
		enum Type {
			Tropical = 0, Illuminati, Nevermore
		};
		Player();
		void update(sf::Time delta);
		void setTexture(sf::Texture& texture) override;
		/**
		 * @brief 
		 * @param foreground
		 * @return Returns true if the target died. 
		 */
		
		bool checkCollision(Foreground& foreground, bool pixel = true);
		const bool isDead() const;
		const bool hasWon() const;
		Rect getBounds();
		sf::Image _image;
		sf::Texture _innerTexture;
		void setContext(Context* context);
		const float getHullLeft() const;
		void setType(Type type);

	private:
		void keyboardControls(sf::Time delta);
		Context* _context;
		std::vector<Bullet> _bullets;
		sf::Clock _bulletTimer;
		InputMap<int> _inputMap;
		float _movement, _movementSpeed, _movementMomentum, _movementAcceleration, _movementSuppresion;
		float _rotation, _rotationSpeed, _rotationMomentum, _rotationAcceleration, _rotationSuppresion;
		bool _canStrafe;
		float _strafe;
		bool _hit;
		bool _dead;
		bool _won;
		virtual void draw(sf::RenderTarget& target, sf::RenderStates states) const final override;
		sf::Sound _glass;
		sf::Sound _deathSound;
		//ParticleSystem _particleSystem;
		int _ammo;
		Type _type;
		Circle _life;
		Circle _mana;
		int _lightType;
};