/*
	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 GAMEOBJECT_H
#define GAMEOBJECT_H

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

class Window;
class Camera;
class Track;
class TrackSection;
class Mipmap;

//##############################################################################
//##############################################################################
//##############################################################################
//##############################################################################
//
//
// Class Name:   GameObject
// Purpose:      Mostly abstract class that defines basic functionality and
//               attributes for all the objects in the game
//
//
//##############################################################################
//##############################################################################
//##############################################################################
//##############################################################################

class GameObject
{
 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 GameObjectManager is the overlord for all game objects, thus is the only
 class to have to access private members of all gameobjects
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/

 friend class GameObjectManager;

 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 Public functions and data
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/

 public:

        //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        // Functions
        //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

        // Constructor: initialise position of the object

        GameObject( float pos_x , float pos_y , float pos_z , bool moveable );

        // Destructor:

        virtual ~GameObject(){};

        // Event handlers:

        virtual void event_collision( GameObject * collider ) = 0;          // Collision event: called by game when collision occurs with an object
        virtual void event_draw( Window & window , Camera * camera ) = 0;   // Draw event: called when the game wants to draw the object
        virtual void event_move( Track * track , float frameTime ) = 0;     // Move event: called before the object is to move

        // accessors

        inline float getPos_x() const {return pos_x;}
        inline float getPos_y() const {return pos_y;}
        inline float getPos_z() const {return pos_z;}

        inline float getSize_x() const {return size_x;}
        inline float getSize_y() const {return size_y;}
        inline float getSize_z() const {return size_z;}

        inline float getVel_x() const {return vel_x;}
        inline float getVel_y() const {return vel_y;}
        inline float getVel_z() const {return vel_z;}

        inline int getSection(){return section;}

        // Modifiers

        inline void setSize_x(float x){ if(x >= 0 ) size_x = x; }
        inline void setSize_y(float y){ if(y >= 0 ) size_y = y; }
        inline void setSize_z(float z){ if(z >= 0 ) size_z = z; }

        inline void setVel_x(float x){ vel_x = x; }
        inline void setVel_y(float y){ vel_y = y; }
        inline void setVel_z(float z){ vel_z = z; }

        // Draw a perspectively scaled image: a common drawing function to all game objects used in the draw event

        void GameObject::drawPerspectiveImage
        (
            Window & window ,
            Camera * camera ,
            const Mipmap * mipmap

        )  const ;

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

 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 Protected functions and data
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/

 protected:

        //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        // Variables
        //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

        // acceleration vector

        float acl_x;    // object acceleration x
        float acl_y;    // object acceleration y
        float acl_z;    // object acceleration z

        // velocity vector

        float vel_x;    // object velocity x
        float vel_y;    // object velocity y
        float vel_z;    // object velocity z

        // size vector

        float size_x;   // object size x
        float size_y;   // object size y
        float size_z;   // object size z

        bool gravityAffected;   // is the object affected by gravity ?
        bool solid;             // Is the object solid ? Collision events will still be called if not, but no collision response

        float weight;           // Weight of the object- must be non zero

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

 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 Private functions and data
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/

private:

        //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        // Variables
        //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

        // position vector

        float pos_x;    // object position x
        float pos_y;    // object position y
        float pos_z;    // object position z

        // Is the object moveable ? Changeable only by the game manager. Game manager separates non movable objects into another array for speed.

        bool moveable;

        // The objects array position in the game object manager's internal array. used only by the game object manager.

        int mgrArrayPos;

        // track section the object is on

        int section;

}; // end of: class GameObject


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

#include "Window.h"
#include "Camera.h"
#include "TrackSection.h"
#include "Track.h"
#include "Mipmap.h"

#endif // end of: ifndef GAMEOBJECT_H
