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

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

class GLWindow;
class GLWindowEventListener;
class Timer;
class Mesh;
class MeshManager;
class Player;
class MovingGameObject;
class Game;
class GameObjectHook;
class GameScene;
class GameObject_Ship;
class GuiScreen_SpaceStation;
class Sound;
class SoundManager;
class SoundSystem;

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

#include <Windows.h>
#include <gl/gl.h>
#include "MathLibrary.h"

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

#include "StaticGameObject.h"

//##############################################################################
//##############################################################################
//##############################################################################
//##############################################################################
//
//
// Class Name:   GameObject_SpaceStation
// Purpose:      Class that describes the spacestation. Tracks the players ship
//               and initiates the spacestation menu if the player gets close
//               enough to the spacestation entrance.
//
//
//##############################################################################
//##############################################################################
//##############################################################################
//##############################################################################

class GameObject_SpaceStation : public StaticGameObject
{

 public:

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

        // Constructor for spacestation

        GameObject_SpaceStation
        (
            float    pos_x,     // initial position: x
            float    pos_y,     // initial position: y
            float    pos_z,     // initial position: z
            Game   * game       // Game the spacestation belongs to
        );

        // On draw event: draws black fog inside the docking part of the spacestation

        void onDraw( Camera * camera );

        // On frame event: spawns particles

        void onFrame( float frameTime );

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

 protected:

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

        static const float DOCK_SPHERE_X;               // bounding sphere which player must enter to initiate docking, position x in objects coordinate system
        static const float DOCK_SPHERE_Y;               // bounding sphere which player must enter to initiate docking, position y in objects coordinate system
        static const float DOCK_SPHERE_Z;               // bounding sphere which player must enter to initiate docking, position z in objects coordinate system
        static const float DOCK_SPHERE_RADIUS;          // bounding sphere which player must enter to initiate docking, radius
        static const float DOCK_FADE_TIME;              // Time the screen fade when docking takes in seconds
        static const float ROTATE_SPEED;                // speed at which the spacestation rotates about the z axis
        static const float PARTICLE_INTERVAL;           // time in betweeen when spacestation creates particles
        static const float PARTICLE_TIME;               // time the particles created live for
        static const float PARTICLE_SIZE;               // size of the particles created
        static const float PARTICLE_R;                  // color of space station particles: red
        static const float PARTICLE_G;                  // color of space station particles: green
        static const float PARTICLE_B;                  // color of space station particles: blue
        static const float PARTICLE_NOISE_DISTANCE;     // distance from which the particle noise can be heard

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

        // Spawn particles along the arms of the spacestation at regular intervals

        void spawnParticles( float frameTime );

        // Check if the player is in position to dock with the space station

        void dockingCheck();

        // Begins the docking procedure

        void dock();

        //----------------------------------------------------------------------
        // Variables
        //----------------------------------------------------------------------

        // Game the spacestation belongs to

        Game * game;

        // Time till next particles are spawned:

        float timeToParticles;

        // Which of the four particle sets to spawn. There are four separate sets of
        // particles and the spacestation alternates between spawning different sets
        // each time it goes to spawn particles.

        unsigned spawnParticleSet;

}; // end of: class GameObject_SpaceStation{}

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

#include "GLWindow.h"
#include "GLWindowEventListener.h"
#include "Timer.h"
#include "Mesh.h"
#include "MeshManager.h"
#include "Player.h"
#include "MovingGameObject.h"
#include "Game.h"
#include "GameObjectHook.h"
#include "GameScene.h"
#include "GameObject_Ship.h"
#include "GuiScreen_SpaceStation.h"
#include "Sound.h"
#include "SoundManager.h"
#include "SoundSystem.h"

#endif // end of: ifndef GAMEOBJECT_SHIP_H
