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

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

#include "simtimer.h"
#include "ai_behavior.h"
#include "hl2wars/rts_placabletank.h"
#include "ai_behavior_functank.h"
#include "hl2wars/npc/ai_behavior_placabletank.h"

//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
class CAI_PlacableTankBehavior : public CAI_SimpleBehavior
{
	DECLARE_CLASS( CAI_PlacableTankBehavior, CAI_SimpleBehavior );
	DEFINE_CUSTOM_SCHEDULE_PROVIDER;
	DECLARE_DATADESC();
	
public:
	// Contructor/Deconstructor
	CAI_PlacableTankBehavior();
	~CAI_PlacableTankBehavior();

	void UpdateOnRemove();
	
	// Identifier
	const char *GetName() {	return "PlacableTank"; }
	
	// Schedule
	bool 		CanSelectSchedule();
	void		BeginScheduleSelection();
	void		EndScheduleSelection();
	void		PrescheduleThink();

	Activity	NPC_TranslateActivity( Activity activity );

	// Conditions:
	virtual void GatherConditions();
	
	enum
	{
		SCHED_MOVE_TO_PLACABLETANK = BaseClass::NEXT_SCHEDULE,
		SCHED_FIRE_PLACABLETANK,
		SCHED_SCAN_WITH_PLACABLETANK,
		SCHED_FAIL_MOVE_TO_PLACABLETANK,
	};
	
	// Tasks
	void		StartTask( const Task_t *pTask );
	void		RunTask( const Task_t *pTask );
	
	enum
	{
		TASK_GET_PATH_TO_PLACABLETANK = BaseClass::NEXT_TASK,
		TASK_FACE_PLACABLETANK,
		TASK_HOLSTER_WEAPON2,
		TASK_FIRE_PLACABLETANK,
		TASK_SCAN_LEFT_PLACABLETANK,
		TASK_SCAN_RIGHT_PLACABLETANK,
		TASK_FORGET_ABOUT_PLACABLETANK,
		TASK_PLACABLETANK_ANNOUNCE_SCAN,
	};

	enum
	{
		COND_PLACABLETANK_DISMOUNT = BaseClass::NEXT_CONDITION,
		NEXT_CONDITION,
	};	

	// Combat.
	CBaseEntity *BestEnemy( void );
	void Event_Killed( const CTakeDamageInfo &info );

	bool HasPlacableTank( void )							{ return ( m_hPlacableTank != NULL ); }
	void SetPlacableTank( CHandle<CPlacableTank> hPlacableTank );
	CPlacableTank *GetPlacableTank() { return m_hPlacableTank; }
	void AimGun( void );

	void Dismount( void );

	int	 OnTakeDamage_Alive( const CTakeDamageInfo &info );

	// Time.
	void SetBusy( float flTime )		{ m_flBusyTime = flTime; }
	bool IsBusy( void )					{ return ( gpGlobals->curtime < m_flBusyTime ); }

	bool IsMounted( void )				{ return m_bMounted; }

private:
	
	// Schedule 
	int			SelectSchedule();
	
private:

	CHandle<CPlacableTank>	m_hPlacableTank;
	bool				m_bMounted;
	float				m_flBusyTime;
	bool				m_bSpottedPlayerOutOfCover;
};

#endif // AI_BEHAVIOR_PLACABLETANK_H