//////////////////////////////////////////////////////////////////////////////
//
// AVP_Behaviour_Alien_CycleRoundDelayed.h
//
// Copyright (C) 2008 Rebellion. All Rights Reserved.
//
//////////////////////////////////////////////////////////////////////////////

// B E G I N   F I L E   W R A P P E R ///////////////////////////////////////

#ifdef ASURA_USE_PRAGMA_ONCE
#pragma once
#endif

#ifndef __AVP_BEHAVIOUR_ALIEN_CYCLEROUNDDELAYED_H__
#define __AVP_BEHAVIOUR_ALIEN_CYCLEROUNDDELAYED_H__ 1

// E N D   F I L E   W R A P P E R ///////////////////////////////////////////

// I N C L U D E S ///////////////////////////////////////////////////////////

// asura
#include "Network/Asura_Guid.h"

// axon
#include "Behaviour/Axon_Project_Behaviour.h"

// F O R W A R D   D E C L A R A T I O N S ///////////////////////////////////

class AVP_Brain_Actor_Alien;

//////////////////////////////////////////////////////////////////////////////
//
// AVP_Behaviour_Alien_CycleRoundDelayed
//
//////////////////////////////////////////////////////////////////////////////

class AVP_Behaviour_Alien_CycleRoundDelayed : public Axon_Project_Behaviour
{
	typedef Axon_Project_Behaviour PARENT;

public:
	AVP_Behaviour_Alien_CycleRoundDelayed( Axon_Project_Brain* pxBrain );

	void SetDestroyNotUnspawn( const bool bDestroy ) { m_bDestroy = bDestroy; }

protected:
	virtual void Deactivate();
	virtual void PerFrameUpdate( const float fTimeslice );
	virtual void Update( const float fTimeslice );

#ifndef ASURA_NO_DEBUG_OUTPUT
	virtual void RenderDebugInfo();
#endif

private:
	enum State
	{
		UNSET,
		RUNNING_TO_HIDE,
		RUNNING_TO_UNSPAWN,
		RUNNING_AWAY,
		UNSPAWNING_GAMESCENE,
		WAITING_UNTIL_NOT_RENDERED,
		FINISHED
	};

	void UnspawnOrDestroy();
	void SwitchToState( int iNewState );
	AVP_Brain_Actor_Alien* GetAlienBrain() const;
	u_int GetHideWP() const;

private:
	// Total number of attempts at getting to a spawn point.
	u_int      m_uNumAttempts;
	Asura_Guid m_uDespawnPointGuid;
	u_int	   m_uHideWP;
	bool	   m_bDestroy;

#ifndef ASURA_NO_DEBUG_OUTPUT
	static const char* s_aszStateStrings[];
#endif
};

//////////////////////////////////////////////////////////////////////////////
//
// 
//
//////////////////////////////////////////////////////////////////////////////

#endif //__AVP_BEHAVIOUR_ALIEN_CYCLEROUNDDELAYED_H__
