//////////////////////////////////////////////////////////////////////////////
//
// Tools_Project_Entity_StartPoint.cpp
//
// Copyright (c) 2005 Rebellion. All rights reserved.
//
//////////////////////////////////////////////////////////////////////////////

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

#include "Core/Asura.h"
#include "Entity/Tools_Entity_StartPoint.h"

#include "Camera/Asura_Camera.h"
#include "Entity/Spawners/AVP_ServerEntity_StartPoint.h"

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

#include "Entity/Spawners/ToolsAVP_Entity_StartPoint.h"

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

void Tools_Entity_StartPoint::Project_Create()
{
	// 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( "Start Pos (Single Player)", "Start Point (SP)", uGuid );
	if( !pxToolsData )
	{
		Asura_Assert( pxToolsData, "Tools_Entity_StartPoint::Create - no tools data" );
		return;
	}

	// Create the game specfic server object and set its data.
	AVP_ServerEntity_StartPoint* pxServerObject = new AVP_ServerEntity_StartPoint(uGuid);
	pxServerObject->SetBlueprintTypeHashID( 0xe294c1b2 );	// Asura_GetHashID( "players" )
	pxServerObject->SetBlueprintHashID( 0xa328fe6e );		// Asura_GetHashID( "startpoint" )

	Asura_Assert( pxServerObject, "Tools_Entity_StartPoint::Create - no server object" );
	if ( pxServerObject )
	{
		pxServerObject->ToolsData = pxToolsData;
	}

	// Create the game specific tools object and select it.
	Tools_Entity_StartPoint* pxToolsObject = new ToolsAVP_Entity_StartPoint(pxServerObject);

	Asura_Assert( pxToolsObject, "Tools_Entity_StartPoint::Create - no tools object" );
	Tools_Object_System::SelectObject( pxToolsObject );

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

	pxServerObject->m_xPosition = pxToolsObject->Position;
	pxServerObject->m_xOrientation = pxToolsObject->Orientation;

	Tools_Timed_Message_System::AddMessage( 0xffffff, "Created new Start Point");
	Tools_SaveAsura::SetEntityModified();
}

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