//	Turret.h - A stationary turret which fires at nearby players/npcs of a
//			   different colour.
//  ----------------------------------------------------------------------------
//	This file is part of 'NiallsAVLib', base code for any kind of audiovisual
//	apps.
//	Copyright (C) 2012  Niall Moody
//	
//	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, either version 3 of the License, or
//	(at your option) any later version.
//
//	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/>.
//	----------------------------------------------------------------------------

#ifndef TURRET_H_
#define TURRET_H_

#include "NPC.h"

class Tank;

///	A stationary turret which fires at nearby players/npcs of a different colour.
class Turret : public NPC
{
  public:
	///	Constructor.
	/*!
		\param pos The turret's position.
		\param col The turret's colour.
		\param dec True if it's currently December (in which case the turret is
		drawn as a snowman).
	 */
	Turret(const TwoFloats& pos, const ThreeFloats& col, bool dec);
	///	Destructor.
	~Turret();

	///	Moves the npc.
	void update(GamePlayState& state);
	///	Draws the npc.
	void draw(shared_ptr<Drawer>& d, float timestepInterp);

	///	Returns true if the npc is dead.
	bool getDead() {return (armour <= 0.0f);};

	///	Returns true if this entity wants to know when it collides with the named entity type.
	bool interestedInCollisionsWith(const std::wstring& entity) const;
	///	Called when this entity collides with another.
	bool collide(const shared_ptr<Collidable>& other, GamePlayState& state);

	///	Returns the entity's position.
	const TwoFloats& getPosition() const {return position;};
	///	Returns the entity's radius.
	float getRadius() const {return 20.0f;};
	///	Returns the entity's colour.
	const ThreeFloats& getColour() const {return colour;};
	///	Returns true if other entities can pass through this one.
	bool getIncorporeal() const {return false;};
  private:
	///	The turret's position.
	TwoFloats position;
	///	The turret's colour.
	ThreeFloats colour;
	///	Whether it's december or not.
	bool december;
	///	The turret's health.
	float armour;
	///	The radius of the turret's search circle.
	const float searchRadius;

	///	The turret's gun's current angle.
	float angle;
	///	The turret's target (if it's a tank).
	shared_ptr<Tank> targetTank;
	///	The turret's target (if it's an npc).
	shared_ptr<NPC> targetNpc;
	///	Used to periodically update the turret's target.
	int angleCount;

	///	Used to fire.
	int fireCount;
};

#endif
