//	ToneGenerator.h - Base class for all ToneGenerators.
//  ----------------------------------------------------------------------------
//	This file is part of 'GameTemplate', template code for a game.
//	Copyright (C) 2011  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 TONEGENERATOR_H_
#define TONEGENERATOR_H_

#include "c0xHeaders.h"
#include "Pickup.h"
#include "Tone.h"

#include <vector>
#include <memory>
#include <map>

class Sounder;

///	Base class for all ToneGenerators.
/*!
	ToneGenerators are used to determine when to add new Tones onto the
	playfield, which Tones to add, and where they should be added.

	Which Tones to add and where they should be added is generally
	determined by ToneCreator rules.
 */
class ToneGenerator
{
  public:
	///	Constructor.
	ToneGenerator() {};
	///	Destructor.
	virtual ~ToneGenerator() {};

	///	Called for every frame in the game.
	/*!
		\param tonesInPlay Vector of all the Tones currently in play. This is
		so the Generator can avoid adding new Tones too close to existing
		Tones, giving the player no time to react.
		\param toneTypesInPlay A map of all the types of Tones currently in
		play, alongside how many of those types are in play.
		\param pickupsInPlay Any Pickups that need generated should be added to
		this.
		\param numWarnings The number of Tones currently on screen which are
		in danger of crashing.
		\param numRails The current number of available rails. Subclasses may
		update this; note the reference.
		\param globalSpeed The global speed Tones are moving relative to (so
		fewer Tones get generated when the Tones are moving slowly => less
		bunched up).
		\param maxRailStart This is to ensure we avoid triggering Tones on rails
		which are about to disappear due to the number of rails changing. It
		will always be <= numRails. Generators should not generate Tones on rails
		>= maxRailStart, even though those rails (currently) still exist.
		\param sounder The game's sounder.

		\return Vector of any new Tones to be added to the playfield in this
		frame. Note that it's a reference (to avoid a whole vector copy); make
		sure you keep hold of the vector after this method returns.

		Subclasses should keep some kind of timer which they can use to
		determine when to add new Tones. New Tones can be created via the
		ToneCreators returned by ToneFactory.
	 */
	virtual std::vector<TonePtr>& tick(const std::vector<TonePtr>& tonesInPlay,
									   const std::map<std::wstring, int>& toneTypesInPlay,
									   std::vector<PickupPtr>& pickupsInPlay,
									   int numWarnings,
									   int& numRails,
									   float globalSpeed,
									   int maxRailStart,
									   shared_ptr<TonesSounder>& sounder) = 0;
};

#endif
