//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
//
// Purpose: 
//
// $NoKeywords: $
//=============================================================================//

#ifndef NEW_BOT_H
#define NEW_BOT_H
#ifdef _WIN32
#pragma once
#endif

#include "player.h"
#include "hl2wars/hl2wars_player.h"

class CBotNavigator;
class CBotPathfinder;

// This is our bot class.
class CBot : public CHL2Wars_Player
{
public:
	CBot();

	void Precache();
	void Spawn();

	//void CreateMove( CUserCmd *pCmd );

	virtual void Update();

	void HandleSendCmd();
	void RunPlayerMove( CUserCmd &cmd, float frametime );

	void SetGoal( Vector goal, float tolerance );
	Vector GetGoal();

	CBotNavigator *GetNavigator() { return m_pNavigator; }
	CBotPathfinder *GetPathfinder() { return m_pPathFinder; }

	Vector				GetLookAtTarget();
	void				SetLookAtTarget( Vector target );

public:
	bool			m_bBackwards;

	float			m_flNextTurnTime;
	bool			m_bLastTurnToRight;

	float			m_flNextStrafeTime;
	
	float			m_flForwardMove;
	float			m_flSideMove;
	float			m_fUpMove;

	QAngle			m_vViewAngles;

	int				m_iButtons;	

	QAngle			m_ForwardAngle;
	QAngle			m_LastAngles;

// components
private:
	Vector m_vLookAtTarget;

	CBotNavigator *m_pNavigator;
	CBotPathfinder *m_pPathFinder;
};

class CBotComponent
{
public:
	CBotComponent( CBot *pOuter = NULL )
		: m_pOuter(pOuter)
	{
	}

	virtual void		SetOuter( CBot *pOuter )	{ m_pOuter = pOuter; }

	CBot *				GetOuter() 			{ return m_pOuter; }
	const CBot *		GetOuter() const 	{ return m_pOuter; }

protected:
	//
	// Common services provided by CBot, Convenience methods to simplify derived code
	//
	edict_t *			GetEdict();

	const Vector &		GetLocalOrigin() const;
	void 				SetLocalOrigin( const Vector &origin );

	const Vector &		GetAbsOrigin() const;
	const QAngle&		GetAbsAngles() const;

	void				SetLocalAngles( const QAngle& angles );
	const QAngle &		GetLocalAngles( void ) const;

private:
	CBot *m_pOuter;
};

//=============================================================================//
//
// Purpose: Component stuff
//
// $NoKeywords: $
//=============================================================================//
//-----------------------------------------------------------------------------

inline const Vector &CBotComponent::GetLocalOrigin() const
{
	return GetOuter()->GetLocalOrigin();
}

//-----------------------------------------------------------------------------

inline void CBotComponent::SetLocalOrigin(const Vector &origin)
{
	GetOuter()->SetLocalOrigin(origin);
}

//-----------------------------------------------------------------------------

inline const Vector &CBotComponent::GetAbsOrigin() const
{
	return GetOuter()->GetAbsOrigin();
}

//-----------------------------------------------------------------------------

inline const QAngle &CBotComponent::GetAbsAngles() const
{
	return GetOuter()->GetAbsAngles();
}

inline void CBotComponent::SetLocalAngles( const QAngle& angles )
{
	GetOuter()->SetLocalAngles( angles );
}

//-----------------------------------------------------------------------------

inline const QAngle &CBotComponent::GetLocalAngles( void ) const
{
	return GetOuter()->GetLocalAngles();
}

//-----------------------------------------------------------------------------

inline edict_t *CBotComponent::GetEdict()
{
	return GetOuter()->NetworkProp()->edict();
}


// run and put in server

// If iTeam or iClass is -1, then a team or class is randomly chosen.
CBasePlayer *BotPutInServer( bool bFrozen, int iTeam, int iClass );

void Bot_RunAll();


#endif // NEW_BOT_H
