// Author : Chris Tolley
// Date   : 8/16/2004
// BugCam.h contains the class declaration for a camera which follows a bug 
// around and allows the user to control that bug.

#if !defined(AFX_BUGCAM_H__67D83139_F493_4FC6_AFA4_78E391B73506__INCLUDED_)
#define AFX_BUGCAM_H__67D83139_F493_4FC6_AFA4_78E391B73506__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include <string>
using std::string;

#include "SmartPointer.h"
#include "Bug.h"
#include "Targeter.h"

// Forward class declarations
class CInputSystem;
class quadTreeTerrain;
class QuadTree;
class SurvivalEngine;

class BugCam  
{
public:
	// Constructor
	BugCam();

	// Destructor
	virtual ~BugCam();

	// Initializes the camera
	void Initialize( CInputSystem* input, quadTreeTerrain* terrain, 
					 QuadTree* tree, SurvivalEngine* engine, string species );

	// Sets the smartpointer to a bug
	bool SetFocus( SmartPointer& bug );

	// Returns true if the target bug is a valid target
	inline bool HasValidTarget() const { return m_spBug.isValid(); };

	// Returns true if the bug in focus is at it's target
	bool IsAtTarget() const;

	// Updates the camera
	void Update( float elapsedSec );

	// Renders the target bug to the screen
	void Render();

	// Checks the input for the current state of the bug cam and
	// sets the target if there is one needed
	void CheckState();

	// Finds the nearest target, if there is one and returns it.  type is the
	// type of object that we are looking for
	SmartPointer FindTarget( string type ) const;

	// Returns the bug that this camera is focused on
	inline SmartPointer GetFocus() const { return m_spBug; };
private:
	// The bug that this camera is following around
	SmartPointer m_spBug;

	// The target of the bug the camera is focused on
	SmartPointer m_spTarget;

	// The input system this camera is based on
	CInputSystem* m_Input;

	// The terrain that this camera is used to look over
	quadTreeTerrain* m_qtTerrain;

	// The object map that all Objects are stored in
	QuadTree* m_qtTree;

	// The engine running this game
	SurvivalEngine* m_pEngine;

	// A value to keep track of the amount of time that has passed
	float m_fPercent;

	// True when the bug is actually reproducing
	bool m_bReproducing;

	// The species of bug this camera is supposed to target
	string m_sSpecies;

	// The targeter that lets the user know what object is the current target
	Targeter m_tTargeter;

	// The patrol path to pass on to the kids
	PatrolPath m_ppPath;

	// The threshold values for the kiddies
	ThresholdValues m_tvThresholds;
};

#endif // !defined(AFX_BUGCAM_H__67D83139_F493_4FC6_AFA4_78E391B73506__INCLUDED_)
