//	IncendiaryField.cpp - Explodes on collision with bullets.
//  ----------------------------------------------------------------------------
//	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 "IncendiaryField.h"
#include "GamePlayState.h"
#include "MiscHelper.h"
#include "Bullet.h"

//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
PuddleCollisionCreator<IncendiaryField> IncendiaryField::creator;

//------------------------------------------------------------------------------
IncendiaryField::IncendiaryField(const shared_ptr<Mine>& mine):
PuddleCollisionModifier(mine)
{

}

//------------------------------------------------------------------------------
IncendiaryField::~IncendiaryField()
{

}

//------------------------------------------------------------------------------
void IncendiaryField::collideTank(Puddle& puddle, Tank& tank, GamePlayState& state)
{

}

//------------------------------------------------------------------------------
void IncendiaryField::collideBullet(Puddle& puddle,
									Bullet& bullet,
									GamePlayState& state)
{
	if(bullet.getParent() != L"Incendiary field")
	{
		int i;
		TwoFloats dir;

		for(i=0;i<8;++i)
		{
			dir.x = sinf(((float)i/8.0f) * 2.0f * NIALL_PI);
			dir.y = cosf(((float)i/8.0f) * 2.0f * NIALL_PI);

			state.firePlainBullet(bullet.getPosition(),
								  dir,
								  getColour(),
								  L"Incendiary field");
		}

		bullet.setDead();
	}
}

//------------------------------------------------------------------------------
void IncendiaryField::collideZombie(Puddle& puddle,
									Zombie& zombie,
									GamePlayState& state)
{

}

//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void IncendiaryFieldCreator::apply(GamePlayState& state)
{
	state.registerPuddleCollisionMod(&IncendiaryField::creator);
}
