/*
	Trig Wars.
	Copyright (c) 2008, 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 ENEMY_WASP_MANAGER_H
#define ENEMY_WASP_MANAGER_H

//=====================================================================================================================
//=====================================================================================================================

#include "GameObjects\AIManager.h"

//=====================================================================================================================
//=====================================================================================================================

namespace Game
{
	//=================================================================================================================
	//=================================================================================================================

	class Camera2D;
	class AIManager;

	//=================================================================================================================
	/// @brief		This type of manager creates and spawns all of the wasps. Wasps are usually spawned by factories
	///				but every so often this class will spawn a few just to keep their numbers up.
	/// @remarks	This class also provides the functionality used by factories to spawn enemies
	//=================================================================================================================

	class EnemyWaspManager : public AIManager
	{
		public:

			//=========================================================================================================
			// Functions
			//=========================================================================================================

				/// Creates this manager
				
				EnemyWaspManager
				( 
					unsigned max_enemies		, 
					unsigned initial_enemies	, 
					float spawn_interval_min	, 
					float spawn_interval_max
				);
				
				/// Destroys the manager
				
				virtual ~EnemyWaspManager();
				
		protected:				

			//=========================================================================================================
			// Functions
			//=========================================================================================================			
			
				/// This virtual function creates the objects used by this manager
				
				virtual void CreatePooledObjects( std::vector<AIControlled*> & pooled_objects );
				
				/// This virtual function destroys the object pool for this type of manager:
				
				virtual void DestroyPooledObjects( std::vector<AIControlled*> & pooled_objects );				
				
				/// This virtual function is called by the base class once per frame before objects are updated. Allows for object spawning.
				
				virtual void OnAIManagerUpdate( float time_delta );
				
				/// This virtual function is called by the base class before all objects are drawn in the manager: allows for setting of rendering parameters.
				
				virtual void OnAIManagerDraw( Camera2D * c );
				
				/// Allows derived managers to update one AI object:
				
				virtual void UpdateAIObject( AIControlled * object , float time_delta );
				
				/// Allows derived managers to draw one AI object:
				
				virtual void DrawAIObject( AIControlled * object , Camera2D * c );

				/// Gets the maximum bounding volume radius for the types of enemy ships this manager looks after

				virtual float GetShipBoundingCircleRadius();
				
				/// Returns the type name for this object

				virtual const char * GetTypeName() const;
				
				/// Called when the manager is added the game. Creates the bullet manager so enemies of this type can fire
				
				virtual void OnGameAdded();
				
				// Only defined when the console is enabled

				#ifdef USE_DEBUG_CONSOLE
				
					/// Debug only function. Enables / disables drawing of the quad tree

					static bool ConCmd_G_WaspQuadTreeRender( bool arg , bool arg_given );

					/// Debug only function. Enables / disables drawing of the quad tree search test

					static bool ConCmd_G_WaspQuadTreeSearchRender( bool arg , bool arg_given );
					
					/// Debug only function. Enables / disables drawing of wander points

					static bool ConCmd_G_WaspShowWanderPoints( bool arg , bool arg_given );

				#endif
				
		private:

			//=========================================================================================================
			// Functions
			//=========================================================================================================
			
				/// Maximum number of enemies allowed
				
				unsigned m_max_enemies;
				
				/// Initial number of enmies created
				
				unsigned m_initial_enemies;
				
				/// Time between enemy spawns: mininum
				
				float m_spawn_interval_min;
				
				/// Time between enemy spawns: maximum
				
				float m_spawn_interval_max;
				
				/// Time till next enemy spawn
				
				float m_time_till_spawn;
				
				/// Spawn the initial number of enemies at the next opportunity ?
				
				bool m_do_initial_spawning;
				
				// Only defined when the console is enabled

				#ifdef USE_DEBUG_CONSOLE

					/// Debug flag: if true we draw the quad tree

					static bool s_quad_tree_render;
					
					/// Debug flag: if true we draw the quad tree search test

					static bool s_quad_tree_search_render;
					
					/// Debug flag: if true we draw wander goal points for each enemy
					
					static bool s_show_wander_points;

				#endif						
	};
};

#endif
