//////////////////////////////////////////////////////////////////////////////
//
// AVP_Brain_Actor_Dropship.h
//
// Copyright (C) 2007 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_BRAIN_ACTOR_DROPSHIP_H__
#define __AVP_BRAIN_ACTOR_DROPSHIP_H__ 1

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

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

#include "Core/BrainTypes/AVP_Brain_Actor.h"

// asura
#include "Core/Asura_HashedList.h"
#include "Core/AVP_Navigation_Types.h"

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

class AVP_ServerVehicle_Dropship;
class AVP_ClientVehicle_Dropship;
//////////////////////////////////////////////////////////////////////////////
//
// AVP_Brain_Actor_Dropship
//
//////////////////////////////////////////////////////////////////////////////

class AVP_Brain_Actor_Dropship : public AVP_Brain_Actor
{
    typedef AVP_Brain_Actor PARENT;

public:
    AVP_Brain_Actor_Dropship( AVP_ServerVehicle_Dropship* pxDropship );

	virtual void Initialise();
	virtual void Shutdown();
    virtual void InitialiseFromBlueprint( const Asura_Blueprint& xBlueprint );
    virtual void ReadFromChunkStream( Asura_Chunk_Stream& xStream );
    virtual void WriteToChunkStream( Asura_Chunk_Stream& xStream ) const;
	virtual void PostLoadInitialise();

	virtual void DoPerFrameUpdate(const float fTimeslice);

    virtual Axon_Behaviour* CreateBehaviour( const u_int uBehaviourType, const Asura_Message* pxMessage = NULL );

    // must implement 
	virtual Asura_Guid GetPrimaryThreatGuid( void );
	virtual Asura_Guid GetAlertGuid( void );

	AVP_ServerVehicle_Dropship* GetDropshipActor() const;
	AVP_ClientVehicle_Dropship* GetDropshipClientActor() const;

	// Equip weapons
	void EquipMissile(u_int uLauncherNumber);
	bool IsMissileReady(u_int uLauncherNumber) const;
	bool FireMissile();
	bool AreFrontPodsOpened() const;
	bool AreFrontPodsClosed() const;
	bool AreBackPodsOpened() const;
	bool AreBackPodsClosed() const;
	bool AreBackPodsDoorsOpened() const;
	bool AreBackPodsDoorsClosed() const;
	void OpenFrontPods();
	void CloseFrontPods();
	void OpenBackPods();
	void CloseBackPods();
	void OpenBackPodsDoors();
	void CloseBackPodsDoors();

	static u_int GetLargestBehaviourSize();

	float ExpandPath(Asura_LinkList<Asura_Vector_3>& xPathSegments);

	bool GetTarget(Asura_Vector_3& xTarget);
	void RefreshMissValue();

	void SetAttackMode(bool bUseMissiles, bool bUseMachinegun, bool bMiss)
	{
		m_bUseMissiles = bUseMissiles;
		m_bUseMachinegun = bUseMachinegun;
		m_bDoesMiss = bMiss; 
	}
	bool GetUseMissiles() const { return m_bUseMissiles; }
	bool GetUseMachinegun() const { return m_bUseMachinegun; }
	bool GetMiss() const { return m_bDoesMiss; }

protected:
    virtual bool HandleMessage( const Asura_Message* pxMessage );

#ifndef ASURA_NO_DEBUG_OUTPUT
	virtual bool Verify();
#endif

private:
	// Note: Parent function is public
	virtual void EstablishNavData();

	void FindTarget();
	
	void UpdateWeaponState();

private:

	Asura_Guid m_uEndSplineNodeID;
	Asura_Guid m_uTargetID;
	float m_fTimeSinceTargetSelected;
	
	enum WeaponType { WEAPON_LAUNCHER, WEAPON_NONE };
	
	WeaponType m_eDesiredWeaponType;
	u_int m_uLauncherNumber;
	bool m_bWeaponStatusNeedUpdate;

	bool m_bUseMissiles;
	bool m_bUseMachinegun;

	Asura_Vector_3 m_xMissDelta;
	bool m_bDoesMiss;

    enum { CURRENT_CHUNK_VERSION = 0 };
};

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

#endif //__AVP_BRAIN_ACTOR_DROPSHIP_H__
