//
// Asura_Chunk_ResourceFile_Xbox360.cpp
//
// Created by KJFL - 27 June 2005
//
// Copyright (C) 2005 Rebellion, All Rights Reserved.
//
/******************************************************************************/
/* Included Files                                                             */
/******************************************************************************/

#include "Core/Asura.h"

#include "ChunkSystem/Asura_Chunk_ResourceFile_Xbox360.h"

// Asura Platform-independent
#include "ChunkSystem/Asura_Chunk_ResourceFile.h"
#include "ChunkSystem/Asura_Chunk_Stream.h"
#include "Core/Asura_Handle.h"
#include "Debugging/Asura_Assert.h"
#include "FileAccess/Asura_FileAccess.h"

// Asura Xbox 360
#include "ChunkSystem/Asura_Chunk_ResourceFile_Xbox360_Botanicals.h"
#if defined ASURA_USE_CARPET
	#include "ChunkSystem/Asura_Chunk_ResourceFile_Xbox360_Carpet.h"
#endif
#if defined ASURA_USE_STATIC_DECAL_SYSTEM
	#include "ChunkSystem/Asura_Chunk_ResourceFile_Xbox360_StaticDecals.h"
#endif
#include "ChunkSystem/Asura_Chunk_ResourceFile_Xbox360_Environment.h"
#include "ChunkSystem/Asura_Chunk_ResourceFile_Xbox360_Character.h"
#include "ChunkSystem/Asura_Chunk_ResourceFile_Xbox360_MaterialResponse.h"
#include "ChunkSystem/Asura_Chunk_ResourceFile_Xbox360_Object.h"
#include "ChunkSystem/Asura_Chunk_ResourceFile_Xbox360_ObjectHierarchy.h"
#include "ChunkSystem/Asura_Chunk_ResourceFile_Xbox360_Skin.h"
#include "ChunkSystem/Asura_Chunk_ResourceFile_Xbox360_StreamedSounds.h"
#include "ChunkSystem/Asura_Chunk_ResourceFile_Xbox360_XPR.h"


/******************************************************************************/
/* Asura_Chunk_ResourceFile Class Functions                                   */
/******************************************************************************/

bool Asura_Chunk_ResourceFile::Platform_Process( Asura_Handle __hFile, const char* szOriginalFileName )
{
	Asura_Chunk_File_Stream	xStream (__hFile);

	// (MP - 16.09.2002) Note that I've omitted the semi-colon at the end of
	// this macro; this stops Lint complaining.
	#define PROCESS( type, class_for_type ) \
		case type: \
		return(reinterpret_cast<class_for_type*>(this)->Process( szOriginalFileName, xStream ))

	switch( SubType )
	{
		// Process known subtypes.
		PROCESS( ASURA_RESOURCEFILE_TYPE_XBOX360_ENVIRONMENT,		Asura_Chunk_ResourceFile_Xbox360_Environment );
		PROCESS( ASURA_RESOURCEFILE_TYPE_XBOX360_CHARACTER,			Asura_Chunk_ResourceFile_Xbox360_Character );
		PROCESS( ASURA_RESOURCEFILE_TYPE_XBOX360_OBJECT,			Asura_Chunk_ResourceFile_Xbox360_Object );
		PROCESS( ASURA_RESOURCEFILE_TYPE_XBOX360_OBJECTHIERARCHY,	Asura_Chunk_ResourceFile_Xbox360_ObjectHierarchy );
		PROCESS( ASURA_RESOURCEFILE_TYPE_XBOX360_SKIN,				Asura_Chunk_ResourceFile_Xbox360_Skin );
		PROCESS( ASURA_RESOURCEFILE_TYPE_XBOX360_XPR,				Asura_Chunk_ResourceFile_Xbox360_XPR );

#ifndef ASURA_USE_AUDIO_SYSTEM
		PROCESS( ASURA_RESOURCEFILE_TYPE_XBOX360_STREAMINGSOUNDS,	Asura_Chunk_ResourceFile_Xbox360_StreamedSounds) ;
#endif

#if defined ASURA_USE_BOTANICALS
		PROCESS( ASURA_RESOURCEFILE_TYPE_XBOX360_BOTANICALS, Asura_Chunk_ResourceFile_Xbox360_Botanicals );
#endif

#if defined ASURA_USE_CARPET
		PROCESS( ASURA_RESOURCEFILE_TYPE_XBOX360_CARPET, Asura_Chunk_ResourceFile_Xbox360_Carpet );
#endif

#if defined ASURA_USE_STATIC_DECAL_SYSTEM
		PROCESS( ASURA_RESOURCEFILE_TYPE_XBOX360_STATICDECALS, Asura_Chunk_ResourceFile_Xbox360_StaticDecals );
#endif

#if defined ASURA_USE_MATERIAL_RESPONSE_SYSTEM
		PROCESS( ASURA_RESOURCEFILE_TYPE_XBOX360_MATERIALRESPONSE, Asura_Chunk_ResourceFile_Xbox360_MaterialResponse );
#endif

		default:
		{
			Asura_Assert( false, "Unrecognised resource file subtype." );
			
			// skip the data to keep things happy
			Asura_FileAccess::SkipData( __hFile, FileSize );
			return false;
		}
	}
}
