/*
	Rogue Trader.
	Copyright (c) 2007, 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 PLAYERAI_H
#define PLAYERAI_H

//##############################################################################
// Forward references
//##############################################################################

class GLWindow;
class GameScene;

//##############################################################################
// Base class: cannot be forward referenced
//##############################################################################

#include "Player.h"

//##############################################################################
//##############################################################################
//##############################################################################
//##############################################################################
//
//
// Class Name:   PlayerAI
// Purpose:      Class for an AI player. Controls a ship and tries to kill player.
//
//
//##############################################################################
//##############################################################################
//##############################################################################
//##############################################################################

class PlayerAI : public Player
{

  public:

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

        // Constructor:

        PlayerAI
        (
            GameObjectHook * hookShip    ,  // hook to ship ai player will control
            GameObjectHook * hookTarget  ,  // hook to ship ai player will target
            double credits                  // number of credits the ai player will have
        );

        // Make the AI players move:

        void makeMove( float frameTime );

        // Decide where the AI player will move to next:

        void pickTargetPoint( float frameTime );

        // Decide whether the ship will fire its lasers or not

        void decideToFireLasers( float frameTime );

        // Decide whether the ship wll fire missiles or not:

        void decideToFireMissiles( float frameTime );

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

  private:

        //----------------------------------------------------------------------
        // Constants:
        //----------------------------------------------------------------------

        static const float MIN_PLAYER_SEPARATION_DISTANCE;  // minimum distance the AI would like to be from the player
        static const float MAX_TURN_AMOUNT;                 // maximum amount in radians the ai can turn per second
        static const float LASER_FIRE_CLOSNESS;             // controls how close the ais ship must be oriented to players ship to fire
        static const float REACTION_SPEED;                  // determines how fast the AI responds to changes in the players position
        static const float MISSILE_FIRE_CHANCE;             // Likelyness that the AI player will try and fire a missile per second

        //----------------------------------------------------------------------
        // Variables:
        //----------------------------------------------------------------------

        // Hook to ship that AI player will target:

        GameObjectHook * hookTarget;

        // Target point the AI will try to pilot ship towards:

        float targetX;
        float targetY;
        float targetZ;

        // Was the AI's ship too close for comfort to the players ship last time we checked ?

        bool playerTooCloseLastMove;
};

//##############################################################################
// C++ includes
//##############################################################################

#include "GLWindow.h"
#include "GameScene.h"

#endif // ifndef PLAYERAI_H
