//////////////////////////////////////////////////////////////////////////////
//
// ToolsAVP_Node_VantagePoint_Predator.cpp
//
// Copyright (C) 2008 Rebellion. All Rights Reserved.
//
//////////////////////////////////////////////////////////////////////////////

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

// core
#include "Core/Asura.h"

// header
#include "Entity/Locations/VantagePoint/ToolsAVP_Node_VantagePoint_Predator.h"

// asura
#include "Camera/Asura_Camera.h"

// axon

// avp
#include "Entity/Locations/VantagePoint/AVP_ServerNode_VantagePoint_Predator.h"

// tools
#include "Load&Save/Tools_SaveAsura.h"
#include "Misc/Tools_Timed_Messages.h"
#include "Objects/Tools_Object_System.h"

//////////////////////////////////////////////////////////////////////////////
//
// ToolsAVP_Node_VantagePoint_Predator
//
//////////////////////////////////////////////////////////////////////////////

ToolsAVP_Node_VantagePoint_Predator::ToolsAVP_Node_VantagePoint_Predator( Asura_Entity* pxEntity )
: PARENT( pxEntity )
{
	Type = TOT_Entity_VantagePoint_Predator;

	SetMesh( "ToolsShape_PredatorVantagePoint" );
}

bool ToolsAVP_Node_VantagePoint_Predator::IsBaseOrDerivativeOf( int iToolsObjectType ) const
{
	if ( iToolsObjectType == TOT_Entity_VantagePoint_Predator )
	{
		return true;
	}
	return PARENT::IsBaseOrDerivativeOf( iToolsObjectType );
}

Tools_Object* ToolsAVP_Node_VantagePoint_Predator::CreateObjectOfThisType() const
{
	return CreateAndReturn();
}

void ToolsAVP_Node_VantagePoint_Predator::Create()
{
	CreateAndReturn();
}

AVP_ServerNode_VantagePoint_Predator* ToolsAVP_Node_VantagePoint_Predator::GetGameVantagePoint() const
{
	return static_cast< AVP_ServerNode_VantagePoint_Predator* >( Entity );
}

ToolsAVP_Node_VantagePoint_Predator* ToolsAVP_Node_VantagePoint_Predator::CreateAndReturn()
{
	// Get a new GUID
	const Asura_Guid uGuid = Asura_Entity_System::GetCreatedByToolsGuid();

	// Set up tools data and auto-create a unique name (prompt for new name if there is a clash).
	Tools_Entity_Data* pxToolsData = CreateToolsDataWithDefaultName( "Predator Vantage Point", "PVP", uGuid );
	if ( !pxToolsData ) { return NULL; }

	// Create the game specfic server object and set its data.
	AVP_ServerNode_VantagePoint_Predator* pxGamePoint = new AVP_ServerNode_VantagePoint_Predator( uGuid );
	if ( !pxGamePoint ) { return NULL; }

	pxGamePoint->ToolsData = pxToolsData;

	// Create the game specific tools object and select it.
	ToolsAVP_Node_VantagePoint_Predator* pxToolsPoint = new ToolsAVP_Node_VantagePoint_Predator( pxGamePoint );
	if ( !pxToolsPoint ) { return NULL; }

	Tools_Object_System::SelectObject( pxToolsPoint );

	pxToolsPoint->Position = *Asura_Camera::GetPosition();
	pxToolsPoint->Orientation = *Asura_Camera::GetOrientation();

	pxGamePoint->SetPosition( pxToolsPoint->Position );

	Tools_Timed_Message_System::AddMessage( Tools_Timed_Message_System::COLOUR_DEFAULT, "Created new Predator Vantage Point" );
	Tools_SaveAsura::SetEntityModified();

	return pxToolsPoint;
}

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