//	ShockwaveEntity.cpp - Represents a collidable shockwave.
//  ----------------------------------------------------------------------------
//	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 "drawing/Drawer.h"
#include "MiscHelper.h"
#include "ShockwaveEntity.h"

//------------------------------------------------------------------------------
ShockwaveEntity::ShockwaveEntity(const TwoFloats& pos, const ThreeFloats& col):
Collidable(L"Shockwave"),
position(pos),
colour(col),
index(0.0f)
{

}

//------------------------------------------------------------------------------
ShockwaveEntity::~ShockwaveEntity()
{

}

//------------------------------------------------------------------------------
bool ShockwaveEntity::update()
{
	bool retval = false;

	if(index < 0.66f)
		index += 0.01f + ((0.66f-index) * 0.03f);
	else
		index += 0.01f;

	if(index > 1.0f)
		retval = true;

	return retval;
}

//------------------------------------------------------------------------------
void ShockwaveEntity::draw(shared_ptr<Drawer>& d, float timestepInterp)
{
	float tempf;

	if(index < 0.66f)
		tempf = 1.0f;
	else
		tempf = 1.0f-fakeLog((index-0.66f)*(1.0f/0.33f));

	d->drawImage(L"Shockwave",
				 position-(index * 64.0f),
				 index,
				 colour,
				 tempf);
}

//------------------------------------------------------------------------------
bool ShockwaveEntity::interestedInCollisionsWith(const std::wstring& entity) const
{
	bool retval = false;

	if((entity == L"Tank") || (entity == L"Bullet"))
		retval = true;

	return retval;
}

//------------------------------------------------------------------------------
bool ShockwaveEntity::collide(const shared_ptr<Collidable>& other,
						GamePlayState& state)
{
	return false;
}
