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

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

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

// header
#include "ChunkSystem/Asura_Chunk_WaypointingSettings.h"

// asura
#include "AI/Asura_AI_Navigation.h"
#include "Core/Asura_String.h"
#include "ChunkSystem/Asura_Chunk_Stream.h"
#include "ChunkSystem/Asura_SaveBlock.h"
#include "FileAccess/Asura_FileAccess.h"

#ifdef ASURA_TOOLS
// tools
#include "Waypointing/Tools_Mode_Waypointing.h"
#endif

//////////////////////////////////////////////////////////////////////////////
//
// Asura_Chunk_WaypointingSettings
//
//////////////////////////////////////////////////////////////////////////////

bool Asura_Chunk_WaypointingSettings::Process( Asura_Chunk_Stream& xStream ) const
{
	if ( Version == iCURRENT_VERSION )
	{
#ifdef ASURA_TOOLS
		xStream >> Tools_Mode_Waypointing::s_bShouldGenCoverpoints;
		xStream >> Tools_Mode_Waypointing::s_bShouldCalcZoningData;
		xStream >> Tools_Mode_Waypointing::s_fMinWaypointRadius;
		xStream >> Tools_Mode_Waypointing::s_fMaxWaypointRadius;
		xStream >> Tools_Mode_Waypointing::s_fMinDenseWaypointRadius;
		xStream >> Tools_Mode_Waypointing::s_fMaxDenseWaypointRadius;
		xStream >> Tools_Mode_Waypointing::s_fMinLinkLength;
		xStream >> Tools_Mode_Waypointing::s_fMaxLinkLength;
		xStream >> Tools_Mode_Waypointing::s_fMaxLinkFallDistance;

		Asura_AI_Navigation_System::s_fMaxWaypointRadius = Tools_Mode_Waypointing::s_fMaxWaypointRadius;
#else
		bool bDummy;
		float fDummy;
		xStream >> bDummy;
		xStream >> bDummy;
		xStream >> fDummy;
		xStream >> Asura_AI_Navigation_System::s_fMaxWaypointRadius;
		xStream >> fDummy;
		xStream >> fDummy;
		xStream >> fDummy;
		xStream >> fDummy;
		xStream >> fDummy;
#endif
	}
	else
	{
		Asura_Assertf(false, ("Asura_Chunk_WaypointingSettings::Process - unknown chunk version (%d)",Version));
		return false;
	}

	return true;
}

bool Asura_Chunk_WaypointingSettings::Process( const int iFileHandle ) const
{
	Asura_Chunk_File_Stream xStream( iFileHandle );
	return Process( xStream );
}

#ifdef ASURA_TOOLS
bool Asura_Chunk_WaypointingSettings::Create( Asura_Chunk_Stream& xStream )
{
	xStream.WriteChunk_Start( ASURA_CHUNK_WAYPOINTINGSETTINGS, iCURRENT_VERSION, 0 );

	xStream << Tools_Mode_Waypointing::s_bShouldGenCoverpoints;
	xStream << Tools_Mode_Waypointing::s_bShouldCalcZoningData;
	xStream << Tools_Mode_Waypointing::s_fMinWaypointRadius;
	xStream << Tools_Mode_Waypointing::s_fMaxWaypointRadius;
	xStream << Tools_Mode_Waypointing::s_fMinDenseWaypointRadius;
	xStream << Tools_Mode_Waypointing::s_fMaxDenseWaypointRadius;
	xStream << Tools_Mode_Waypointing::s_fMinLinkLength;
	xStream << Tools_Mode_Waypointing::s_fMaxLinkLength;
	xStream << Tools_Mode_Waypointing::s_fMaxLinkFallDistance;

	xStream.WriteChunk_End();

    return true;
}
#endif

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