//	Mine.h - The mine class.
//  ----------------------------------------------------------------------------
//	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 MINE_H_
#define MINE_H_

#include "Collidable.h"
#include "c0xHeaders.h"

class Drawer;
class Tank;

///	The mine class.
class Mine : public Collidable
{
  public:
	///	Constructor.
	Mine(const TwoFloats& pos,
		 const std::wstring& parent,
		 const ThreeFloats& col);
	///	Destructor.
	~Mine();

	///	Updates the mine's internal state.
	bool update();
	///	Draws the mine.
	void draw(shared_ptr<Drawer>& d, float timestepInterp);

	///	Makes it so the mine can be triggered by bullets.
	void setTriggeredByBullets();
	///	Draws the mine as a pickup.
	void setCamouflage(bool present = false);

	///	Returns the name of the tank (etc.) which dropped this mine.
	const std::wstring& getOwner() const {return owner;};
	///	Returns the mine's colour.
	const ThreeFloats& getColour() const {return colour;};

	///	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 radius;};
	///	Returns true if other entities can pass through this one.
	bool getIncorporeal() const {return (active > 0);};
  private:
	///	The mine's position.
	TwoFloats position;
	///	The name of the tank which deployed this mine.
	std::wstring owner;
	///	The mine's colour.
	ThreeFloats colour;
	///	The mine's radius.
	float radius;

	///	Used to flash the mine's top.
	int flash;

	///	Used to activate the mine after a while.
	int active;
	///	True if the mine is now dead.
	bool dead;
	///	True if the mine can be triggered by bullets.
	bool triggeredByBullets;
	///	True if the mine should be drawn as a pickup.
	bool camouflage;
	///	True if the mine should be drawn as a present.
	bool december;
};

#endif
