//
// Asura_Chunk_ReverbVolumes.cpp
//
// Created by Richard Rice - 10/10/2007
// 
// Copyright (C) 2007 Rebellion, All Rights Reserved.
//

#include "Core/Asura.h"
#include "ChunkSystem/Asura_Chunk_ReverbVolumes.h"

#ifdef ASURA_USE_REVERBVOLUME_SYSTEM

#include "ChunkSystem/Asura_Chunk_Stream.h"
#include "ChunkSystem/Asura_SaveBlock.h"
#include "Sound/Asura_ReverbVolume_System.h"
#include "Sound/Asura_ReverbVolume.h"

#define ASURA_CHUNK_REVERBVOLUMES_VERSION 0


bool Asura_Chunk_ReverbVolumes::Process(Asura_Chunk_Stream& xStream) const
{
	// Is this the correct version?

	if (Version > ASURA_CHUNK_REVERBVOLUMES_VERSION)
	{
		Asura_Assertf(false, ("Unknown chunk version %d for reverb volumes",Version));
		return false;
	}

	Asura_ReverbVolume_Controller* pxController = Asura_ReverbVolume_System::GetReverbVolumeController();
	Asura_Assert(pxController,"");

	pxController->ReadFromChunkStream(xStream);

	return true;
}

bool Asura_Chunk_ReverbVolumes::Process(Asura_Handle iFileHandle) const
{
	Asura_Chunk_File_Stream	xStream(iFileHandle);
	return Process(xStream);
}

#ifdef ASURA_TOOLS
void Asura_Chunk_ReverbVolumes::Create(Asura_Chunk_Stream& xStream)
{
	u_int uChunkFlags = 0;

	xStream.WriteChunk_Start(ASURA_CHUNK_REVERBVOLUMES, ASURA_CHUNK_REVERBVOLUMES_VERSION, uChunkFlags);
		
	Asura_ReverbVolume_Controller* pxController = Asura_ReverbVolume_System::GetReverbVolumeController();
	Asura_Assert(pxController,"");

	pxController->WriteToChunkStream(xStream);

	xStream.WriteChunk_End();
}

void Asura_Chunk_ReverbVolumes::Create(Asura_SaveBlock* pxSaveBlock)
{
	Asura_Chunk_SaveBlock_Stream xStream(pxSaveBlock);
	Create	(xStream);
}


#endif // ASURA_TOOLS




#endif //ASURA_USE_REVERBVOLUME_SYSTEM
