/*
	Wheels Of Steel
	Copyright (c) 2006, Darragh Coy.
	All rights reserved.
	Original work(s), source code & author(s) details available at: http://www.darraghcoy.com

	Redistribution and use in source and binary forms, with or without modification, are permitted 
	provided that the following conditions are met:

		* 	Redistributions of source code must retain the above copyright notice, this list of 
			conditions and the following disclaimer.
		* 	Redistributions in binary form must reproduce the above copyright notice, this list of 
			conditions and the following disclaimer in the documentation.
		* 	Neither the name of the author nor the names of contributors may be used to endorse or 
			promote products derived from this software without specific prior written permission.
		* 	The use of any third party libraries, modules or data files provided with the source 
			form of the program must follow and respect the individual licensing terms of these 
			components. You do not have permission to modify or circumvent the licensing terms for 
			provided third party components unless the third party licenses specifically allow this. 
			If you do not agree to the terms of provided third party components then you do not have 
			permission to use them in your derived work(s).
		* 	The terms of this license do not apply to separate (but related) distributions if supplied 
			by the author(s), only to the contents of this source distribution, derived works, and the 
			binaries produced by either modified or unmodified versions of the source code. The terms 
			of this license do not also apply to any third party libraries or components provided with 
			the source distribution. Such third party elements are licensed under their own separate 
			agreements.

	THIS SOFTWARE IS PROVIDED BY DARRAGH COY ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 
	BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
	ARE DISCLAIMED. IN NO EVENT SHALL DARRAGH COY BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
	EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
	OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 
	OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 
	IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#ifndef TRACKPOPULATOR_H
#define TRACKPOPULATOR_H

//##############################################################################
// C Includes
//##############################################################################

#include <stdlib.h>

//##############################################################################
// Forward declarations
//##############################################################################

class Track;
class Mipmap;
class MipmapManager;
class GameObjectManager;
class GameObject;
class Obj_Car;
class Obj_OilSpill;
class Obj_SolidObstacle;
class AIPlayer;

//##############################################################################
//##############################################################################
//##############################################################################
//##############################################################################
//
//
// Class Name:   TrackPopulator
// Purpose:      Has the simple responsibility for putting objects along the
//               track. These include the cars, static obstacles, oil spills
//               and such. This code was getting slightly bulky for the game
//               class, hence why it is placed here.
//
//
//##############################################################################
//##############################################################################
//##############################################################################
//##############################################################################

class TrackPopulator
{
 /*-----------------------------------------------------------------------------
 Public functions and data
 -----------------------------------------------------------------------------*/

 public:

        //----------------------------------------------------------------------
        // Functions
        //----------------------------------------------------------------------

        static void createTreesAndRocks (Track * track);    // creates the trees and rocks at the side of the road
        static void createOilSpills     (Track * track);    // create oil spills along the road
        static void createFinishFlags   (Track * track);    // create the finish flags at the end of the track

        // create the cars in the game at their starting positions.
        // also create AI objects to control cpu cars.

        static void createCars
        (
            Track     *  track,                    // track the cars go on
            unsigned     carCount,                 // number of cars in the game
            Obj_Car   ** cars,                     // game array where cars are stored
            AIPlayer  ** aiPlayers,                // game array where ai players are stored
            float        playerSpeedHandicap,      // acceleration or speed advantage player has over ALL the AI cars
            float        aiCarGridSpeedDifference, // difference in acceleration between any two AI cars on the grid. as we go further back the cars get slower..
            float        gridSpacing               // space between all the cars on the grid
        );

//##############################################################################
//##############################################################################
//##############################################################################
//##############################################################################

 /*-----------------------------------------------------------------------------
 Private functions and data
 -----------------------------------------------------------------------------*/

 private:

        //----------------------------------------------------------------------
        // Constants
        //----------------------------------------------------------------------

        // Trees and rocks generation parameters

        static const float TREE_ROCK_CHANCE;		// Chance that there will be an tree/rock on a side of the road at each track segment
        static const float TREE_ROCK_SCALE;			// Scale of the tree/rock from original bitmap size
        static const float TREE_ROCK_X_PADDING;		// Minimum distance from the track edge the trees/rocks are
        static const float TREE_ROCK_X_JITTER;		// How much the distance from the track side randomnly varies for trees and rocks: higher values mean further out..

        // Oil spill generation parameters

        static const float OIL_SPILL_CHANCE;		// Chance there will be an oil spill in a particular section


}; // end of: class TrackPopulator{}

//##############################################################################
// C++ Includes
//##############################################################################

#include "Track.h"
#include "Mipmap.h"
#include "MipmapManager.h"
#include "GameObjectManager.h"
#include "GameObject.h"
#include "Obj_Car.h"
#include "Obj_OilSpill.h"
#include "Obj_SolidObstacle.h"
#include "AIPlayer.h"

#endif // end of: ifndef TRACKPOPULATOR_H
