//////////////////////////////////////////////////////////////////////////////
//
// Tools_Entity_WaypointBlockerVolume.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 TOOLS_ENTITY_WAYPOINTBLOCKERVOLUME_H___
#define TOOLS_ENTITY_WAYPOINTBLOCKERVOLUME_H___ 1

//Asura
#include "Core/Asura_OrientedVolume.h"
#include "Entity/Triggers/Asura_ServerEntity_WaypointBlockerVolume.h"

//Tools
#include "Entity/Tools_Entity_Activatable_Object.h"
#include "Objects/Tools_VolumeEdit_Object.h"

class Asura_Overlay;
class Asura_Vector_2;
class Tools_WaypointBlockerVolume_VolumeEdit_Controller;

//////////////////////////////////////////////////////////////////////////////
//
// Tools_Entity_WaypointBlockerVolume
//
//////////////////////////////////////////////////////////////////////////////

class Tools_Entity_WaypointBlockerVolume : public Tools_Entity_ActivatableWithPosition_Object
{
	typedef Tools_Entity_ActivatableWithPosition_Object TOOLS_PARENT;

public :
	Tools_Entity_WaypointBlockerVolume( Asura_Entity* pxEntity );
	~Tools_Entity_WaypointBlockerVolume();

	//virtual function overides
	virtual void AddOverlayControls( Asura_Overlay* pxNewOverlay, Asura_Vector_2& xOffset );
	virtual bool CanBeCopied() const { return true; }
	virtual const char* GetTypeDescription() { return "Waypoint Blocker Volume"; }
	virtual const char* GetMyNamePrefix() const { return Tools_Entity_WaypointBlockerVolume::GetNamePrefix(); }
	virtual void PrintInfo( float& fX, float& fY );
	virtual bool HandlesThisMessage( int iMessageID );
	virtual void OnDeselection();
	virtual void Render();
	virtual bool SetParameter(Asura_Hash_ID uParamID,const class Tools_Parameter* pxParam);
	virtual void Update();
	virtual void UpdatePositionInAsuraData( bool bUpdateLinkedObjects );
	virtual void UpdateWhileSelected();
	virtual bool UseStreamCopy() const { return true; }
	virtual bool SupportsMessageEditor() { return false; }

	static void Create();
	static const char* GetNamePrefix() { return "WBV_"; }

protected:
	static void EditVolume();
	static void UseAdvancedVolumes();
	static void UseSphericalVolume();
	void ShowVolume( bool bShow );

	static bool s_bMoveVolumeWithObject;
	static bool s_bShowAllVolumes;
	static bool s_bShowBlockedLinks;

private:
	static Tools_Entity_WaypointBlockerVolume* CreateMain();

	bool m_bOverlayChanged;
	bool m_bUseAdvancedVolumes;
	Asura_Vector_3 m_xPreviousPosition;
	Tools_WaypointBlockerVolume_VolumeEdit_Controller* m_pxVolumeController;
};

//////////////////////////////////////////////////////////////////////////////
//
// Tools_WaypointBlockerVolume_VolumeEdit_Controller
//
// For dealing with editing the volumes attached to the trigger
//////////////////////////////////////////////////////////////////////////////

class Tools_WaypointBlockerVolume_VolumeEdit_Controller : public Tools_VolumeEdit_Controller
{
public:
	Tools_WaypointBlockerVolume_VolumeEdit_Controller( Tools_Entity_WaypointBlockerVolume* pxToolsEntity );

	virtual void StartVolumeEditing();
	virtual void EndVolumeEditing();

protected:
	virtual bool CanCreateVolume() { return true; }
	virtual bool CanDeleteVolume() { return GetNumberOfVolumes() > 0; }
	virtual int GetNumberOfVolumes() { return m_pxAsuraEntity->m_iNumVolumes; }

	//Gets a pointer to the bounding box for a given volume
	virtual Asura_Bounding_Box* GetVolumeBox(int iIndex) { return &( m_pxAsuraEntity->m_pxVolumes[ iIndex ].m_xBox ); }

	//Gets a pointer to the orientation for a given volume. Returns 0 if there is none
	virtual Asura_Quat* GetVolumeOrient(int iIndex) { return &( m_pxAsuraEntity->m_pxVolumes[ iIndex ].m_xOrient ); }

	//Gets a default position for volume objects that have yet to gain a proper volume
	virtual Asura_Vector_3 GetDefaultPosition() { return m_pxToolsEntity->Position; }

	//Gets the name of the owner, to use for part of the volume names
	virtual const char* GetName() { return m_pxToolsEntity->GetName(); }

	//Creates the new volume in the asura data
	virtual void CreateVolumeMain();

	//Deletes the volume from the asura data
	virtual void DeleteVolumeMain(int iIndex);

private:
	Tools_Entity_WaypointBlockerVolume*	m_pxToolsEntity;
	Asura_ServerEntity_WaypointBlockerVolume* m_pxAsuraEntity;
};

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

#endif // #ifndef TOOLS_ENTITY_WAYPOINTBLOCKERVOLUME_H___
