//	BulletModifiers.h - Base classes for the various Bullet modifiers.
//  ----------------------------------------------------------------------------
//	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 BULLETMODIFIERS_H_
#define BULLETMODIFIERS_H_

#include "c0xHeaders.h"
#include "TwoFloats.h"

class GamePlayState;
class Collidable;
class Bullet;

//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
///	Base class for modifiers which activate when the Bullet collides with a wall.
class BulletCollisionModifier
{
  public:
	///	Constructor.
	BulletCollisionModifier() {};
	///	Destructor.
	virtual ~BulletCollisionModifier() {};

	///	Called when the passed-in bullet collides with a wall.
	virtual void wallCollide(Bullet& bullet,
							 GamePlayState& state,
							 const shared_ptr<Collidable>& wall) = 0;
};

//------------------------------------------------------------------------------
///	Base class used to create a BulletCollisionModifier.
class BulletCollisionCreatorBase
{
  public:
	///	Constructor.
	BulletCollisionCreatorBase() {};
	///	Destructor.
	virtual ~BulletCollisionCreatorBase() {};

	///	Constructs the modifier.
	virtual shared_ptr<BulletCollisionModifier> createModifier() const = 0;
};
///	The template class used to actually create a BulletCollisionModifier.
template <class T>
class BulletCollisionCreator : public BulletCollisionCreatorBase
{
  public:
	///	Constructor.
	BulletCollisionCreator() {};
	///	Destructor.
	~BulletCollisionCreator() {};

	///	Constructs the modifier.
	shared_ptr<BulletCollisionModifier> createModifier() const {return shared_ptr<BulletCollisionModifier>(new T());};
};

//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
///	Base class for modifiers which activate when the Bullet dies.
class BulletDeathModifier
{
  public:
	///	Constructor.
	BulletDeathModifier() {};
	///	Destructor.
	virtual ~BulletDeathModifier() {};

	///	Called when the Bullet dies.
	virtual void bulletDeath(Bullet& bullet, GamePlayState& state) = 0;
};

//------------------------------------------------------------------------------
///	Base class used to create a BulletDeathModifier.
class BulletDeathCreatorBase
{
  public:
	///	Constructor.
	BulletDeathCreatorBase() {};
	///	Destructor.
	virtual ~BulletDeathCreatorBase() {};

	///	Constructs the modifier.
	virtual shared_ptr<BulletDeathModifier> createModifier() const = 0;
};
///	The template class used to actually create a BulletDeathModifier.
template <class T>
class BulletDeathCreator : public BulletDeathCreatorBase
{
  public:
	///	Constructor.
	BulletDeathCreator() {};
	///	Destructor.
	~BulletDeathCreator() {};

	///	Constructs the modifier.
	shared_ptr<BulletDeathModifier> createModifier() const {return shared_ptr<BulletDeathModifier>(new T());};
};

//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
///	Base class for modifiers which alter Bullets' direction.
class BulletDirectionModifier
{
  public:
	///	Constructor.
	BulletDirectionModifier() {};
	///	Destructor.
	virtual ~BulletDirectionModifier() {};

	///	Called for every frame in the Bullet's update() method.
	virtual void alterDirection(TwoFloats& dir,
								Bullet& bullet,
								GamePlayState& state) = 0;
};

//------------------------------------------------------------------------------
///	Base class used to create a BulletDirectionModifier.
class BulletDirectionCreatorBase
{
  public:
	///	Constructor.
	BulletDirectionCreatorBase() {};
	///	Destructor.
	virtual ~BulletDirectionCreatorBase() {};

	///	Constructs the modifier.
	virtual shared_ptr<BulletDirectionModifier> createModifier() const = 0;
};
///	The template class used to actually create a BulletDirectionModifier.
template <class T>
class BulletDirectionCreator : public BulletDirectionCreatorBase
{
  public:
	///	Constructor.
	BulletDirectionCreator() {};
	///	Destructor.
	~BulletDirectionCreator() {};

	///	Constructs the modifier.
	shared_ptr<BulletDirectionModifier> createModifier() const {return shared_ptr<BulletDirectionModifier>(new T());};
};

#endif
