//	BulletCreator.cpp - Factory class used to create Bullets with the correct
//					    set of 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/>.
//	----------------------------------------------------------------------------

#include "BulletModifiers.h"
#include "BulletCreator.h"
#include "Bullet.h"

//------------------------------------------------------------------------------
BulletCreator::BulletCreator()
{

}

//------------------------------------------------------------------------------
BulletCreator::~BulletCreator()
{

}

//------------------------------------------------------------------------------
shared_ptr<Bullet> BulletCreator::getBullet(const TwoFloats& pos,
											const TwoFloats& dir,
											const ThreeFloats& col,
											const std::wstring& parent)
{
	unsigned int i;
	shared_ptr<Bullet> retval(new Bullet(pos, dir, col, parent));

	for(i=0;i<collisionMods.size();++i)
	{
		shared_ptr<BulletCollisionModifier> mod = collisionMods[i]->createModifier();

		retval->addCollisionModifier(mod);
	}
	for(i=0;i<deathMods.size();++i)
	{
		shared_ptr<BulletDeathModifier> mod = deathMods[i]->createModifier();
		
		retval->addDeathModifier(mod);
	}
	for(i=0;i<directionMods.size();++i)
	{
		shared_ptr<BulletDirectionModifier> mod = directionMods[i]->createModifier();
		
		retval->addDirectionModifier(mod);
	}

	return retval;
}

//------------------------------------------------------------------------------
shared_ptr<Bullet> BulletCreator::getPlainBullet(const TwoFloats& pos,
												 const TwoFloats& dir,
												 const ThreeFloats& col,
												 const std::wstring& parent)
{
	shared_ptr<Bullet> retval(new Bullet(pos, dir, col, parent));

	return retval;
}

//------------------------------------------------------------------------------
void BulletCreator::addCollisionModifier(BulletCollisionCreatorBase * mod)
{
	collisionMods.push_back(mod);
}

//------------------------------------------------------------------------------
void BulletCreator::addDeathModifier(BulletDeathCreatorBase * mod)
{
	deathMods.push_back(mod);
}

//------------------------------------------------------------------------------
void BulletCreator::addDirectionModifier(BulletDirectionCreatorBase * mod)
{
	directionMods.push_back(mod);
}
